summaryrefslogtreecommitdiffstats
path: root/sample
diff options
context:
space:
mode:
Diffstat (limited to 'sample')
-rw-r--r--sample/app/app.pro12
-rw-r--r--sample/app/eventhandler.cpp19
-rw-r--r--sample/app/eventhandler.h2
-rw-r--r--sample/app/main.cpp33
-rw-r--r--sample/app/main.qml6
-rw-r--r--sample/package/package.pro6
-rw-r--r--sample/package/qml/images/answer.png (renamed from sample/ons/images/answer.png)bin2688 -> 2688 bytes
-rw-r--r--sample/package/qml/images/disable.png (renamed from sample/ons/images/disable.png)bin2714 -> 2714 bytes
-rw-r--r--sample/package/qml/images/heart_1079x400.png (renamed from sample/ons/images/heart_1079x400.png)bin20429 -> 20429 bytes
-rw-r--r--sample/package/qml/images/images.qrc (renamed from sample/ons/images/images.qrc)0
-rw-r--r--sample/package/qml/images/oval_1079x400.png (renamed from sample/ons/images/oval_1079x400.png)bin18800 -> 18800 bytes
-rw-r--r--sample/package/qml/images/reject.png (renamed from sample/ons/images/reject.png)bin4820 -> 4820 bytes
-rw-r--r--sample/package/qml/msg.qml (renamed from sample/ons/msg.qml)1
-rw-r--r--sample/package/qml/phone.qml (renamed from sample/ons/phone.qml)1
-rw-r--r--sample/package/qml/system.qml (renamed from sample/ons/system.qml)1
-rw-r--r--sample/package/qml/vics.qml (renamed from sample/ons/vics.qml)1
-rw-r--r--sample/readme.md2
17 files changed, 52 insertions, 32 deletions
diff --git a/sample/app/app.pro b/sample/app/app.pro
index b4c75f3..22d0c89 100644
--- a/sample/app/app.pro
+++ b/sample/app/app.pro
@@ -1,5 +1,9 @@
TARGET = onstestapp
-QT = quick
+QT = quick quickcontrols2 qml
+
+CONFIG += c++11 link_pkgconfig
+PKGCONFIG += qlibwindowmanager qlibhomescreen
+DESTDIR = $${OUT_PWD}/../package/root/bin
SOURCES = main.cpp \
eventhandler.cpp
@@ -7,10 +11,8 @@ SOURCES = main.cpp \
RESOURCES += \
qml.qrc
-LIBS += -lqtwindowmanager -lqthomescreen -ljson-c
-
-DESTDIR = $${OUT_PWD}/../package/root/bin
-
HEADERS += \
eventhandler.h
+LIBS += -ljson-c
+
diff --git a/sample/app/eventhandler.cpp b/sample/app/eventhandler.cpp
index b88bda4..34e7e3e 100644
--- a/sample/app/eventhandler.cpp
+++ b/sample/app/eventhandler.cpp
@@ -19,11 +19,15 @@
#include <QJsonDocument>
#include <QJsonObject>
#include <QQuickWindow>
-#include <QtQml/QQmlContext>
+//#include <QtQml/QQmlContext>
+#include <QQmlContext>
+#include <QtQml/QQmlApplicationEngine>
#include "eventhandler.h"
void* EventHandler::myThis = 0;
+const char _drawing_name[] = "drawing_name";
+
EventHandler::EventHandler(QObject *parent) :
QObject(parent),
mp_hs(NULL),
@@ -52,8 +56,8 @@ void EventHandler::init(int port, const char *token)
mp_hs = new QLibHomeScreen();
mp_hs->init(port, token);
- mp_hs->set_event_handler(QLibHomeScreen::Event_TapShortcut, [this](json_object *object){
- this->mp_wm->activateWindow(ROLE_NAME);
+ mp_hs->set_event_handler(QLibHomeScreen::Event_ShowWindow, [this](json_object *object){
+ this->mp_wm->activateWindow(ROLE_NAME, "normal");
HMI_DEBUG(APP_ID, "received showWindow event, end!, line=%d", __LINE__);
});
@@ -76,7 +80,7 @@ void EventHandler::init(int port, const char *token)
mp_wm->set_event_handler(QLibWindowmanager::Event_Visible, [this](json_object *object) {
struct json_object *value;
- json_object_object_get_ex(object, "drawing_name", &value);
+ json_object_object_get_ex(object, _drawing_name, &value);
const char *name = json_object_get_string(value);
HMI_DEBUG(APP_ID, "Event_Active kKeyDrawingName = %s", name);
@@ -84,7 +88,7 @@ void EventHandler::init(int port, const char *token)
mp_wm->set_event_handler(QLibWindowmanager::Event_Invisible, [this](json_object *object) {
struct json_object *value;
- json_object_object_get_ex(object, "drawing_name", &value);
+ json_object_object_get_ex(object, _drawing_name, &value);
const char *name = json_object_get_string(value);
HMI_DEBUG(APP_ID, "Event_Inactive kKeyDrawingName = %s", name);
@@ -106,3 +110,8 @@ void EventHandler::showWindow(QString id, QString json)
else
mp_hs->showWindow(id.toStdString().c_str(), json_tokener_parse(json.toStdString().c_str()));
}
+
+void EventHandler::hideWindow(QString id)
+{
+ mp_hs->hideWindow(id.toStdString().c_str());
+}
diff --git a/sample/app/eventhandler.h b/sample/app/eventhandler.h
index 61b519b..c601d0d 100644
--- a/sample/app/eventhandler.h
+++ b/sample/app/eventhandler.h
@@ -31,6 +31,7 @@
using namespace std;
class QQuickWindow;
+class QQmlApplicationEngine;
class EventHandler : public QObject
{
@@ -44,6 +45,7 @@ public:
static void* myThis;
Q_INVOKABLE void showWindow(QString id, QString json);
+ Q_INVOKABLE void hideWindow(QString id);
signals:
void signalOnReplyShowWindow(QVariant val);
diff --git a/sample/app/main.cpp b/sample/app/main.cpp
index 5e822f7..69642dc 100644
--- a/sample/app/main.cpp
+++ b/sample/app/main.cpp
@@ -14,20 +14,17 @@
* limitations under the License.
*/
-#include <QUrlQuery>
#include <QQmlContext>
-#include <QtCore/QDebug>
#include <QtCore/QCommandLineParser>
-#include <QtCore/QUrlQuery>
#include <QtGui/QGuiApplication>
#include <QtQml/QQmlContext>
#include <QtQml/QQmlApplicationEngine>
#include <QtQuickControls2/QQuickStyle>
#include <QtQuick/QQuickWindow>
+#include <QtCore/QDir>
#include "eventhandler.h"
-static EventHandler* eventHandler;
int main(int argc, char *argv[])
{
@@ -39,7 +36,7 @@ int main(int argc, char *argv[])
app.setOrganizationDomain(QStringLiteral("automotivelinux.org"));
app.setOrganizationName(QStringLiteral("AutomotiveGradeLinux"));
- //QQuickStyle::setStyle("AGL");
+ QQuickStyle::setStyle("AGL");
QCommandLineParser parser;
parser.addPositionalArgument("port", app.translate("main", "port for binding"));
@@ -50,33 +47,31 @@ int main(int argc, char *argv[])
QStringList positionalArguments = parser.positionalArguments();
QQmlApplicationEngine engine;
- QQmlContext *context = engine.rootContext();
- QUrl bindingAddress;
int port = 0;
QString secret;
if (positionalArguments.length() == 2) {
port = positionalArguments.takeFirst().toInt();
secret = positionalArguments.takeFirst();
- bindingAddress.setScheme(QStringLiteral("ws"));
- bindingAddress.setHost(QStringLiteral("localhost"));
- bindingAddress.setPort(port);
- bindingAddress.setPath(QStringLiteral("/api"));
- QUrlQuery query;
- query.addQueryItem(QStringLiteral("token"), secret);
- bindingAddress.setQuery(query);
- context->setContextProperty(QStringLiteral("bindingAddress"), bindingAddress);
- } else {
- context->setContextProperty(QStringLiteral("bindingAddress"), bindingAddress);
}
- eventHandler = new EventHandler();
+ EventHandler *eventHandler = new EventHandler();
eventHandler->init(port, secret.toStdString().c_str());
engine.rootContext()->setContextProperty("eventHandler", eventHandler);
+ QString qmldir = QCoreApplication::applicationDirPath();
+ qmldir.replace(QString("bin"), QString("qml"));
+ qmldir.append('/');
+ qDebug() << "####qmldir=" << qmldir;
+ engine.rootContext()->setContextProperty("qmldir", qmldir);
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
+ if (engine.rootObjects().isEmpty()) {
+ HMI_DEBUG(APP_ID, "Fatal Error, rootObject is empty!");
+ return -1;
+ }
+ qDebug() << "####" << QDir::currentPath() << QCoreApplication::applicationDirPath();
+
QObject *root = engine.rootObjects().first();
QQuickWindow *window = qobject_cast<QQuickWindow *>(root);
-
QObject::connect(eventHandler, SIGNAL(signalOnReplyShowWindow(QVariant)), window, SLOT(qmlOnReplyShowWindow(QVariant)));
eventHandler->setQuickWindow(window);
diff --git a/sample/app/main.qml b/sample/app/main.qml
index ccce169..94de871 100644
--- a/sample/app/main.qml
+++ b/sample/app/main.qml
@@ -3,7 +3,7 @@ import QtQuick.Window 2.2
import QtQuick.Controls 2.0
import QtQuick.Layouts 1.0
import QtQuick.VirtualKeyboard 2.1
-
+import AGL.Demo.Controls 1.0
ApplicationWindow {
id: root
@@ -12,7 +12,8 @@ ApplicationWindow {
height: 1487
property string onsId: qsTr("onscreenapp")
- property string pri_path: qsTr("/home/0/app-data/OnScreen/qml/")
+// property string pri_path: qsTr("/home/0/app-data/OnScreen/qml/")
+ property string pri_path: qmldir
property string filepath: pri_path + qsTr("vics.qml")
property string msgdata: ""
property string postmsg: ""
@@ -354,5 +355,6 @@ ApplicationWindow {
function qmlOnReplyShowWindow(text) {
console.log("onstestapp received:",text);
output.text = text;
+ eventHandler.hideWindow(onsId);
}
}
diff --git a/sample/package/package.pro b/sample/package/package.pro
index faf285c..5a0c7d8 100644
--- a/sample/package/package.pro
+++ b/sample/package/package.pro
@@ -13,6 +13,12 @@ copy_config.commands = $(COPY_FILE) \"$$replace(copy_config.depends, /, $$QMAKE_
QMAKE_EXTRA_TARGETS += copy_config
PRE_TARGETDEPS += $$copy_config.target
+copy_qml.target = $$OUT_PWD/root/qml/
+copy_qml.depends = $$_PRO_FILE_PWD_/qml/.
+copy_qml.commands = $(COPY_DIR) \"$$replace(copy_qml.depends, /, $$QMAKE_DIR_SEP)\" \"$$replace(copy_qml.target, /, $$QMAKE_DIR_SEP)\"
+QMAKE_EXTRA_TARGETS += copy_qml
+PRE_TARGETDEPS += $$copy_qml.target
+
wgt.target = package
wgt.commands = wgtpkg-pack -f -o onstestapp.wgt root
diff --git a/sample/ons/images/answer.png b/sample/package/qml/images/answer.png
index 4707a23..4707a23 100644
--- a/sample/ons/images/answer.png
+++ b/sample/package/qml/images/answer.png
Binary files differ
diff --git a/sample/ons/images/disable.png b/sample/package/qml/images/disable.png
index 8c08c03..8c08c03 100644
--- a/sample/ons/images/disable.png
+++ b/sample/package/qml/images/disable.png
Binary files differ
diff --git a/sample/ons/images/heart_1079x400.png b/sample/package/qml/images/heart_1079x400.png
index e1fe683..e1fe683 100644
--- a/sample/ons/images/heart_1079x400.png
+++ b/sample/package/qml/images/heart_1079x400.png
Binary files differ
diff --git a/sample/ons/images/images.qrc b/sample/package/qml/images/images.qrc
index b75641f..b75641f 100644
--- a/sample/ons/images/images.qrc
+++ b/sample/package/qml/images/images.qrc
diff --git a/sample/ons/images/oval_1079x400.png b/sample/package/qml/images/oval_1079x400.png
index fb850df..fb850df 100644
--- a/sample/ons/images/oval_1079x400.png
+++ b/sample/package/qml/images/oval_1079x400.png
Binary files differ
diff --git a/sample/ons/images/reject.png b/sample/package/qml/images/reject.png
index d6586e1..d6586e1 100644
--- a/sample/ons/images/reject.png
+++ b/sample/package/qml/images/reject.png
Binary files differ
diff --git a/sample/ons/msg.qml b/sample/package/qml/msg.qml
index d6adb97..f89ffa0 100644
--- a/sample/ons/msg.qml
+++ b/sample/package/qml/msg.qml
@@ -9,6 +9,7 @@ Item {
visible: true
width: 1079
height: 400
+ scale: screenInfo.scale_factor()
function qmlOnScreenParameter(message) {
console.log(qsTr('OnScreenVICS:QML:System >>> qmlOnScreenMessage.'), message);
diff --git a/sample/ons/phone.qml b/sample/package/qml/phone.qml
index 3fc23ee..1b25ed3 100644
--- a/sample/ons/phone.qml
+++ b/sample/package/qml/phone.qml
@@ -9,6 +9,7 @@ Item {
visible: true
width: 1079
height: 400
+ scale: screenInfo.scale_factor()
property string messageText: "Incoming Call"
function qmlOnScreenParameter(message) {
diff --git a/sample/ons/system.qml b/sample/package/qml/system.qml
index 8592698..d42eeb7 100644
--- a/sample/ons/system.qml
+++ b/sample/package/qml/system.qml
@@ -9,6 +9,7 @@ Item {
visible: true
width: 1079
height: 400
+ scale: screenInfo.scale_factor()
function qmlOnScreenParameter(message) {
console.log(qsTr('OnScreenSys:QML:System >>> qmlOnScreenMessage.'), message);
diff --git a/sample/ons/vics.qml b/sample/package/qml/vics.qml
index 30d5cd1..2848fbc 100644
--- a/sample/ons/vics.qml
+++ b/sample/package/qml/vics.qml
@@ -9,6 +9,7 @@ Item {
visible: true
width: 1079
height: 400
+ scale: screenInfo.scale_factor()
function qmlOnScreenParameter(message) {
console.log(qsTr('OnScreenVICS:QML:System >>> qmlOnScreenMessage.'), message);
diff --git a/sample/readme.md b/sample/readme.md
index ae6d0da..539f386 100644
--- a/sample/readme.md
+++ b/sample/readme.md
@@ -8,7 +8,7 @@ A test application for onscreenapp
- when onscreenapp is compiled, this app's wgt file will exist at "onscreenapp/sample/package", called onstestapp.wgt.
- install
-: `afm-util install onstestapp.wgt;sync`
+ `afm-util install onstestapp.wgt;sync`
## dependence