From 3f64297af4e7a070b4f62ebf3f17105ee6b0a3a8 Mon Sep 17 00:00:00 2001 From: Tomasz Sterna Date: Thu, 30 Apr 2015 16:33:09 +0200 Subject: Implemented profile changes on watch (dis)connection --- app/qml/pages/ManagerPage.qml | 82 +++++++++++++++++++++++---- app/translations/pebble-es.ts | 125 +++++++++++++++++++++++------------------ app/translations/pebble-pl.ts | 126 +++++++++++++++++++++++++++--------------- app/translations/pebble.ts | 117 +++++++++++++++++++++------------------ daemon/manager.cpp | 36 +----------- daemon/manager.h | 3 - daemon/settings.h | 9 ++- rpm/pebble.spec | 1 + rpm/pebble.yaml | 1 + 9 files changed, 295 insertions(+), 205 deletions(-) diff --git a/app/qml/pages/ManagerPage.qml b/app/qml/pages/ManagerPage.qml index 7fb7369..b989c64 100644 --- a/app/qml/pages/ManagerPage.qml +++ b/app/qml/pages/ManagerPage.qml @@ -2,6 +2,7 @@ import QtQuick 2.0 import QtQml 2.1 import Sailfish.Silica 1.0 import org.nemomobile.configuration 1.0 +import org.nemomobile.dbus 2.0 Page { id: page @@ -9,7 +10,8 @@ Page { ConfigurationGroup { id: settings path: "/org/pebbled/settings" - property bool silentWhenConnected: false + property string profileWhenConnected: "" + property string profileWhenDisconnected: "" property bool transliterateMessage: false property bool useSystemVolume: true property bool incomingCallNotification: true @@ -23,6 +25,25 @@ Page { property bool notificationsAll: false } + DBusInterface { + id: profiled + + service: 'com.nokia.profiled' + iface: 'com.nokia.profiled' + path: '/com/nokia/profiled' + + property var profiles + } + + Component.onCompleted: { + profiled.typedCall('get_profiles', [], function (result) { + console.log('Got profiles: ' + result); + profiled.profiles = result; + }); + } + + + SilicaFlickable { id: flickable anchors.fill: parent @@ -124,15 +145,6 @@ Page { settings.incomingCallNotification = !settings.incomingCallNotification; } } - TextSwitch { - text: qsTr("Silent when connected") - description: qsTr("Sets phone profile to \"silent\" when Pebble is connected") - checked: settings.silentWhenConnected - automaticCheck: false - onClicked: { - settings.silentWhenConnected = !settings.silentWhenConnected; - } - } TextSwitch { text: qsTr("Control main volume") description: qsTr("Pebble music volume buttons change the main phone volume directly instead of through the music player.") @@ -234,6 +246,56 @@ Page { settings.notificationsAll = !settings.notificationsAll; } } + + Label { + text: qsTr("Profiles") + font.family: Theme.fontFamilyHeading + color: Theme.highlightColor + anchors.right: parent.right + anchors.rightMargin: Theme.paddingMedium + } + + ComboBox { + label: qsTr("Connected") + menu: ContextMenu { + MenuItem { + text: qsTr("no change") + font.capitalization: Font.SmallCaps + } + Repeater { + model: profiled.profiles + delegate: MenuItem { + text: modelData + down: modelData === settings.profileWhenConnected + } + } + } + value: settings.profileWhenConnected || qsTr("no change") + onCurrentIndexChanged: { + settings.profileWhenConnected = currentIndex ? currentItem.text : "" + } + } + + ComboBox { + label: qsTr("Disconnected") + menu: ContextMenu { + MenuItem { + text: qsTr("no change") + font.capitalization: Font.SmallCaps + } + Repeater { + model: profiled.profiles + delegate: MenuItem { + text: modelData + down: modelData === settings.profileWhenDisconnected + } + } + } + value: settings.profileWhenDisconnected || qsTr("no change") + onCurrentIndexChanged: { + settings.profileWhenDisconnected = currentIndex ? currentItem.text : "" + } + } } } } diff --git a/app/translations/pebble-es.ts b/app/translations/pebble-es.ts index fa2c566..bbe2e61 100644 --- a/app/translations/pebble-es.ts +++ b/app/translations/pebble-es.ts @@ -65,32 +65,47 @@ AppStorePage - + Logout - + + Logging out... + + + + + Hide search + + + + + Show search + + + + Pebble Appstore - - WatchApps + + Apps - - WatchFaces + + Faces - + Downloading... - + Downloading %1... @@ -149,19 +164,6 @@ ¿Errores? - - FirmwareUpgrade - - - Firmware upgrade - - - - - Begin upgrade - - - InstallAppDialog @@ -192,164 +194,177 @@ ManagerPage - + Pebble Appstore - + About Acerca de - + Pebble Manager - + Waiting for watch... If it can't be found please check it's available and paired in Bluetooth settings. Buscando el reloj Si esto tarda mucho, comprueba que el reloj esté emparejado correctamente. - + Service Servicio - + Enabled Habilitado - + Automatic startup Inicio automático - + Manual startup Inicio manual - + Active Activo - + Running Ejecutándose - + Dead Detenido - + Connection Conexión - + + Connected Conectado - + + Disconnected Desconectado - + Settings Configuración - + Forward phone calls Transferir llamadas - + + Profiles + + + + + + + + no change + + + Silent when connected - Modo silencio automático + Modo silencio automático - Sets phone profile to "silent" when Pebble is connected - Activa el modo silencio cuando se conecte un Pebble + Activa el modo silencio cuando se conecte un Pebble - + Control main volume - + Pebble music volume buttons change the main phone volume directly instead of through the music player. - + Transliterate messages Transliterar mensajes - + Messages are transliterated to ASCII before sending to Pebble Codifica los mensajes entrates a ASCII antes de enviarlos a Pebble - + Notifications Notificaciones - + Messaging Mensajería - + SMS and IM SMS y chat - + Missed call Llamadas perdidas - + Emails Correos electrónicos - + Mitakuuluu - + Twitter Twitter - + Facebook Facebook - + Other notifications Resto de notificaciones - + All notifications Todas las notificaciones diff --git a/app/translations/pebble-pl.ts b/app/translations/pebble-pl.ts index 407c5e9..7163310 100644 --- a/app/translations/pebble-pl.ts +++ b/app/translations/pebble-pl.ts @@ -65,32 +65,55 @@ AppStorePage - + Logout Wyloguj - + + Logging out... + + + + + Hide search + + + + + Show search + + + + Pebble Appstore Pebble Appstore - + + Apps + + + + + Faces + + + WatchApps - Aplikacje + Aplikacje - WatchFaces - Cyferblaty + Cyferblaty - + Downloading... Pobieranie... - + Downloading %1... Pobieranie %1... @@ -176,14 +199,12 @@ FirmwareUpgrade - Firmware upgrade - Aktualizacja firmware + Aktualizacja firmware - Begin upgrade - Rozpocznij aktualizację + Rozpocznij aktualizację @@ -212,164 +233,177 @@ ManagerPage - + Pebble Appstore Pebble Appstore - + About Informacje - + Pebble Manager Pebble Manager - + Waiting for watch... If it can't be found please check it's available and paired in Bluetooth settings. Oczekiwanie na zegarek... Jeśli nie zostaje znaleziony sprawdź czy jest w zasięgu i czy jest sparowany w ustawieniach Bluetooth. - + Service Usługa - + Enabled Włączona - + Automatic startup Start automatyczny - + Manual startup Start ręczny - + Active Aktywna - + Running Pracuje - + Dead Martwa - + Connection Połączenie - + + Connected Połączony - + + Disconnected Rozłączony - + Settings Ustawienia - + Forward phone calls Przekazuj telefony - + + Profiles + + + + + + + + no change + + + Silent when connected - Cichy gdy połączony + Cichy gdy połączony - Sets phone profile to "silent" when Pebble is connected - Ustawia "cichy" profil telefonu gdy Pebble jest połączony + Ustawia "cichy" profil telefonu gdy Pebble jest połączony - + Control main volume Steruj głośnością główną - + Pebble music volume buttons change the main phone volume directly instead of through the music player. Guziki zmiany głośności na Pebble będą zmieniać głośność bezpośrednio, a nie za pomocą odtwarzacza muzyki. - + Transliterate messages Transliteracja wiadomości - + Messages are transliterated to ASCII before sending to Pebble Wiadomości są transliterowane do ASCII przed wysłaniem do Pebble - + Notifications Powiadomienia - + Messaging Wiadomości - + SMS and IM SMS i IM - + Missed call Ominięte telefony - + Emails Emaile - + Mitakuuluu Mitakuuluu - + Twitter Twitter - + Facebook Facebook - + Other notifications Pozostałe powiadomienia - + All notifications Wszystkie powiadomienia diff --git a/app/translations/pebble.ts b/app/translations/pebble.ts index f1679e1..755956e 100644 --- a/app/translations/pebble.ts +++ b/app/translations/pebble.ts @@ -65,32 +65,47 @@ AppStorePage - + Logout - + + Logging out... + + + + + Hide search + + + + + Show search + + + + Pebble Appstore - - WatchApps + + Apps - - WatchFaces + + Faces - + Downloading... - + Downloading %1... @@ -141,19 +156,6 @@ - - FirmwareUpgrade - - - Firmware upgrade - - - - - Begin upgrade - - - InstallAppDialog @@ -180,163 +182,168 @@ ManagerPage - + Pebble Appstore - + About - + Pebble Manager - + Waiting for watch... If it can't be found please check it's available and paired in Bluetooth settings. - + Service - + Enabled - + Automatic startup - + Manual startup - + Active - + Running - + Dead - + Connection - + + Connected - + + Disconnected - + Settings - + Forward phone calls - - Silent when connected + + Profiles - - Sets phone profile to "silent" when Pebble is connected + + + + + no change - + Control main volume - + Pebble music volume buttons change the main phone volume directly instead of through the music player. - + Transliterate messages - + Messages are transliterated to ASCII before sending to Pebble - + Notifications - + Messaging - + SMS and IM - + Missed call - + Emails - + Mitakuuluu - + Twitter - + Facebook - + Other notifications - + All notifications diff --git a/daemon/manager.cpp b/daemon/manager.cpp index 567316e..262fb4b 100644 --- a/daemon/manager.cpp +++ b/daemon/manager.cpp @@ -24,7 +24,6 @@ Manager::Manager(Settings *settings, QObject *parent) : { connect(settings, SIGNAL(valueChanged(QString)), SLOT(onSettingChanged(const QString&))); connect(settings, SIGNAL(valuesChanged()), SLOT(onSettingsChanged())); - //connect(settings, SIGNAL(silentWhenConnectedChanged(bool)), SLOT(onSilentWhenConnectedChanged(bool))); // We don't need to handle presence changes, so report them separately and ignore them QMap parameters; @@ -75,8 +74,6 @@ Manager::Manager(Settings *settings, QObject *parent) : connect(bank, &BankManager::slotsChanged, proxy, &PebbledProxy::AppSlotsChanged); connect(apps, &AppManager::appsChanged, proxy, &PebbledProxy::AllAppsChanged); - QString currentProfile = getCurrentProfile(); - defaultProfile = currentProfile.isEmpty() ? "ambience" : currentProfile; connect(watch, SIGNAL(connectedChanged()), SLOT(applyProfile())); // Set BT icon for notification @@ -259,38 +256,11 @@ void Manager::onEmailNotify(const QString &sender, const QString &data,const QSt watch->sendEmailNotification(sender, data, subject); } -QString Manager::getCurrentProfile() const -{ - QDBusReply profile = QDBusConnection::sessionBus().call( - QDBusMessage::createMethodCall("com.nokia.profiled", "/com/nokia/profiled", "com.nokia.profiled", "get_profile")); - if (profile.isValid()) { - QString currentProfile = profile.value(); - qCDebug(l) << "Got profile" << currentProfile; - return currentProfile; - } - - qCCritical(l) << profile.error().message(); - return QString(); -} - void Manager::applyProfile() { - QString currentProfile = getCurrentProfile(); - QString newProfile; - - if (settings->property("silentWhenConnected").toBool()) { - if (watch->isConnected() && currentProfile != "silent") { - newProfile = "silent"; - defaultProfile = currentProfile; - } - if (!watch->isConnected() && currentProfile == "silent" && defaultProfile != "silent") { - newProfile = defaultProfile; - } - } - else if (currentProfile != defaultProfile) { - newProfile = defaultProfile; - } - + QString newProfile = settings->property( + watch->isConnected() ? "profileWhenConnected" + : "profileWhenDisconnected").toString(); if (!newProfile.isEmpty()) { QDBusReply res = QDBusConnection::sessionBus().call( QDBusMessage::createMethodCall("com.nokia.profiled", "/com/nokia/profiled", "com.nokia.profiled", "set_profile") diff --git a/daemon/manager.h b/daemon/manager.h index de01dbb..2079de0 100644 --- a/daemon/manager.h +++ b/daemon/manager.h @@ -58,8 +58,6 @@ class Manager : public QObject, protected QDBusContext QContactManager *contacts; QContactDetailFilter numberFilter; - QString defaultProfile; - QUuid currentAppUuid; QScopedPointer transliterator; @@ -69,7 +67,6 @@ public: ~Manager(); QString findPersonByNumber(QString number); - QString getCurrentProfile() const; bool uploadFirmware(bool recovery, const QString &file); diff --git a/daemon/settings.h b/daemon/settings.h index 688b211..3c38473 100644 --- a/daemon/settings.h +++ b/daemon/settings.h @@ -7,7 +7,8 @@ class Settings : public MDConfGroup { Q_OBJECT - Q_PROPERTY(bool silentWhenConnected MEMBER silentWhenConnected NOTIFY silentWhenConnectedChanged) + Q_PROPERTY(QString profileWhenConnected MEMBER profileWhenConnected NOTIFY profileWhenConnectedChanged) + Q_PROPERTY(QString profileWhenDisconnected MEMBER profileWhenDisconnected NOTIFY profileWhenDisconnectedChanged) Q_PROPERTY(bool transliterateMessage MEMBER transliterateMessage NOTIFY transliterateMessageChanged) Q_PROPERTY(bool useSystemVolume MEMBER useSystemVolume NOTIFY useSystemVolumeChanged) Q_PROPERTY(bool incomingCallNotification MEMBER incomingCallNotification NOTIFY incomingCallNotificationChanged) @@ -21,7 +22,8 @@ class Settings : public MDConfGroup Q_PROPERTY(bool notificationsAll MEMBER notificationsAll NOTIFY notificationsAllChanged) Q_PROPERTY(QString accountToken MEMBER accountToken NOTIFY accountTokenChanged) - bool silentWhenConnected; + QString profileWhenConnected; + QString profileWhenDisconnected; bool transliterateMessage; bool useSystemVolume; bool incomingCallNotification; @@ -41,7 +43,8 @@ public: { resolveMetaObject(); } signals: - void silentWhenConnectedChanged(); + void profileWhenConnectedChanged(); + void profileWhenDisconnectedChanged(); void transliterateMessageChanged(); void useSystemVolumeChanged(); void incomingCallNotificationChanged(); diff --git a/rpm/pebble.spec b/rpm/pebble.spec index 4e99c28..790e11d 100644 --- a/rpm/pebble.spec +++ b/rpm/pebble.spec @@ -22,6 +22,7 @@ Source0: %{name}-%{version}.tar.xz Source100: pebble.yaml Requires: sailfishsilica-qt5 >= 0.10.9 Requires: systemd-user-session-targets +Requires: nemo-qml-plugin-dbus-qt5 BuildRequires: pkgconfig(Qt5DBus) BuildRequires: pkgconfig(Qt5Bluetooth) BuildRequires: pkgconfig(Qt5Contacts) diff --git a/rpm/pebble.yaml b/rpm/pebble.yaml index 60e02e6..8184281 100644 --- a/rpm/pebble.yaml +++ b/rpm/pebble.yaml @@ -27,6 +27,7 @@ PkgConfigBR: Requires: - sailfishsilica-qt5 >= 0.10.9 - systemd-user-session-targets +- nemo-qml-plugin-dbus-qt5 Files: - '%{_bindir}' - '%{_datadir}/%{name}/qml' -- cgit v1.2.3