X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=homescreen%2Fsrc%2Fmain.cpp;h=215e7c6c899fd3581096fb08ae80acc8d9a99e33;hb=b9889b160ecc43dcde07fe9d8a96373196c539ab;hp=47d4f1617c8067d49fbf5cd24d68bb41b7fae917;hpb=0592a405aa68f3baf6773795efa5522e4ee16779;p=apps%2Fhomescreen.git diff --git a/homescreen/src/main.cpp b/homescreen/src/main.cpp index 47d4f16..215e7c6 100644 --- a/homescreen/src/main.cpp +++ b/homescreen/src/main.cpp @@ -26,15 +26,40 @@ #include "applicationlauncher.h" #include "statusbarmodel.h" #include "applicationmodel.h" +#include "appinfo.h" +#include "afm_user_daemon_proxy.h" +#include "mastervolume.h" +#include "paclient.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 &) { } +} + int main(int argc, char *argv[]) { QGuiApplication a(argc, argv); + 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"); @@ -54,18 +79,26 @@ int main(int argc, char *argv[]) qInstallMessageHandler(noOutput); } + // Fire up PA client QThread + QThread* pat = new QThread; + PaClient* client = new PaClient(); + client->moveToThread(pat); + pat->start(); + qDBusRegisterMetaType(); qDBusRegisterMetaType >(); qmlRegisterType("HomeScreen", 1, 0, "ApplicationLauncher"); qmlRegisterType("Home", 1, 0, "ApplicationModel"); qmlRegisterType("HomeScreen", 1, 0, "StatusBarModel"); + qmlRegisterType("MasterVolume", 1, 0, "MasterVolume"); QQmlApplicationEngine engine; LayoutHandler* layoutHandler = new LayoutHandler(); HomeScreenControlInterface* hsci = new HomeScreenControlInterface(); + QObject::connect(hsci, SIGNAL(newRequestGetSurfaceStatus(int)), layoutHandler, SLOT(requestGetSurfaceStatus(int))); QObject::connect(hsci, SIGNAL(newRequestsToBeVisibleApp(int)), layoutHandler, SLOT(makeMeVisible(int))); QObject::connect(hsci, SIGNAL(newRequestRenderSurfaceToArea(int, int)), layoutHandler, SLOT(requestRenderSurfaceToArea(int,int))); @@ -76,5 +109,14 @@ int main(int argc, char *argv[]) engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); + QList mobjs = engine.rootObjects(); + MasterVolume *mv = mobjs.first()->findChild("mv"); + engine.rootContext()->setContextProperty("MasterVolume", mv); + QObject::connect(mv, SIGNAL(sliderVolumeChanged(int)), client, SLOT(incDecVolume(int))); + QObject::connect(client, SIGNAL(volumeExternallyChanged(int)), mv, SLOT(changeExternalVolume(int))); + + // Initalize PA client + client->init(); + return a.exec(); }