diff options
author | jan Iversen <jani@apache.org> | 2018-06-13 18:06:11 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2018-06-15 14:12:14 -0700 |
commit | b8eb348f546291c49e2d606649b3c85d23e43782 (patch) | |
tree | 8ca54d1f5aa363496de4b83e1b6200b92304a8a3 /mobile-widgets/qml | |
parent | 62ca5e90e13d65235d3cd53feffd0cb62cfbac43 (diff) | |
download | subsurface-b8eb348f546291c49e2d606649b3c85d23e43782.tar.gz |
mobile: move settings from qmlmanager to qmlprefs
add settings variables/functions to qmlprefs
remove settings variables/functions from qmlmanager
change manager. to prefs. in qml files for setting variables/functions
Signed-off-by: Jan Iversen <jani@apache.org>
Diffstat (limited to 'mobile-widgets/qml')
-rw-r--r-- | mobile-widgets/qml/CloudCredentials.qml | 12 | ||||
-rw-r--r-- | mobile-widgets/qml/DiveList.qml | 17 | ||||
-rw-r--r-- | mobile-widgets/qml/Settings.qml | 33 | ||||
-rw-r--r-- | mobile-widgets/qml/main.qml | 30 |
4 files changed, 49 insertions, 43 deletions
diff --git a/mobile-widgets/qml/CloudCredentials.qml b/mobile-widgets/qml/CloudCredentials.qml index 52a7162ce..b32323d05 100644 --- a/mobile-widgets/qml/CloudCredentials.qml +++ b/mobile-widgets/qml/CloudCredentials.qml @@ -15,9 +15,9 @@ Item { property string password: password.text; function saveCredentials() { - manager.cloudUserName = login.text - manager.cloudPassword = password.text - manager.cloudPin = pin.text + prefs.cloudUserName = login.text + prefs.cloudPassword = password.text + prefs.cloudPin = pin.text manager.saveCloudCredentials() } @@ -60,7 +60,7 @@ Item { Controls.TextField { id: login - text: manager.cloudUserName + text: prefs.cloudUserName visible: !rootItem.showPin Layout.fillWidth: true inputMethodHints: Qt.ImhEmailCharactersOnly | @@ -76,7 +76,7 @@ Item { Controls.TextField { id: password - text: manager.cloudPassword + text: prefs.cloudPassword visible: !rootItem.showPin echoMode: TextInput.PasswordEchoOnEdit inputMethodHints: Qt.ImhSensitiveData | @@ -146,7 +146,7 @@ Item { text: qsTr("No cloud mode") onClicked: { manager.syncToCloud = false - manager.credentialStatus = QMLManager.CS_NOCLOUD + manager.credentialStatus = QMLPrefs.CS_NOCLOUD manager.saveCloudCredentials() manager.openNoCloudRepo() } diff --git a/mobile-widgets/qml/DiveList.qml b/mobile-widgets/qml/DiveList.qml index 31b2204fa..36929951a 100644 --- a/mobile-widgets/qml/DiveList.qml +++ b/mobile-widgets/qml/DiveList.qml @@ -13,7 +13,7 @@ Kirigami.ScrollablePage { title: qsTr("Dive list") verticalScrollBarPolicy: Qt.ScrollBarAlwaysOff width: subsurfaceTheme.columnWidth - property int credentialStatus: manager.credentialStatus + property int credentialStatus: prefs.credentialStatus property int numDives: diveListView.count property color textColor: subsurfaceTheme.textColor property color secondaryTextColor: subsurfaceTheme.secondaryTextColor @@ -23,14 +23,14 @@ Kirigami.ScrollablePage { supportsRefreshing: true onRefreshingChanged: { if (refreshing) { - if (manager.credentialStatus === QMLManager.CS_VERIFIED) { + if (prefs.credentialStatus === QMLPrefs.CS_VERIFIED) { console.log("User pulled down dive list - syncing with cloud storage") detailsWindow.endEditMode() manager.saveChangesCloud(true) console.log("done syncing, turn off spinner") refreshing = false } else { - console.log("sync with cloud storage requested, but credentialStatus is " + manager.credentialStatus) + console.log("sync with cloud storage requested, but credentialStatus is " + prefs.credentialStatus) console.log("no syncing, turn off spinner") refreshing = false } @@ -339,7 +339,8 @@ Kirigami.ScrollablePage { StartPage { id: startPage anchors.fill: parent - opacity: credentialStatus === QMLManager.CS_NOCLOUD || (credentialStatus === QMLManager.CS_VERIFIED) ? 0 : 1 + opacity: credentialStatus === QMLPrefs.CS_NOCLOUD || + (credentialStatus === QMLPrefs.CS_VERIFIED) ? 0 : 1 visible: opacity > 0 Behavior on opacity { NumberAnimation { duration: Kirigami.Units.shortDuration } } function setupActions() { @@ -347,7 +348,8 @@ Kirigami.ScrollablePage { page.actions.main = null page.actions.right = null page.title = qsTr("Cloud credentials") - } else if (manager.credentialStatus === QMLManager.CS_VERIFIED || manager.credentialStatus === QMLManager.CS_NOCLOUD) { + } else if (prefs.credentialStatus === QMLPrefs.CS_VERIFIED || + prefs.credentialStatus === QMLPrefs.CS_NOCLOUD) { page.actions.main = page.downloadFromDCAction page.actions.right = page.addDiveAction page.title = qsTr("Dive list") @@ -424,8 +426,9 @@ Kirigami.ScrollablePage { } onBackRequested: { - if (startPage.visible && diveListView.count > 0 && manager.credentialStatus !== QMLManager.CS_INCORRECT_USER_PASSWD) { - manager.credentialStatus = oldStatus + if (startPage.visible && diveListView.count > 0 && + prefs.credentialStatus !== QMLPrefs.CS_INCORRECT_USER_PASSWD) { + prefs.credentialStatus = oldStatus event.accepted = true; } if (!startPage.visible) { diff --git a/mobile-widgets/qml/Settings.qml b/mobile-widgets/qml/Settings.qml index 40ee2ea08..3c567f156 100644 --- a/mobile-widgets/qml/Settings.qml +++ b/mobile-widgets/qml/Settings.qml @@ -42,7 +42,8 @@ Kirigami.ScrollablePage { Layout.preferredHeight: Kirigami.Units.gridUnit * 2 } Controls.Label { - text: manager.credentialStatus === QMLManager.CS_NOCLOUD ? qsTr("Not applicable") : manager.cloudUserName + text: prefs.credentialStatus === QMLPrefs.CS_NOCLOUD ? qsTr("Not applicable") : + prefs.cloudUserName Layout.alignment: Qt.AlignRight Layout.preferredWidth: gridWidth * 0.60 Layout.preferredHeight: Kirigami.Units.gridUnit * 2 @@ -63,7 +64,7 @@ Kirigami.ScrollablePage { Layout.preferredHeight: Kirigami.Units.gridUnit * 2 } Controls.Label { - text: describe[manager.credentialStatus] + text: describe[prefs.credentialStatus] Layout.alignment: Qt.AlignRight Layout.preferredWidth: gridWidth * 0.60 Layout.preferredHeight: Kirigami.Units.gridUnit * 2 @@ -136,8 +137,8 @@ Kirigami.ScrollablePage { enabled: subsurfaceTheme.currentTheme !== "Blue" onClicked: { blueTheme() - manager.theme = subsurfaceTheme.currentTheme - manager.savePreferences() + prefs.theme = subsurfaceTheme.currentTheme + prefs.savePreferences() } } @@ -189,8 +190,8 @@ Kirigami.ScrollablePage { enabled: subsurfaceTheme.currentTheme !== "Pink" onClicked: { pinkTheme() - manager.theme = subsurfaceTheme.currentTheme - manager.savePreferences() + prefs.theme = subsurfaceTheme.currentTheme + prefs.savePreferences() } } @@ -241,8 +242,8 @@ Kirigami.ScrollablePage { enabled: subsurfaceTheme.currentTheme !== "Dark" onClicked: { darkTheme() - manager.theme = subsurfaceTheme.currentTheme - manager.savePreferences() + prefs.theme = subsurfaceTheme.currentTheme + prefs.savePreferences() } } } @@ -275,11 +276,11 @@ Kirigami.ScrollablePage { Controls.TextField { id: distanceThreshold - text: manager.distanceThreshold + text: prefs.distanceThreshold Layout.preferredWidth: gridWidth * 0.25 onEditingFinished: { - manager.distanceThreshold = distanceThreshold.text - manager.savePreferences() + prefs.distanceThreshold = distanceThreshold.text + prefs.savePreferences() } } @@ -291,11 +292,11 @@ Kirigami.ScrollablePage { Controls.TextField { id: timeThreshold - text: manager.timeThreshold + text: prefs.timeThreshold Layout.preferredWidth: gridWidth * 0.25 onEditingFinished: { - manager.timeThreshold = timeThreshold.text - manager.savePreferences() + prefs.timeThreshold = timeThreshold.text + prefs.savePreferences() } } @@ -325,10 +326,10 @@ Kirigami.ScrollablePage { } SsrfSwitch { id: developerButton - checked: manager.developer + checked: prefs.developer Layout.preferredWidth: gridWidth * 0.25 onClicked: { - manager.developer = checked + prefs.developer = checked } } } diff --git a/mobile-widgets/qml/main.qml b/mobile-widgets/qml/main.qml index 28f16a9b8..125d964ec 100644 --- a/mobile-widgets/qml/main.qml +++ b/mobile-widgets/qml/main.qml @@ -20,11 +20,11 @@ Kirigami.ApplicationWindow { maximumHeight: Kirigami.Units.gridUnit * 2 background: Rectangle { color: subsurfaceTheme.primaryColor } } - property alias oldStatus: manager.oldStatus + property alias oldStatus: prefs.oldStatus property alias notificationText: manager.notificationText property alias syncToCloud: manager.syncToCloud property alias locationServiceEnabled: manager.locationServiceEnabled - property alias showPin: manager.showPin + property alias showPin: prefs.showPin onNotificationTextChanged: { if (notificationText != "") { // there's a risk that we have a >5 second gap in update events; @@ -119,12 +119,12 @@ Kirigami.ApplicationWindow { } text: qsTr("Dive list") onTriggered: { - manager.appendTextToLog("requested dive list with credential status " + manager.credentialStatus) - if (manager.credentialStatus == QMLManager.CS_UNKNOWN) { + manager.appendTextToLog("requested dive list with credential status " + prefs.credentialStatus) + if (prefs.credentialStatus == QMLPrefs.CS_UNKNOWN) { // the user has asked to change credentials - if the credentials before that // were valid, go back to dive list - if (oldStatus == QMLManager.CS_VERIFIED) { - manager.credentialStatus = oldStatus + if (oldStatus == QMLPrefs.CS_VERIFIED) { + prefs.credentialStatus = oldStatus } } returnTopPage() @@ -150,7 +150,8 @@ Kirigami.ApplicationWindow { name: ":/icons/ic_add.svg" } text: qsTr("Add dive manually") - enabled: manager.credentialStatus === QMLManager.CS_VERIFIED || manager.credentialStatus === QMLManager.CS_NOCLOUD + enabled: prefs.credentialStatus === QMLPrefs.CS_VERIFIED || + prefs.credentialStatus === QMLPrefs.CS_NOCLOUD onTriggered: { globalDrawer.close() returnTopPage() // otherwise odd things happen with the page stack @@ -184,13 +185,14 @@ Kirigami.ApplicationWindow { name: ":/icons/cloud_sync.svg" } text: qsTr("Manual sync with cloud") - enabled: manager.credentialStatus === QMLManager.CS_VERIFIED || manager.credentialStatus === QMLManager.CS_NOCLOUD + enabled: prefs.credentialStatus === QMLPrefs.CS_VERIFIED || + prefs.credentialStatus === QMLPrefs.CS_NOCLOUD onTriggered: { - if (manager.credentialStatus === QMLManager.CS_NOCLOUD) { + if (prefs.credentialStatus === QMLPrefs.CS_NOCLOUD) { returnTopPage() - oldStatus = manager.credentialStatus + oldStatus = prefs.credentialStatus manager.startPageText = "Enter valid cloud storage credentials" - manager.credentialStatus = QMLManager.CS_UNKNOWN + prefs.credentialStatus = QMLPrefs.CS_UNKNOWN globalDrawer.close() } else { globalDrawer.close() @@ -205,7 +207,7 @@ Kirigami.ApplicationWindow { name: syncToCloud ? ":/icons/ic_cloud_off.svg" : ":/icons/ic_cloud_done.svg" } text: syncToCloud ? qsTr("Disable auto cloud sync") : qsTr("Enable auto cloud sync") - enabled: manager.credentialStatus !== QMLManager.CS_NOCLOUD + enabled: prefs.credentialStatus !== QMLPrefs.CS_NOCLOUD onTriggered: { syncToCloud = !syncToCloud if (!syncToCloud) { @@ -307,7 +309,7 @@ if you have network connectivity and want to sync your data to cloud storage."), name: ":/icons/ic_adb.svg" } text: qsTr("Developer") - visible: manager.developer + visible: prefs.developer Kirigami.Action { text: qsTr("App log") onTriggered: { @@ -452,7 +454,7 @@ if you have network connectivity and want to sync your data to cloud storage."), property int columnWidth: Math.round(rootItem.width/(Kirigami.Units.gridUnit*28)) > 0 ? Math.round(rootItem.width / Math.round(rootItem.width/(Kirigami.Units.gridUnit*28))) : rootItem.width Component.onCompleted: { // this needs to pick the theme from persistent preference settings - var theme = manager.theme + var theme = prefs.theme if (theme == "Blue") blueTheme() else if (theme == "Pink") |