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 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 72 insertions(+), 10 deletions(-) (limited to 'app/qml') 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 : "" + } + } } } } -- cgit v1.2.3