summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/SettingPage.qml4
-rw-r--r--app/app.pro2
-rw-r--r--app/example/Example.qml24
-rw-r--r--app/main.cpp23
4 files changed, 49 insertions, 4 deletions
diff --git a/app/SettingPage.qml b/app/SettingPage.qml
index 10aea21..ceed9f5 100644
--- a/app/SettingPage.qml
+++ b/app/SettingPage.qml
@@ -29,6 +29,10 @@ Page {
parent.pop()
}
+ function setStatusIcon(index, icon) {
+ dbus.setStatusIcon(index, icon)
+ }
+
Connections {
target: root
onCheckedChanged: {
diff --git a/app/app.pro b/app/app.pro
index b35e40e..fcfa050 100644
--- a/app/app.pro
+++ b/app/app.pro
@@ -1,5 +1,5 @@
TARGET = settings
-QT = quickcontrols2
+QT = quickcontrols2 dbus
SOURCES = main.cpp
diff --git a/app/example/Example.qml b/app/example/Example.qml
index 18e3efc..283b76b 100644
--- a/app/example/Example.qml
+++ b/app/example/Example.qml
@@ -32,14 +32,32 @@ SettingPage {
RowLayout {
spacing: 20
Button {
- text: 'Sushi'
+ text: 'Wifi'
highlighted: true
+ property int index: 0
+ property var icons: ['HMI_Status_Wifi_NoBars-01', 'HMI_Status_Wifi_1Bar-01', 'HMI_Status_Wifi_2Bars-01', 'HMI_Status_Wifi_3Bars-01', 'HMI_Status_Wifi_Full-01']
+ onClicked: {
+ index = (index + 1) % icons.length
+ setStatusIcon(0, 'qrc:/images/Status/%1.png'.arg(icons[index]))
+ }
}
Button {
- text: 'Sashimi'
+ text: 'Bluetooth'
+ property int index: 0
+ property var icons: ['HMI_Status_Bluetooth_Inactive-01', 'HMI_Status_Bluetooth_On-01']
+ onClicked: {
+ index = (index + 1) % icons.length
+ setStatusIcon(1, 'qrc:/images/Status/%1.png'.arg(icons[index]))
+ }
}
Button {
- text: 'Ramen'
+ text: 'Signal'
+ property int index: 0
+ property var icons: ['HMI_Status_Signal_NoBars-01', 'HMI_Status_Signal_1Bars-01', 'HMI_Status_Signal_2Bars-01', 'HMI_Status_Signal_3Bars-01', 'HMI_Status_Signal_4Bars-01', 'HMI_Status_Signal_Full-01']
+ onClicked: {
+ index = (index + 1) % icons.length
+ setStatusIcon(2, 'qrc:/images/Status/%1.png'.arg(icons[index]))
+ }
}
}
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"