summaryrefslogtreecommitdiffstats
path: root/app/main.cpp
diff options
context:
space:
mode:
authorTasuku Suzuki <tasuku.suzuki@qt.io>2016-12-20 19:18:49 +0900
committerTasuku Suzuki <tasuku.suzuki@qt.io>2016-12-20 19:22:58 +0900
commitc70f97efea9b58490362692833104a6a5f23da89 (patch)
treeca43bb1d61fb2fdf16e6e814dd32870cb1f5bf7c /app/main.cpp
parent2f77037147a7609418c570c28ed02f0c1d31733f (diff)
Add changing status icon in example
to test this, you need to add a conf file under /etc/dbus-1/session.d/ <?xml version="1.0"?> <!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd"> <busconfig> <policy context="default"> <allow send_destination="org.agl.homescreen"/> </policy> </busconfig> Change-Id: I82c4b01db86ee54de87fad1db2ebf3f743b7c020 Signed-off-by: Tasuku Suzuki <tasuku.suzuki@qt.io>
Diffstat (limited to 'app/main.cpp')
-rw-r--r--app/main.cpp23
1 files changed, 23 insertions, 0 deletions
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 <QtCore/QDebug>
#include <QtCore/QCommandLineParser>
#include <QtCore/QUrlQuery>
+#include <QtDBus/QDBusInterface>
+#include <QtDBus/QDBusReply>
#include <QtGui/QGuiApplication>
#include <QtQml/QQmlApplicationEngine>
#include <QtQml/QQmlContext>
@@ -26,6 +28,23 @@
#include <libhomescreen.hpp>
#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"