diff options
Diffstat (limited to 'homescreen/src')
-rw-r--r-- | homescreen/src/applicationlauncher.cpp | 30 | ||||
-rw-r--r-- | homescreen/src/applicationlauncher.h | 10 | ||||
-rw-r--r-- | homescreen/src/main.cpp | 15 |
3 files changed, 53 insertions, 2 deletions
diff --git a/homescreen/src/applicationlauncher.cpp b/homescreen/src/applicationlauncher.cpp index 7e1cda1..5a1e2d6 100644 --- a/homescreen/src/applicationlauncher.cpp +++ b/homescreen/src/applicationlauncher.cpp @@ -26,7 +26,23 @@ extern org::AGL::afm::user *afm_user_daemon_proxy; ApplicationLauncher::ApplicationLauncher(QObject *parent) : QObject(parent) + , m_launching(false) + , m_timeout(new QTimer(this)) { + m_timeout->setInterval(3000); + m_timeout->setSingleShot(true); + connect(m_timeout, &QTimer::timeout, [&]() { + setLaunching(false); + }); + connect(this, &ApplicationLauncher::launchingChanged, [&](bool launching) { + if (launching) + m_timeout->start(); + else + m_timeout->stop(); + }); + connect(this, &ApplicationLauncher::currentChanged, [&]() { + setLaunching(false); + }); } int ApplicationLauncher::launch(const QString &application) @@ -38,12 +54,24 @@ int ApplicationLauncher::launch(const QString &application) HMI_DEBUG("HomeScreen","ApplicationLauncher pid: %d.", result); if (result > 1) { - setCurrent(application); + setLaunching(true); } return result; } +bool ApplicationLauncher::isLaunching() const +{ + return m_launching; +} + +void ApplicationLauncher::setLaunching(bool launching) +{ + if (m_launching == launching) return; + m_launching = launching; + launchingChanged(launching); +} + QString ApplicationLauncher::current() const { return m_current; diff --git a/homescreen/src/applicationlauncher.h b/homescreen/src/applicationlauncher.h index 697dad0..dfa5846 100644 --- a/homescreen/src/applicationlauncher.h +++ b/homescreen/src/applicationlauncher.h @@ -21,17 +21,22 @@ #include <QtCore/QObject> +class QTimer; + class ApplicationLauncher : public QObject { Q_OBJECT + Q_PROPERTY(bool launching READ isLaunching NOTIFY launchingChanged) Q_PROPERTY(QString current READ current WRITE setCurrent NOTIFY currentChanged) public: explicit ApplicationLauncher(QObject *parent = NULL); + bool isLaunching() const; QString current() const; signals: void newAppRequestsToBeVisible(int pid); + void launchingChanged(bool launching); void currentChanged(const QString ¤t); public slots: @@ -39,7 +44,12 @@ public slots: void setCurrent(const QString ¤t); private: + void setLaunching(bool launching); + +private: + bool m_launching; QString m_current; + QTimer *m_timeout; }; #endif // APPLICATIONLAUNCHER_H diff --git a/homescreen/src/main.cpp b/homescreen/src/main.cpp index e0850d6..522f957 100644 --- a/homescreen/src/main.cpp +++ b/homescreen/src/main.cpp @@ -87,7 +87,7 @@ int main(int argc, char *argv[]) HMI_DEBUG("HomeScreen","port = %d, token = %s", port, token.toStdString().c_str()); // import C++ class to QML - qmlRegisterType<ApplicationLauncher>("HomeScreen", 1, 0, "ApplicationLauncher"); + // qmlRegisterType<ApplicationLauncher>("HomeScreen", 1, 0, "ApplicationLauncher"); qmlRegisterType<ApplicationModel>("Home", 1, 0, "ApplicationModel"); qmlRegisterType<StatusBarModel>("HomeScreen", 1, 0, "StatusBarModel"); qmlRegisterType<MasterVolume>("MasterVolume", 1, 0, "MasterVolume"); @@ -96,6 +96,7 @@ int main(int argc, char *argv[]) qDBusRegisterMetaType<AppInfo>(); qDBusRegisterMetaType<QList<AppInfo> >(); + ApplicationLauncher *launcher = new ApplicationLauncher(); QLibWindowmanager* layoutHandler = new QLibWindowmanager(); if(layoutHandler->init(port,token) != 0){ exit(EXIT_FAILURE); @@ -109,6 +110,17 @@ int main(int argc, char *argv[]) layoutHandler->endDraw(QString("HomeScreen")); }); + layoutHandler->set_event_handler(QLibWindowmanager::Event_Visible, [layoutHandler, launcher](json_object *object) { + QString label = QString(json_object_get_string( json_object_object_get(object, "drawing_name") )); + qDebug() << label; + QMetaObject::invokeMethod(launcher, "setCurrent", Qt::QueuedConnection, Q_ARG(QString, label == "HomeScreen" ? "Home" : label)); + }); + + layoutHandler->set_event_handler(QLibWindowmanager::Event_Invisible, [layoutHandler, launcher](json_object *object) { + const char* label = json_object_get_string( json_object_object_get(object, "drawing_name") ); + HMI_DEBUG("HomeScreen", "surface %s Event_Invisible", label); + }); + HomescreenHandler* homescreenHandler = new HomescreenHandler(); homescreenHandler->init(port, token.toStdString().c_str()); @@ -116,6 +128,7 @@ int main(int argc, char *argv[]) QQmlApplicationEngine engine; engine.rootContext()->setContextProperty("layoutHandler", layoutHandler); engine.rootContext()->setContextProperty("homescreenHandler", homescreenHandler); + engine.rootContext()->setContextProperty("launcher", launcher); engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); QObject *root = engine.rootObjects().first(); |