From c70f97efea9b58490362692833104a6a5f23da89 Mon Sep 17 00:00:00 2001 From: Tasuku Suzuki Date: Tue, 20 Dec 2016 19:18:49 +0900 Subject: Add changing status icon in example to test this, you need to add a conf file under /etc/dbus-1/session.d/ Change-Id: I82c4b01db86ee54de87fad1db2ebf3f743b7c020 Signed-off-by: Tasuku Suzuki --- app/main.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'app/main.cpp') diff --git a/app/main.cpp b/app/main.cpp index ff3ca1e..9c01cac 100644 --- a/app/main.cpp +++ b/app/main.cpp @@ -17,6 +17,8 @@ #include #include #include +#include +#include #include #include #include @@ -26,6 +28,23 @@ #include #endif +class DBus : public QObject +{ + Q_OBJECT +public: + DBus(QObject *parent = nullptr) + : QObject(parent) + , interface("org.agl.homescreen", "/StatusBar", "org.agl.statusbar", QDBusConnection::sessionBus()) + {} + + Q_INVOKABLE void setStatusIcon(int index, const QString &url) { + interface.call("setStatusIcon", index, url); + } + +private: + QDBusInterface interface; +}; + int main(int argc, char *argv[]) { #ifdef HAVE_LIBHOMESCREEN @@ -69,8 +88,12 @@ int main(int argc, char *argv[]) QQmlContext *context = engine.rootContext(); context->setContextProperty(QStringLiteral("bindingAddress"), bindingAddress); } + + DBus dbus; + engine.rootContext()->setContextProperty("dbus", &dbus); engine.load(QUrl(QStringLiteral("qrc:/Settings.qml"))); return app.exec(); } +#include "main.moc" -- cgit 1.2.3-korg