X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=homescreen%2Fsrc%2Fmain.cpp;h=b92ff607da2ad2b5836800c11c4deb8b5eed6864;hb=3f99bee502be1f49801797a50c041c3f177535c5;hp=19bb0d3f69412e284155462f5d3cd7b671c4cf05;hpb=7a78d97346aad35b1ad023fe8d3a369e45b61ee8;p=apps%2Fhomescreen.git diff --git a/homescreen/src/main.cpp b/homescreen/src/main.cpp index 19bb0d3..b92ff60 100644 --- a/homescreen/src/main.cpp +++ b/homescreen/src/main.cpp @@ -1,6 +1,6 @@ /* * Copyright (C) 2016, 2017 Mentor Graphics Development (Deutschland) GmbH - * Copyright (c) 2017 TOYOTA MOTOR CORPORATION + * Copyright (c) 2017, 2018 TOYOTA MOTOR CORPORATION * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,6 +17,7 @@ #include #include +#include #include #include #include @@ -25,43 +26,18 @@ #include #include +#include #include "applicationlauncher.h" #include "statusbarmodel.h" -#include "afm_user_daemon_proxy.h" #include "mastervolume.h" #include "homescreenhandler.h" #include "hmi-debug.h" - -// XXX: We want this DBus connection to be shared across the different -// QML objects, is there another way to do this, a nice way, perhaps? -org::AGL::afm::user *afm_user_daemon_proxy; - -namespace { - -struct Cleanup { - static inline void cleanup(org::AGL::afm::user *p) { - delete p; - afm_user_daemon_proxy = Q_NULLPTR; - } -}; - -void noOutput(QtMsgType, const QMessageLogContext &, const QString &) -{ -} - -} +#include "chromecontroller.h" int main(int argc, char *argv[]) { QGuiApplication a(argc, argv); - // use launch process - QScopedPointer afm_user_daemon_proxy(new org::AGL::afm::user("org.AGL.afm.user", - "/org/AGL/afm/user", - QDBusConnection::sessionBus(), - 0)); - ::afm_user_daemon_proxy = afm_user_daemon_proxy.data(); - QCoreApplication::setOrganizationDomain("LinuxFoundation"); QCoreApplication::setOrganizationName("AutomotiveGradeLinux"); QCoreApplication::setApplicationName("HomeScreen"); @@ -74,9 +50,10 @@ int main(int argc, char *argv[]) parser.addVersionOption(); parser.process(a); QStringList positionalArguments = parser.positionalArguments(); - + int port = 1700; QString token = "wm"; + QString graphic_role = "homescreen"; // defined in layers.json in Window Manager if (positionalArguments.length() == 2) { port = positionalArguments.takeFirst().toInt(); @@ -89,6 +66,8 @@ int main(int argc, char *argv[]) // qmlRegisterType("HomeScreen", 1, 0, "ApplicationLauncher"); qmlRegisterType("HomeScreen", 1, 0, "StatusBarModel"); qmlRegisterType("MasterVolume", 1, 0, "MasterVolume"); + qmlRegisterUncreatableType("SpeechChrome", 1, 0, "SpeechChromeController", + QLatin1String("SpeechChromeController is uncreatable.")); ApplicationLauncher *launcher = new ApplicationLauncher(); QLibWindowmanager* layoutHandler = new QLibWindowmanager(); @@ -96,12 +75,14 @@ int main(int argc, char *argv[]) exit(EXIT_FAILURE); } - if (layoutHandler->requestSurface(QString("HomeScreen")) != 0) { + AGLScreenInfo screenInfo(layoutHandler->get_scale_factor()); + + if (layoutHandler->requestSurface(graphic_role) != 0) { exit(EXIT_FAILURE); } - layoutHandler->set_event_handler(QLibWindowmanager::Event_SyncDraw, [layoutHandler](json_object *object) { - layoutHandler->endDraw(QString("HomeScreen")); + layoutHandler->set_event_handler(QLibWindowmanager::Event_SyncDraw, [layoutHandler, &graphic_role](json_object *object) { + layoutHandler->endDraw(graphic_role); }); layoutHandler->set_event_handler(QLibWindowmanager::Event_ScreenUpdated, [layoutHandler, launcher](json_object *object) { @@ -130,15 +111,23 @@ int main(int argc, char *argv[]) // mail.qml loading QQmlApplicationEngine engine; + engine.rootContext()->setContextProperty("bindingAddress", bindingAddress); engine.rootContext()->setContextProperty("layoutHandler", layoutHandler); engine.rootContext()->setContextProperty("homescreenHandler", homescreenHandler); engine.rootContext()->setContextProperty("launcher", launcher); engine.rootContext()->setContextProperty("weather", new Weather(bindingAddress)); + engine.rootContext()->setContextProperty("bluetooth", new Bluetooth(bindingAddress, engine.rootContext())); + engine.rootContext()->setContextProperty("speechChromeController", new ChromeController(bindingAddress, &engine)); + engine.rootContext()->setContextProperty("screenInfo", &screenInfo); engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); QObject *root = engine.rootObjects().first(); QQuickWindow *window = qobject_cast(root); QObject::connect(window, SIGNAL(frameSwapped()), layoutHandler, SLOT(slotActivateSurface())); + QList sobjs = engine.rootObjects(); + StatusBarModel *statusBar = sobjs.first()->findChild("statusBar"); + statusBar->init(bindingAddress, engine.rootContext()); + return a.exec(); }