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>
This commit is contained in:
Jan Mulder 2017-08-03 14:55:09 +02:00 committed by Dirk Hohndel
parent 7e2803d6dd
commit 9a2d503d3b
5 changed files with 50 additions and 47 deletions

View file

@ -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) {