diff options
| author | Javier <dev.git@javispedro.com> | 2014-12-03 00:48:19 +0100 |
|---|---|---|
| committer | Javier <dev.git@javispedro.com> | 2014-12-03 00:48:19 +0100 |
| commit | 69822e4dcf541a52e4202d5ff566364fb90e6ec0 (patch) | |
| tree | 5485db6e7d94517f2763db735ce4cfc2eec260cd /app | |
| parent | 843e8c2550f69de3b9dfc3ec5f13d2c3a5710896 (diff) | |
implement UI for JS app configuration
Diffstat (limited to 'app')
| -rw-r--r-- | app/app.pro | 2 | ||||
| -rw-r--r-- | app/pebbledinterface.cpp | 41 | ||||
| -rw-r--r-- | app/pebbledinterface.h | 7 | ||||
| -rw-r--r-- | app/qml/pages/AboutPage.qml | 2 | ||||
| -rw-r--r-- | app/qml/pages/AppConfigPage.qml (renamed from app/qml/pages/WebViewPage.qml) | 15 | ||||
| -rw-r--r-- | app/qml/pages/WatchPage.qml | 30 | ||||
| -rw-r--r-- | app/qml/pebble.qml | 5 |
7 files changed, 72 insertions, 30 deletions
diff --git a/app/app.pro b/app/app.pro index e0ff449..ddf2dba 100644 --- a/app/app.pro +++ b/app/app.pro @@ -25,4 +25,4 @@ OTHER_FILES += \ qml/images/* \ pebble.desktop \ pebble.png \ - qml/pages/WebViewPage.qml + qml/pages/AppConfigPage.qml diff --git a/app/pebbledinterface.cpp b/app/pebbledinterface.cpp index fb937f2..0aceaa0 100644 --- a/app/pebbledinterface.cpp +++ b/app/pebbledinterface.cpp @@ -3,7 +3,7 @@ static const QString PEBBLED_SYSTEMD_UNIT("pebbled.service"); static const QString PEBBLED_DBUS_SERVICE("org.pebbled"); -static const QString PEBBLED_DBUS_PATH("/org/pebbled/watch"); +static const QString PEBBLED_DBUS_PATH("/org/pebbled/Watch"); static const QString PEBBLED_DBUS_IFACE("org.pebbled.Watch"); PebbledInterface::PebbledInterface(QObject *parent) : @@ -22,6 +22,8 @@ PebbledInterface::PebbledInterface(QObject *parent) : this, &PebbledInterface::addressChanged); connect(watch, &OrgPebbledWatchInterface::ConnectedChanged, this, &PebbledInterface::connectedChanged); + connect(watch, &OrgPebbledWatchInterface::AppUuidChanged, + this, &PebbledInterface::appUuidChanged); // simulate connected change on active changed // as the daemon might not had a chance to send 'connectedChanged' @@ -67,7 +69,7 @@ void PebbledInterface::getUnitProperties() void PebbledInterface::onPropertiesChanged(QString interface, QMap<QString,QVariant> changed, QStringList invalidated) { - qDebug() << __FUNCTION__ << interface << changed << invalidated; + qDebug() << Q_FUNC_INFO << interface << changed << invalidated; if (interface != "org.freedesktop.systemd1.Unit") return; if (invalidated.contains("UnitFileState") || invalidated.contains("ActiveState")) getUnitProperties(); @@ -75,7 +77,7 @@ void PebbledInterface::onPropertiesChanged(QString interface, QMap<QString,QVari bool PebbledInterface::enabled() const { - qDebug() << __FUNCTION__; + qDebug() << Q_FUNC_INFO; return unitProperties["UnitFileState"].toString() == "enabled"; } @@ -95,7 +97,7 @@ void PebbledInterface::setEnabled(bool enabled) bool PebbledInterface::active() const { - qDebug() << __FUNCTION__; + qDebug() << Q_FUNC_INFO; return unitProperties["ActiveState"].toString() == "active"; } @@ -110,54 +112,61 @@ void PebbledInterface::setActive(bool active) bool PebbledInterface::connected() const { - qDebug() << __FUNCTION__; + qDebug() << Q_FUNC_INFO; return watch->connected(); } QString PebbledInterface::name() const { - qDebug() << __FUNCTION__; + qDebug() << Q_FUNC_INFO; return watch->name(); } QString PebbledInterface::address() const { - qDebug() << __FUNCTION__; + qDebug() << Q_FUNC_INFO; return watch->address(); } +QString PebbledInterface::appUuid() const +{ + qDebug() << Q_FUNC_INFO; + return watch->appUuid(); +} + void PebbledInterface::ping() { - qDebug() << __FUNCTION__; + qDebug() << Q_FUNC_INFO; watch->Ping(66); } void PebbledInterface::time() { - qDebug() << __FUNCTION__; + qDebug() << Q_FUNC_INFO; watch->SyncTime(); } void PebbledInterface::disconnect() { - qDebug() << __FUNCTION__; + qDebug() << Q_FUNC_INFO; watch->Disconnect(); } void PebbledInterface::reconnect() { - qDebug() << __FUNCTION__; + qDebug() << Q_FUNC_INFO; watch->Reconnect(); } -QUrl PebbledInterface::configureApp(const QUuid &uuid) +QUrl PebbledInterface::configureApp(const QString &uuid) { - qDebug() << __FUNCTION__ << uuid; - QString url = watch->StartAppConfiguration(uuid.toString()); + qDebug() << Q_FUNC_INFO << uuid; + QString url = watch->StartAppConfiguration(uuid); return QUrl(url); } -void PebbledInterface::setAppConfiguration(const QUuid &uuid, const QString &data) +void PebbledInterface::setAppConfiguration(const QString &uuid, const QString &data) { - watch->SendAppConfigurationData(uuid.toString(), data); + qDebug() << Q_FUNC_INFO << uuid << data; + watch->SendAppConfigurationData(uuid, data); } diff --git a/app/pebbledinterface.h b/app/pebbledinterface.h index 78724ad..f506e67 100644 --- a/app/pebbledinterface.h +++ b/app/pebbledinterface.h @@ -15,6 +15,7 @@ class PebbledInterface : public QObject Q_PROPERTY(bool connected READ connected NOTIFY connectedChanged) Q_PROPERTY(QString name READ name NOTIFY nameChanged) Q_PROPERTY(QString address READ address NOTIFY addressChanged) + Q_PROPERTY(QString appUuid READ appUuid NOTIFY appUuidChanged) public: explicit PebbledInterface(QObject *parent = 0); @@ -24,6 +25,7 @@ public: bool connected() const; QString name() const; QString address() const; + QString appUuid() const; signals: void enabledChanged(); @@ -31,6 +33,7 @@ signals: void connectedChanged(); void nameChanged(); void addressChanged(); + void appUuidChanged(); public slots: void setEnabled(bool); @@ -40,8 +43,8 @@ public slots: void disconnect(); void reconnect(); - QUrl configureApp(const QUuid &uuid); - void setAppConfiguration(const QUuid &uuid, const QString &data); + QUrl configureApp(const QString &uuid); + void setAppConfiguration(const QString &uuid, const QString &data); private slots: void getUnitProperties(); diff --git a/app/qml/pages/AboutPage.qml b/app/qml/pages/AboutPage.qml index bec1031..8fd009e 100644 --- a/app/qml/pages/AboutPage.qml +++ b/app/qml/pages/AboutPage.qml @@ -40,7 +40,7 @@ Page { anchors { left: parent.left right: parent.right - margins: Theme.paddingSmall + margins: Theme.paddingMedium } font.pixelSize: Theme.fontSizeTiny horizontalAlignment: Text.AlignJustify diff --git a/app/qml/pages/WebViewPage.qml b/app/qml/pages/AppConfigPage.qml index 2c6fcf0..8fb31ca 100644 --- a/app/qml/pages/WebViewPage.qml +++ b/app/qml/pages/AppConfigPage.qml @@ -4,21 +4,26 @@ import QtWebKit 3.0 import Sailfish.Silica 1.0 Page { - id: webviewPage + id: appConfigPage property alias url: webview.url + property string uuid SilicaWebView { id: webview anchors.fill: parent + header: PageHeader { + title: "Configuring " + uuid + } + onNavigationRequested: { - console.log("navigation requested to " + request.url); - var url = request.url.toString() + console.log("appconfig navigation requested to " + request.url); + var url = request.url.toString(); if (/^pebblejs:\/\/close/.exec(url)) { var data = decodeURI(url.substring(17)); - console.log("match with pebble close regexp. data: " + data); - pebbled.webviewClosed(data); + console.log("appconfig requesting close; data: " + data); + pebbled.setAppConfiguration(uuid, data); pageStack.pop(); request.action = WebView.IgnoreRequest; } else { diff --git a/app/qml/pages/WatchPage.qml b/app/qml/pages/WatchPage.qml index 90e5ec9..8169507 100644 --- a/app/qml/pages/WatchPage.qml +++ b/app/qml/pages/WatchPage.qml @@ -77,6 +77,36 @@ Page { } } + + Label { + text: qsTr("App configuration") + font.family: Theme.fontFamilyHeading + color: Theme.highlightColor + anchors.right: parent.right + anchors.rightMargin: Theme.paddingMedium + } + + Button { + text: "Configure current app" + anchors { + left: parent.left + right: parent.right + margins: Theme.paddingLarge + } + onClicked: { + var uuid = pebbled.appUuid; + console.log("going to configureApp " + uuid); + var url = pebbled.configureApp(uuid); + console.log("obtained configure URL " + url); + if (url) { + pageStack.push(Qt.resolvedUrl("AppConfigPage.qml"), { + url: url, + uuid: uuid + }); + } + } + } + } } } diff --git a/app/qml/pebble.qml b/app/qml/pebble.qml index 2ff0839..da3bfb5 100644 --- a/app/qml/pebble.qml +++ b/app/qml/pebble.qml @@ -41,10 +41,5 @@ ApplicationWindow PebbledInterface { id: pebbled - - onOpenUrl: { - console.log("got open url: " + url); - pageStack.push(Qt.resolvedUrl("pages/WebViewPage.qml"), {url: url}); - } } } |
