core: make qPref::cloud_status the only version of the enum

add enum to qPref and remove elsewhere
update source core to reference qPref.

the enum cannot be in pref.h because it is to be used in qml and Q_ENUM
need the enum to be defined as part of the class

Signed-off-by: Jan Iversen <jani@apache.org>
This commit is contained in:
jan Iversen 2018-07-05 20:37:53 +02:00 committed by Dirk Hohndel
parent 7103f36c7c
commit 8d66633fe7
14 changed files with 90 additions and 95 deletions

View file

@ -144,7 +144,7 @@ Item {
text: qsTr("No cloud mode")
onClicked: {
manager.syncToCloud = false
prefs.credentialStatus = QMLPrefs.CS_NOCLOUD
prefs.credentialStatus = SsrfPrefs.CS_NOCLOUD
manager.saveCloudCredentials()
manager.openNoCloudRepo()
}

View file

@ -23,7 +23,7 @@ Kirigami.ScrollablePage {
supportsRefreshing: true
onRefreshingChanged: {
if (refreshing) {
if (prefs.credentialStatus === QMLPrefs.CS_VERIFIED) {
if (prefs.credentialStatus === SsrfPrefs.CS_VERIFIED) {
console.log("User pulled down dive list - syncing with cloud storage")
detailsWindow.endEditMode()
manager.saveChangesCloud(true)
@ -339,8 +339,8 @@ Kirigami.ScrollablePage {
StartPage {
id: startPage
anchors.fill: parent
opacity: credentialStatus === QMLPrefs.CS_NOCLOUD ||
(credentialStatus === QMLPrefs.CS_VERIFIED) ? 0 : 1
opacity: credentialStatus === SsrfPrefs.CS_NOCLOUD ||
(credentialStatus === SsrfPrefs.CS_VERIFIED) ? 0 : 1
visible: opacity > 0
Behavior on opacity { NumberAnimation { duration: Kirigami.Units.shortDuration } }
function setupActions() {
@ -348,8 +348,8 @@ Kirigami.ScrollablePage {
page.actions.main = null
page.actions.right = null
page.title = qsTr("Cloud credentials")
} else if (prefs.credentialStatus === QMLPrefs.CS_VERIFIED ||
prefs.credentialStatus === QMLPrefs.CS_NOCLOUD) {
} else if (prefs.credentialStatus === SsrfPrefs.CS_VERIFIED ||
prefs.credentialStatus === SsrfPrefs.CS_NOCLOUD) {
page.actions.main = page.downloadFromDCAction
page.actions.right = page.addDiveAction
page.title = qsTr("Dive list")
@ -427,7 +427,7 @@ Kirigami.ScrollablePage {
onBackRequested: {
if (startPage.visible && diveListView.count > 0 &&
prefs.credentialStatus !== QMLPrefs.CS_INCORRECT_USER_PASSWD) {
prefs.credentialStatus !== SsrfPrefs.CS_INCORRECT_USER_PASSWD) {
prefs.credentialStatus = oldStatus
event.accepted = true;
}

View file

@ -42,7 +42,7 @@ Kirigami.ScrollablePage {
Layout.preferredHeight: Kirigami.Units.gridUnit * 2
}
Controls.Label {
text: prefs.credentialStatus === QMLPrefs.CS_NOCLOUD ? qsTr("Not applicable") : prefs.cloudUserName
text: prefs.credentialStatus === SsrfPrefs.CS_NOCLOUD ? qsTr("Not applicable") : prefs.cloudUserName
Layout.alignment: Qt.AlignRight
Layout.preferredWidth: gridWidth * 0.60
Layout.preferredHeight: Kirigami.Units.gridUnit * 2

View file

@ -186,10 +186,10 @@ Kirigami.ApplicationWindow {
text: qsTr("Dive list")
onTriggered: {
manager.appendTextToLog("requested dive list with credential status " + prefs.credentialStatus)
if (prefs.credentialStatus == QMLPrefs.CS_UNKNOWN) {
if (prefs.credentialStatus == SsrfPrefs.CS_UNKNOWN) {
// the user has asked to change credentials - if the credentials before that
// were valid, go back to dive list
if (oldStatus == QMLPrefs.CS_VERIFIED) {
if (oldStatus == SsrfPrefs.CS_VERIFIED) {
prefs.credentialStatus = oldStatus
}
}
@ -216,8 +216,8 @@ Kirigami.ApplicationWindow {
name: ":/icons/ic_add.svg"
}
text: qsTr("Add dive manually")
enabled: prefs.credentialStatus === QMLPrefs.CS_VERIFIED ||
prefs.credentialStatus === QMLPrefs.CS_NOCLOUD
enabled: prefs.credentialStatus === SsrfPrefs.CS_VERIFIED ||
prefs.credentialStatus === SsrfPrefs.CS_NOCLOUD
onTriggered: {
globalDrawer.close()
returnTopPage() // otherwise odd things happen with the page stack
@ -251,14 +251,14 @@ Kirigami.ApplicationWindow {
name: ":/icons/cloud_sync.svg"
}
text: qsTr("Manual sync with cloud")
enabled: prefs.credentialStatus === QMLPrefs.CS_VERIFIED ||
prefs.credentialStatus === QMLPrefs.CS_NOCLOUD
enabled: prefs.credentialStatus === SsrfPrefs.CS_VERIFIED ||
prefs.credentialStatus === SsrfPrefs.CS_NOCLOUD
onTriggered: {
if (prefs.credentialStatus === QMLPrefs.CS_NOCLOUD) {
if (prefs.credentialStatus === SsrfPrefs.CS_NOCLOUD) {
returnTopPage()
oldStatus = prefs.credentialStatus
manager.startPageText = "Enter valid cloud storage credentials"
prefs.credentialStatus = QMLPrefs.CS_UNKNOWN
prefs.credentialStatus = SsrfPrefs.CS_UNKNOWN
globalDrawer.close()
} else {
globalDrawer.close()
@ -273,7 +273,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: prefs.credentialStatus !== QMLPrefs.CS_NOCLOUD
enabled: prefs.credentialStatus !== SsrfPrefs.CS_NOCLOUD
onTriggered: {
syncToCloud = !syncToCloud
if (!syncToCloud) {