summaryrefslogtreecommitdiffstats
path: root/sample/app/main.cpp
diff options
context:
space:
mode:
authorwang_zhiqiang <wang_zhiqiang@dl.cn.nexty-ele.com>2018-11-29 11:13:12 +0800
committerwang_zhiqiang <wang_zhiqiang@dl.cn.nexty-ele.com>2018-11-29 11:13:12 +0800
commit5ba4327b148f81852c6e2a53bc51ab07b238602e (patch)
tree0be7f86962e8a26ad3cdbc6cb4309c5fd29761f5 /sample/app/main.cpp
parente79d82c88e350e6b882158624363b82fe3e2d91a (diff)
modify display/hide onscreen sequence
Diffstat (limited to 'sample/app/main.cpp')
-rw-r--r--sample/app/main.cpp33
1 files changed, 14 insertions, 19 deletions
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);