From 5481f054ccd53d401bcc6763c01d5e217663b2b4 Mon Sep 17 00:00:00 2001 From: Tomasz Sterna Date: Tue, 31 Mar 2015 15:51:45 +0200 Subject: Implemented Watch Info page --- app/app.pro | 3 +- app/pebble.desktop | 2 +- app/pebbledinterface.cpp | 23 ++++++++++++- app/qml/pages/WatchInfo.qml | 80 +++++++++++++++++++++++++++++++++++++++++++ app/qml/pages/WatchPage.qml | 18 +++++----- app/translations/pebble-es.ts | 49 +++++++++++++++++++++----- app/translations/pebble.ts | 49 +++++++++++++++++++++----- daemon/manager.h | 3 +- 8 files changed, 199 insertions(+), 28 deletions(-) create mode 100644 app/qml/pages/WatchInfo.qml diff --git a/app/app.pro b/app/app.pro index 9600919..dc6240c 100644 --- a/app/app.pro +++ b/app/app.pro @@ -33,7 +33,8 @@ OTHER_FILES += \ translations/*.ts \ pebble.desktop \ pebble.png \ - qml/pages/AppStorePage.qml + qml/pages/AppStorePage.qml \ + qml/pages/WatchInfo.qml CONFIG += sailfishapp_i18n TRANSLATIONS += translations/pebble-es.ts diff --git a/app/pebble.desktop b/app/pebble.desktop index d3837b7..c7dd6c3 100644 --- a/app/pebble.desktop +++ b/app/pebble.desktop @@ -4,4 +4,4 @@ X-Nemo-Application-Type=silica-qt5 Name=Pebble Icon=pebble Exec=pebble %U -MimeType=application/zip +MimeType=application/zip; diff --git a/app/pebbledinterface.cpp b/app/pebbledinterface.cpp index 9338f7f..e7fcb2e 100644 --- a/app/pebbledinterface.cpp +++ b/app/pebbledinterface.cpp @@ -1,6 +1,8 @@ #include "pebbledinterface.h" #include "watch_interface.h" +#include + 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"); @@ -145,7 +147,26 @@ QString PebbledInterface::address() const QVariantMap PebbledInterface::info() const { qDebug() << Q_FUNC_INFO; - return watch->info(); + QVariantMap info = watch->info(); + QVariantList firmwares; + foreach (const QVariant &var, info.values("firmware")) { + const QDBusArgument &arg = var.value(); + arg.beginMap(); + QVariantMap map; + while (!arg.atEnd()) { + QString key; + QVariant value; + arg.beginMapEntry(); + arg >> key >> value; + arg.endMapEntry(); + map.insert(key, value); + } + arg.endMap(); + firmwares << map; + } + info.remove("firmware"); + info.insert("firmware", firmwares); + return info; } QString PebbledInterface::appUuid() const diff --git a/app/qml/pages/WatchInfo.qml b/app/qml/pages/WatchInfo.qml new file mode 100644 index 0000000..9ae1135 --- /dev/null +++ b/app/qml/pages/WatchInfo.qml @@ -0,0 +1,80 @@ +import QtQuick 2.0 +import QtQml 2.1 +import Sailfish.Silica 1.0 + +Page { + id: watchInfoPage + + property string firmwareVersion + property string recoveryVersion + + Component.onCompleted: { + pebbled.info.firmware.forEach(function(firmware){ + if (firmware.recovery) { + recoveryVersion = firmware.version + } else { + firmwareVersion = firmware.version + } + }) + } + + Column { + id: column + width: watchInfoPage.width + spacing: Theme.paddingMedium + + PageHeader { + title: pebbled.name + } + + Grid { + columns: 2 + spacing: Theme.paddingMedium + anchors { + left: parent.left + right: parent.right + margins: Theme.paddingLarge + } + + Label { + color: Theme.highlightColor + text: qsTr("Address") + } + Label { + text: pebbled.info.address + } + + Label { + color: Theme.highlightColor + text: qsTr("Serial Number") + } + Label { + text: pebbled.info.serial + } + + Label { + color: Theme.highlightColor + text: qsTr("BootLoader") + } + Label { + text: new Date(pebbled.info.bootloader * 1000).toLocaleString(Qt.locale(), Locale.ShortFormat) + } + + Label { + color: Theme.highlightColor + text: qsTr("Firmware") + } + Label { + text: firmwareVersion + } + + Label { + color: Theme.highlightColor + text: qsTr("Recovery") + } + Label { + text: recoveryVersion + } + } + } +} diff --git a/app/qml/pages/WatchPage.qml b/app/qml/pages/WatchPage.qml index b36280f..7d4375c 100644 --- a/app/qml/pages/WatchPage.qml +++ b/app/qml/pages/WatchPage.qml @@ -59,20 +59,22 @@ Page { } + Button { + text: qsTr("Info") + width: parent.width / 3 + onClicked: pageStack.push(Qt.resolvedUrl("WatchInfo.qml")) + } + Button { text: qsTr("Ping") - width: parent.width / 2 - onClicked: { - pebbled.ping(66) - } + width: parent.width / 3 + onClicked: pebbled.ping(66) } Button { text: qsTr("Sync Time") - width: parent.width / 2 - onClicked: { - pebbled.time() - } + width: parent.width / 3 + onClicked: pebbled.time() } } diff --git a/app/translations/pebble-es.ts b/app/translations/pebble-es.ts index 1591a4d..53f6d13 100644 --- a/app/translations/pebble-es.ts +++ b/app/translations/pebble-es.ts @@ -255,50 +255,83 @@ Si esto tarda mucho, comprueba que el reloj esté emparejado correctamente.Todas las notificaciones + + WatchInfo + + + Address + + + + + Serial Number + + + + + BootLoader + + + + + Firmware + + + + + Recovery + + + WatchPage + Info + + + + Ping Ping - + Sync Time Ajustar hora - + Installed applications Aplicaciones instaladas - + Uninstalling Desinstalando - + (empty slot) (hueco libre) - + (slot in use by unknown app) (hueco en uso) - + Install app... Instalar app... - + Configure... Configurar... - + Uninstall Desinstalar diff --git a/app/translations/pebble.ts b/app/translations/pebble.ts index f49cac1..66a914d 100644 --- a/app/translations/pebble.ts +++ b/app/translations/pebble.ts @@ -250,50 +250,83 @@ If it can't be found please check it's available and paired in Bluetoo + + WatchInfo + + + Address + + + + + Serial Number + + + + + BootLoader + + + + + Firmware + + + + + Recovery + + + WatchPage + Info + + + + Ping - + Sync Time - + Installed applications - + Uninstalling - + (empty slot) - + (slot in use by unknown app) - + Install app... - + Configure... - + Uninstall diff --git a/daemon/manager.h b/daemon/manager.h index 9825339..a5e05ad 100644 --- a/daemon/manager.h +++ b/daemon/manager.h @@ -122,7 +122,8 @@ public: inline QString Name() const { return pebble()["Name"].toString(); } inline QString Address() const { return pebble()["Address"].toString(); } - inline QVariantMap Info() const { return manager()->watch->versions().toMap(); } + inline QVariantMap Info() const { return manager()->watch->versions().serialNumber.isEmpty() + ? QVariantMap() : manager()->watch->versions().toMap(); } inline bool Connected() const { return manager()->watch->isConnected(); } inline QString AppUuid() const { return manager()->currentAppUuid.toString(); } -- cgit v1.2.3