summaryrefslogtreecommitdiffstats
path: root/mobile-widgets/qml
diff options
context:
space:
mode:
authorGravatar Jan Mulder <jlmulder@xs4all.nl>2017-08-03 14:55:09 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2017-09-04 07:38:30 -0700
commit9a2d503d3b3d2c0a4631ef6c26dcf1c6785a4e56 (patch)
tree31270a689b6d00666553a0cc71ee9bbb27a70a7a /mobile-widgets/qml
parent7e2803d6dd65016bfd925345adf3abdfbbbe6056 (diff)
downloadsubsurface-9a2d503d3b3d2c0a4631ef6c26dcf1c6785a4e56.tar.gz
Unify credential states
Having two different enums around with more or less the same definition has lead to unclear code. After removing two not needed states on the mobile end, the remaining step to one enum for the credential state becomes almost is simple rename operation. Unfortunately, I do not know a way to embed a plain C enum from pref.h into the QMLManager object. So after this, there are still 2 enums around, but now identical. This commit is not changing any functionality. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
Diffstat (limited to 'mobile-widgets/qml')
-rw-r--r--mobile-widgets/qml/DiveList.qml11
-rw-r--r--mobile-widgets/qml/main.qml14
2 files changed, 13 insertions, 12 deletions
diff --git a/mobile-widgets/qml/DiveList.qml b/mobile-widgets/qml/DiveList.qml
index 1dccb5b75..be659e6b9 100644
--- a/mobile-widgets/qml/DiveList.qml
+++ b/mobile-widgets/qml/DiveList.qml
@@ -24,7 +24,7 @@ Kirigami.ScrollablePage {
supportsRefreshing: true
onRefreshingChanged: {
if (refreshing) {
- if (manager.credentialStatus === QMLManager.VALID) {
+ if (manager.credentialStatus === QMLManager.CS_VERIFIED) {
console.log("User pulled down dive list - syncing with cloud storage")
detailsWindow.endEditMode()
manager.saveChangesCloud(true)
@@ -266,7 +266,7 @@ Kirigami.ScrollablePage {
StartPage {
id: startPage
anchors.fill: parent
- opacity: credentialStatus === QMLManager.NOCLOUD || (credentialStatus === QMLManager.VALID) ? 0 : 1
+ opacity: credentialStatus === QMLManager.CS_NOCLOUD || (credentialStatus === QMLManager.CS_VERIFIED) ? 0 : 1
visible: opacity > 0
Behavior on opacity { NumberAnimation { duration: Kirigami.Units.shortDuration } }
function setupActions() {
@@ -274,7 +274,7 @@ Kirigami.ScrollablePage {
page.actions.main = page.saveAction
page.actions.right = page.offlineAction
page.title = qsTr("Cloud credentials")
- } else if(manager.credentialStatus === QMLManager.VALID || manager.credentialStatus === QMLManager.NOCLOUD) {
+ } else if(manager.credentialStatus === QMLManager.CS_VERIFIED || manager.credentialStatus === QMLManager.CS_NOCLOUD) {
page.actions.main = page.downloadFromDCAction
page.actions.right = page.addDiveAction
page.title = qsTr("Dive list")
@@ -289,6 +289,7 @@ Kirigami.ScrollablePage {
onVisibleChanged: {
setupActions();
}
+
Component.onCompleted: {
setupActions();
}
@@ -355,12 +356,12 @@ Kirigami.ScrollablePage {
iconName: "qrc:/qml/nocloud.svg"
onTriggered: {
manager.syncToCloud = false
- manager.credentialStatus = QMLManager.NOCLOUD
+ manager.credentialStatus = QMLManager.CS_NOCLOUD
}
}
onBackRequested: {
- if (startPage.visible && diveListView.count > 0 && manager.credentialStatus !== QMLManager.INVALID) {
+ if (startPage.visible && diveListView.count > 0 && manager.credentialStatus !== QMLManager.CS_INCORRECT_USER_PASSWD) {
manager.credentialStatus = oldStatus
event.accepted = true;
}
diff --git a/mobile-widgets/qml/main.qml b/mobile-widgets/qml/main.qml
index e34e89e50..1cf1ea35d 100644
--- a/mobile-widgets/qml/main.qml
+++ b/mobile-widgets/qml/main.qml
@@ -117,10 +117,10 @@ Kirigami.ApplicationWindow {
text: qsTr("Dive list")
onTriggered: {
manager.appendTextToLog("requested dive list with credential status " + manager.credentialStatus)
- if (manager.credentialStatus == QMLManager.UNKNOWN) {
+ if (manager.credentialStatus == QMLManager.CS_UNKNOWN) {
// the user has asked to change credentials - if the credentials before that
// were valid, go back to dive list
- if (oldStatus == QMLManager.VALID) {
+ if (oldStatus == QMLManager.CS_VERIFIED) {
manager.credentialStatus = oldStatus
}
}
@@ -134,7 +134,7 @@ Kirigami.ApplicationWindow {
Kirigami.Action {
iconName: "icons/ic_add.svg"
text: qsTr("Add dive manually")
- enabled: manager.credentialStatus === QMLManager.VALID || manager.credentialStatus === QMLManager.NOCLOUD
+ enabled: manager.credentialStatus === QMLManager.CS_VERIFIED || manager.credentialStatus === QMLManager.CS_NOCLOUD
onTriggered: {
returnTopPage() // otherwise odd things happen with the page stack
startAddDive()
@@ -159,13 +159,13 @@ Kirigami.ApplicationWindow {
Kirigami.Action {
iconName: "icons/cloud_sync.svg"
text: qsTr("Manual sync with cloud")
- enabled: manager.credentialStatus === QMLManager.VALID || manager.credentialStatus === QMLManager.NOCLOUD
+ enabled: manager.credentialStatus === QMLManager.CS_VERIFIED || manager.credentialStatus === QMLManager.CS_NOCLOUD
onTriggered: {
- if (manager.credentialStatus === QMLManager.NOCLOUD) {
+ if (manager.credentialStatus === QMLManager.CS_NOCLOUD) {
returnTopPage()
oldStatus = manager.credentialStatus
manager.startPageText = "Enter valid cloud storage credentials"
- manager.credentialStatus = QMLManager.UNKNOWN
+ manager.credentialStatus = QMLManager.CS_UNKNOWN
globalDrawer.close()
} else {
globalDrawer.close()
@@ -178,7 +178,7 @@ Kirigami.ApplicationWindow {
Kirigami.Action {
iconName: syncToCloud ? "icons/ic_cloud_off.svg" : "icons/ic_cloud_done.svg"
text: syncToCloud ? qsTr("Offline mode") : qsTr("Enable auto cloud sync")
- enabled: manager.credentialStatus !== QMLManager.NOCLOUD
+ enabled: manager.credentialStatus !== QMLManager.CS_NOCLOUD
onTriggered: {
syncToCloud = !syncToCloud
if (!syncToCloud) {