diff options
| author | Tomasz Sterna <tomek@xiaoka.com> | 2015-03-31 15:51:45 +0200 |
|---|---|---|
| committer | Tomasz Sterna <tomek@xiaoka.com> | 2015-03-31 16:37:37 +0200 |
| commit | 5481f054ccd53d401bcc6763c01d5e217663b2b4 (patch) | |
| tree | c814847fa6f9a5d4f5f3e675a8aafcea9820dd78 | |
| parent | c01b9da9f441d74578792ffeca2db25734b19704 (diff) | |
Implemented Watch Info page
| -rw-r--r-- | app/app.pro | 3 | ||||
| -rw-r--r-- | app/pebble.desktop | 2 | ||||
| -rw-r--r-- | app/pebbledinterface.cpp | 23 | ||||
| -rw-r--r-- | app/qml/pages/WatchInfo.qml | 80 | ||||
| -rw-r--r-- | app/qml/pages/WatchPage.qml | 18 | ||||
| -rw-r--r-- | app/translations/pebble-es.ts | 49 | ||||
| -rw-r--r-- | app/translations/pebble.ts | 49 | ||||
| -rw-r--r-- | daemon/manager.h | 3 |
8 files changed, 199 insertions, 28 deletions
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 <QDBusArgument> + 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<QDBusArgument>(); + 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 @@ -60,19 +60,21 @@ 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 @@ -256,49 +256,82 @@ Si esto tarda mucho, comprueba que el reloj esté emparejado correctamente.</tra </message> </context> <context> + <name>WatchInfo</name> + <message> + <location filename="../qml/pages/WatchInfo.qml" line="41"/> + <source>Address</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="../qml/pages/WatchInfo.qml" line="49"/> + <source>Serial Number</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="../qml/pages/WatchInfo.qml" line="57"/> + <source>BootLoader</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="../qml/pages/WatchInfo.qml" line="65"/> + <source>Firmware</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="../qml/pages/WatchInfo.qml" line="73"/> + <source>Recovery</source> + <translation type="unfinished"></translation> + </message> +</context> +<context> <name>WatchPage</name> <message> <location filename="../qml/pages/WatchPage.qml" line="63"/> + <source>Info</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="../qml/pages/WatchPage.qml" line="69"/> <source>Ping</source> <translation>Ping</translation> </message> <message> - <location filename="../qml/pages/WatchPage.qml" line="71"/> + <location filename="../qml/pages/WatchPage.qml" line="75"/> <source>Sync Time</source> <translation>Ajustar hora</translation> </message> <message> - <location filename="../qml/pages/WatchPage.qml" line="85"/> + <location filename="../qml/pages/WatchPage.qml" line="87"/> <source>Installed applications</source> <translation>Aplicaciones instaladas</translation> </message> <message> - <location filename="../qml/pages/WatchPage.qml" line="121"/> + <location filename="../qml/pages/WatchPage.qml" line="123"/> <source>Uninstalling</source> <translation>Desinstalando</translation> </message> <message> - <location filename="../qml/pages/WatchPage.qml" line="193"/> + <location filename="../qml/pages/WatchPage.qml" line="195"/> <source>(empty slot)</source> <translation>(hueco libre)</translation> </message> <message> - <location filename="../qml/pages/WatchPage.qml" line="193"/> + <location filename="../qml/pages/WatchPage.qml" line="195"/> <source>(slot in use by unknown app)</source> <translation>(hueco en uso)</translation> </message> <message> - <location filename="../qml/pages/WatchPage.qml" line="202"/> + <location filename="../qml/pages/WatchPage.qml" line="204"/> <source>Install app...</source> <translation>Instalar app...</translation> </message> <message> - <location filename="../qml/pages/WatchPage.qml" line="207"/> + <location filename="../qml/pages/WatchPage.qml" line="209"/> <source>Configure...</source> <translation>Configurar...</translation> </message> <message> - <location filename="../qml/pages/WatchPage.qml" line="212"/> + <location filename="../qml/pages/WatchPage.qml" line="214"/> <source>Uninstall</source> <translation>Desinstalar</translation> </message> 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 @@ -251,49 +251,82 @@ If it can't be found please check it's available and paired in Bluetoo </message> </context> <context> + <name>WatchInfo</name> + <message> + <location filename="../qml/pages/WatchInfo.qml" line="41"/> + <source>Address</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="../qml/pages/WatchInfo.qml" line="49"/> + <source>Serial Number</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="../qml/pages/WatchInfo.qml" line="57"/> + <source>BootLoader</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="../qml/pages/WatchInfo.qml" line="65"/> + <source>Firmware</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="../qml/pages/WatchInfo.qml" line="73"/> + <source>Recovery</source> + <translation type="unfinished"></translation> + </message> +</context> +<context> <name>WatchPage</name> <message> <location filename="../qml/pages/WatchPage.qml" line="63"/> + <source>Info</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="../qml/pages/WatchPage.qml" line="69"/> <source>Ping</source> <translation type="unfinished"></translation> </message> <message> - <location filename="../qml/pages/WatchPage.qml" line="71"/> + <location filename="../qml/pages/WatchPage.qml" line="75"/> <source>Sync Time</source> <translation type="unfinished"></translation> </message> <message> - <location filename="../qml/pages/WatchPage.qml" line="85"/> + <location filename="../qml/pages/WatchPage.qml" line="87"/> <source>Installed applications</source> <translation type="unfinished"></translation> </message> <message> - <location filename="../qml/pages/WatchPage.qml" line="121"/> + <location filename="../qml/pages/WatchPage.qml" line="123"/> <source>Uninstalling</source> <translation type="unfinished"></translation> </message> <message> - <location filename="../qml/pages/WatchPage.qml" line="193"/> + <location filename="../qml/pages/WatchPage.qml" line="195"/> <source>(empty slot)</source> <translation type="unfinished"></translation> </message> <message> - <location filename="../qml/pages/WatchPage.qml" line="193"/> + <location filename="../qml/pages/WatchPage.qml" line="195"/> <source>(slot in use by unknown app)</source> <translation type="unfinished"></translation> </message> <message> - <location filename="../qml/pages/WatchPage.qml" line="202"/> + <location filename="../qml/pages/WatchPage.qml" line="204"/> <source>Install app...</source> <translation type="unfinished"></translation> </message> <message> - <location filename="../qml/pages/WatchPage.qml" line="207"/> + <location filename="../qml/pages/WatchPage.qml" line="209"/> <source>Configure...</source> <translation type="unfinished"></translation> </message> <message> - <location filename="../qml/pages/WatchPage.qml" line="212"/> + <location filename="../qml/pages/WatchPage.qml" line="214"/> <source>Uninstall</source> <translation type="unfinished"></translation> </message> 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(); } |
