mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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:
parent
7103f36c7c
commit
8d66633fe7
14 changed files with 90 additions and 95 deletions
|
@ -52,7 +52,7 @@ void CloudStorageAuthenticate::uploadFinished()
|
||||||
CloudStorageSettings csSettings(parent());
|
CloudStorageSettings csSettings(parent());
|
||||||
|
|
||||||
if (cloudAuthReply == QLatin1String("[VERIFIED]") || cloudAuthReply == QLatin1String("[OK]")) {
|
if (cloudAuthReply == QLatin1String("[VERIFIED]") || cloudAuthReply == QLatin1String("[OK]")) {
|
||||||
csSettings.setVerificationStatus(CS_VERIFIED);
|
csSettings.setVerificationStatus(qPref::CS_VERIFIED);
|
||||||
/* TODO: Move this to a correct place
|
/* TODO: Move this to a correct place
|
||||||
NotificationWidget *nw = MainWindow::instance()->getNotificationWidget();
|
NotificationWidget *nw = MainWindow::instance()->getNotificationWidget();
|
||||||
if (nw->getNotificationText() == myLastError)
|
if (nw->getNotificationText() == myLastError)
|
||||||
|
@ -61,7 +61,7 @@ void CloudStorageAuthenticate::uploadFinished()
|
||||||
myLastError.clear();
|
myLastError.clear();
|
||||||
} else if (cloudAuthReply == QLatin1String("[VERIFY]") ||
|
} else if (cloudAuthReply == QLatin1String("[VERIFY]") ||
|
||||||
cloudAuthReply == QLatin1String("Invalid PIN")) {
|
cloudAuthReply == QLatin1String("Invalid PIN")) {
|
||||||
csSettings.setVerificationStatus(CS_NEED_TO_VERIFY);
|
csSettings.setVerificationStatus(qPref::CS_NEED_TO_VERIFY);
|
||||||
report_error(qPrintable(tr("Cloud account verification required, enter PIN in preferences")));
|
report_error(qPrintable(tr("Cloud account verification required, enter PIN in preferences")));
|
||||||
} else if (cloudAuthReply == QLatin1String("[PASSWDCHANGED]")) {
|
} else if (cloudAuthReply == QLatin1String("[PASSWDCHANGED]")) {
|
||||||
free((void *)prefs.cloud_storage_password);
|
free((void *)prefs.cloud_storage_password);
|
||||||
|
@ -70,7 +70,7 @@ void CloudStorageAuthenticate::uploadFinished()
|
||||||
emit passwordChangeSuccessful();
|
emit passwordChangeSuccessful();
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
csSettings.setVerificationStatus(CS_INCORRECT_USER_PASSWD);
|
csSettings.setVerificationStatus(qPref::CS_INCORRECT_USER_PASSWD);
|
||||||
myLastError = cloudAuthReply;
|
myLastError = cloudAuthReply;
|
||||||
report_error("%s", qPrintable(cloudAuthReply));
|
report_error("%s", qPrintable(cloudAuthReply));
|
||||||
}
|
}
|
||||||
|
|
|
@ -213,14 +213,6 @@ enum def_file_behavior {
|
||||||
CLOUD_DEFAULT_FILE
|
CLOUD_DEFAULT_FILE
|
||||||
};
|
};
|
||||||
|
|
||||||
enum cloud_status {
|
|
||||||
CS_UNKNOWN,
|
|
||||||
CS_INCORRECT_USER_PASSWD,
|
|
||||||
CS_NEED_TO_VERIFY,
|
|
||||||
CS_VERIFIED,
|
|
||||||
CS_NOCLOUD
|
|
||||||
};
|
|
||||||
|
|
||||||
extern struct preferences prefs, default_prefs, git_prefs;
|
extern struct preferences prefs, default_prefs, git_prefs;
|
||||||
|
|
||||||
extern const char *system_divelist_default_font;
|
extern const char *system_divelist_default_font;
|
||||||
|
|
|
@ -20,6 +20,14 @@ public:
|
||||||
void loadSync(bool doSync);
|
void loadSync(bool doSync);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
enum cloud_status {
|
||||||
|
CS_UNKNOWN,
|
||||||
|
CS_INCORRECT_USER_PASSWD,
|
||||||
|
CS_NEED_TO_VERIFY,
|
||||||
|
CS_VERIFIED,
|
||||||
|
CS_NOCLOUD
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
};
|
};
|
||||||
|
|
|
@ -442,8 +442,8 @@ void MainWindow::on_actionDiveSiteEdit_triggered() {
|
||||||
|
|
||||||
void MainWindow::enableDisableCloudActions()
|
void MainWindow::enableDisableCloudActions()
|
||||||
{
|
{
|
||||||
ui.actionCloudstorageopen->setEnabled(prefs.cloud_verification_status == CS_VERIFIED);
|
ui.actionCloudstorageopen->setEnabled(prefs.cloud_verification_status == qPref::CS_VERIFIED);
|
||||||
ui.actionCloudstoragesave->setEnabled(prefs.cloud_verification_status == CS_VERIFIED);
|
ui.actionCloudstoragesave->setEnabled(prefs.cloud_verification_status == qPref::CS_VERIFIED);
|
||||||
}
|
}
|
||||||
|
|
||||||
PlannerDetails *MainWindow::plannerDetails() const {
|
PlannerDetails *MainWindow::plannerDetails() const {
|
||||||
|
@ -751,7 +751,7 @@ void MainWindow::closeCurrentFile()
|
||||||
|
|
||||||
void MainWindow::updateCloudOnlineStatus()
|
void MainWindow::updateCloudOnlineStatus()
|
||||||
{
|
{
|
||||||
bool is_cloud = existing_filename && prefs.cloud_git_url && prefs.cloud_verification_status == CS_VERIFIED &&
|
bool is_cloud = existing_filename && prefs.cloud_git_url && prefs.cloud_verification_status == qPref::CS_VERIFIED &&
|
||||||
strstr(existing_filename, prefs.cloud_git_url);
|
strstr(existing_filename, prefs.cloud_git_url);
|
||||||
ui.actionCloudOnline->setEnabled(is_cloud);
|
ui.actionCloudOnline->setEnabled(is_cloud);
|
||||||
ui.actionCloudOnline->setChecked(is_cloud && !prefs.git_local_only);
|
ui.actionCloudOnline->setChecked(is_cloud && !prefs.git_local_only);
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include "ui_preferences_defaults.h"
|
#include "ui_preferences_defaults.h"
|
||||||
#include "core/dive.h"
|
#include "core/dive.h"
|
||||||
#include "core/subsurface-qt/SettingsObjectWrapper.h"
|
#include "core/subsurface-qt/SettingsObjectWrapper.h"
|
||||||
|
#include "core/settings/qPref.h"
|
||||||
|
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
|
|
||||||
|
@ -61,7 +62,7 @@ void PreferencesDefaults::refreshSettings()
|
||||||
ui->velocitySlider->setValue(prefs.animation_speed);
|
ui->velocitySlider->setValue(prefs.animation_speed);
|
||||||
ui->btnUseDefaultFile->setChecked(prefs.use_default_file);
|
ui->btnUseDefaultFile->setChecked(prefs.use_default_file);
|
||||||
|
|
||||||
if (prefs.cloud_verification_status == CS_VERIFIED) {
|
if (prefs.cloud_verification_status == qPref::CS_VERIFIED) {
|
||||||
ui->cloudDefaultFile->setEnabled(true);
|
ui->cloudDefaultFile->setEnabled(true);
|
||||||
} else {
|
} else {
|
||||||
if (ui->cloudDefaultFile->isChecked())
|
if (ui->cloudDefaultFile->isChecked())
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include "core/cloudstorage.h"
|
#include "core/cloudstorage.h"
|
||||||
#include "core/dive.h"
|
#include "core/dive.h"
|
||||||
#include "core/subsurface-qt/SettingsObjectWrapper.h"
|
#include "core/subsurface-qt/SettingsObjectWrapper.h"
|
||||||
|
#include "core/settings/qPref.h"
|
||||||
#include <QNetworkProxy>
|
#include <QNetworkProxy>
|
||||||
|
|
||||||
PreferencesNetwork::PreferencesNetwork() : AbstractPreferencesWidget(tr("Network"),QIcon(":preferences-system-network-icon"), 9), ui(new Ui::PreferencesNetwork())
|
PreferencesNetwork::PreferencesNetwork() : AbstractPreferencesWidget(tr("Network"),QIcon(":preferences-system-network-icon"), 9), ui(new Ui::PreferencesNetwork())
|
||||||
|
@ -62,7 +63,7 @@ void PreferencesNetwork::syncSettings()
|
||||||
QString newpassword = ui->cloud_storage_new_passwd->text();
|
QString newpassword = ui->cloud_storage_new_passwd->text();
|
||||||
|
|
||||||
//TODO: Change this to the Cloud Storage Stuff, not preferences.
|
//TODO: Change this to the Cloud Storage Stuff, not preferences.
|
||||||
if (prefs.cloud_verification_status == CS_VERIFIED && !newpassword.isEmpty()) {
|
if (prefs.cloud_verification_status == qPref::CS_VERIFIED && !newpassword.isEmpty()) {
|
||||||
// deal with password change
|
// deal with password change
|
||||||
if (!email.isEmpty() && !password.isEmpty()) {
|
if (!email.isEmpty() && !password.isEmpty()) {
|
||||||
// connect to backend server to check / create credentials
|
// connect to backend server to check / create credentials
|
||||||
|
@ -83,14 +84,14 @@ void PreferencesNetwork::syncSettings()
|
||||||
ui->cloud_storage_new_passwd->setText("");
|
ui->cloud_storage_new_passwd->setText("");
|
||||||
cloud->setNewPassword(newpassword);
|
cloud->setNewPassword(newpassword);
|
||||||
}
|
}
|
||||||
} else if (prefs.cloud_verification_status == CS_UNKNOWN ||
|
} else if (prefs.cloud_verification_status == qPref::CS_UNKNOWN ||
|
||||||
prefs.cloud_verification_status == CS_INCORRECT_USER_PASSWD ||
|
prefs.cloud_verification_status == qPref::CS_INCORRECT_USER_PASSWD ||
|
||||||
email != prefs.cloud_storage_email ||
|
email != prefs.cloud_storage_email ||
|
||||||
password != prefs.cloud_storage_password) {
|
password != prefs.cloud_storage_password) {
|
||||||
|
|
||||||
// different credentials - reset verification status
|
// different credentials - reset verification status
|
||||||
int oldVerificationStatus = cloud->verificationStatus();
|
int oldVerificationStatus = cloud->verificationStatus();
|
||||||
cloud->setVerificationStatus(CS_UNKNOWN);
|
cloud->setVerificationStatus(qPref::CS_UNKNOWN);
|
||||||
if (!email.isEmpty() && !password.isEmpty()) {
|
if (!email.isEmpty() && !password.isEmpty()) {
|
||||||
// connect to backend server to check / create credentials
|
// connect to backend server to check / create credentials
|
||||||
QRegularExpression reg("^[a-zA-Z0-9@.+_-]+$");
|
QRegularExpression reg("^[a-zA-Z0-9@.+_-]+$");
|
||||||
|
@ -103,7 +104,7 @@ void PreferencesNetwork::syncSettings()
|
||||||
connect(cloudAuth, &CloudStorageAuthenticate::finishedAuthenticate, this, &PreferencesNetwork::updateCloudAuthenticationState);
|
connect(cloudAuth, &CloudStorageAuthenticate::finishedAuthenticate, this, &PreferencesNetwork::updateCloudAuthenticationState);
|
||||||
cloudAuth->backend(email, password);
|
cloudAuth->backend(email, password);
|
||||||
}
|
}
|
||||||
} else if (prefs.cloud_verification_status == CS_NEED_TO_VERIFY) {
|
} else if (prefs.cloud_verification_status == qPref::CS_NEED_TO_VERIFY) {
|
||||||
QString pin = ui->cloud_storage_pin->text();
|
QString pin = ui->cloud_storage_pin->text();
|
||||||
if (!pin.isEmpty()) {
|
if (!pin.isEmpty()) {
|
||||||
// connect to backend server to check / create credentials
|
// connect to backend server to check / create credentials
|
||||||
|
@ -126,19 +127,19 @@ void PreferencesNetwork::syncSettings()
|
||||||
|
|
||||||
void PreferencesNetwork::updateCloudAuthenticationState()
|
void PreferencesNetwork::updateCloudAuthenticationState()
|
||||||
{
|
{
|
||||||
ui->cloud_storage_pin->setEnabled(prefs.cloud_verification_status == CS_NEED_TO_VERIFY);
|
ui->cloud_storage_pin->setEnabled(prefs.cloud_verification_status == qPref::CS_NEED_TO_VERIFY);
|
||||||
ui->cloud_storage_pin->setVisible(prefs.cloud_verification_status == CS_NEED_TO_VERIFY);
|
ui->cloud_storage_pin->setVisible(prefs.cloud_verification_status == qPref::CS_NEED_TO_VERIFY);
|
||||||
ui->cloud_storage_pin_label->setEnabled(prefs.cloud_verification_status == CS_NEED_TO_VERIFY);
|
ui->cloud_storage_pin_label->setEnabled(prefs.cloud_verification_status == qPref::CS_NEED_TO_VERIFY);
|
||||||
ui->cloud_storage_pin_label->setVisible(prefs.cloud_verification_status == CS_NEED_TO_VERIFY);
|
ui->cloud_storage_pin_label->setVisible(prefs.cloud_verification_status == qPref::CS_NEED_TO_VERIFY);
|
||||||
ui->cloud_storage_new_passwd->setEnabled(prefs.cloud_verification_status == CS_VERIFIED);
|
ui->cloud_storage_new_passwd->setEnabled(prefs.cloud_verification_status == qPref::CS_VERIFIED);
|
||||||
ui->cloud_storage_new_passwd->setVisible(prefs.cloud_verification_status == CS_VERIFIED);
|
ui->cloud_storage_new_passwd->setVisible(prefs.cloud_verification_status == qPref::CS_VERIFIED);
|
||||||
ui->cloud_storage_new_passwd_label->setEnabled(prefs.cloud_verification_status == CS_VERIFIED);
|
ui->cloud_storage_new_passwd_label->setEnabled(prefs.cloud_verification_status == qPref::CS_VERIFIED);
|
||||||
ui->cloud_storage_new_passwd_label->setVisible(prefs.cloud_verification_status == CS_VERIFIED);
|
ui->cloud_storage_new_passwd_label->setVisible(prefs.cloud_verification_status == qPref::CS_VERIFIED);
|
||||||
if (prefs.cloud_verification_status == CS_VERIFIED) {
|
if (prefs.cloud_verification_status == qPref::CS_VERIFIED) {
|
||||||
ui->cloudStorageGroupBox->setTitle(tr("Subsurface cloud storage (credentials verified)"));
|
ui->cloudStorageGroupBox->setTitle(tr("Subsurface cloud storage (credentials verified)"));
|
||||||
} else if (prefs.cloud_verification_status == CS_INCORRECT_USER_PASSWD) {
|
} else if (prefs.cloud_verification_status == qPref::CS_INCORRECT_USER_PASSWD) {
|
||||||
ui->cloudStorageGroupBox->setTitle(tr("Subsurface cloud storage (incorrect password)"));
|
ui->cloudStorageGroupBox->setTitle(tr("Subsurface cloud storage (incorrect password)"));
|
||||||
} else if (prefs.cloud_verification_status == CS_NEED_TO_VERIFY) {
|
} else if (prefs.cloud_verification_status == qPref::CS_NEED_TO_VERIFY) {
|
||||||
ui->cloudStorageGroupBox->setTitle(tr("Subsurface cloud storage (PIN required)"));
|
ui->cloudStorageGroupBox->setTitle(tr("Subsurface cloud storage (PIN required)"));
|
||||||
} else {
|
} else {
|
||||||
ui->cloudStorageGroupBox->setTitle(tr("Subsurface cloud storage"));
|
ui->cloudStorageGroupBox->setTitle(tr("Subsurface cloud storage"));
|
||||||
|
|
|
@ -144,7 +144,7 @@ Item {
|
||||||
text: qsTr("No cloud mode")
|
text: qsTr("No cloud mode")
|
||||||
onClicked: {
|
onClicked: {
|
||||||
manager.syncToCloud = false
|
manager.syncToCloud = false
|
||||||
prefs.credentialStatus = QMLPrefs.CS_NOCLOUD
|
prefs.credentialStatus = SsrfPrefs.CS_NOCLOUD
|
||||||
manager.saveCloudCredentials()
|
manager.saveCloudCredentials()
|
||||||
manager.openNoCloudRepo()
|
manager.openNoCloudRepo()
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ Kirigami.ScrollablePage {
|
||||||
supportsRefreshing: true
|
supportsRefreshing: true
|
||||||
onRefreshingChanged: {
|
onRefreshingChanged: {
|
||||||
if (refreshing) {
|
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")
|
console.log("User pulled down dive list - syncing with cloud storage")
|
||||||
detailsWindow.endEditMode()
|
detailsWindow.endEditMode()
|
||||||
manager.saveChangesCloud(true)
|
manager.saveChangesCloud(true)
|
||||||
|
@ -339,8 +339,8 @@ Kirigami.ScrollablePage {
|
||||||
StartPage {
|
StartPage {
|
||||||
id: startPage
|
id: startPage
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
opacity: credentialStatus === QMLPrefs.CS_NOCLOUD ||
|
opacity: credentialStatus === SsrfPrefs.CS_NOCLOUD ||
|
||||||
(credentialStatus === QMLPrefs.CS_VERIFIED) ? 0 : 1
|
(credentialStatus === SsrfPrefs.CS_VERIFIED) ? 0 : 1
|
||||||
visible: opacity > 0
|
visible: opacity > 0
|
||||||
Behavior on opacity { NumberAnimation { duration: Kirigami.Units.shortDuration } }
|
Behavior on opacity { NumberAnimation { duration: Kirigami.Units.shortDuration } }
|
||||||
function setupActions() {
|
function setupActions() {
|
||||||
|
@ -348,8 +348,8 @@ Kirigami.ScrollablePage {
|
||||||
page.actions.main = null
|
page.actions.main = null
|
||||||
page.actions.right = null
|
page.actions.right = null
|
||||||
page.title = qsTr("Cloud credentials")
|
page.title = qsTr("Cloud credentials")
|
||||||
} else if (prefs.credentialStatus === QMLPrefs.CS_VERIFIED ||
|
} else if (prefs.credentialStatus === SsrfPrefs.CS_VERIFIED ||
|
||||||
prefs.credentialStatus === QMLPrefs.CS_NOCLOUD) {
|
prefs.credentialStatus === SsrfPrefs.CS_NOCLOUD) {
|
||||||
page.actions.main = page.downloadFromDCAction
|
page.actions.main = page.downloadFromDCAction
|
||||||
page.actions.right = page.addDiveAction
|
page.actions.right = page.addDiveAction
|
||||||
page.title = qsTr("Dive list")
|
page.title = qsTr("Dive list")
|
||||||
|
@ -427,7 +427,7 @@ Kirigami.ScrollablePage {
|
||||||
|
|
||||||
onBackRequested: {
|
onBackRequested: {
|
||||||
if (startPage.visible && diveListView.count > 0 &&
|
if (startPage.visible && diveListView.count > 0 &&
|
||||||
prefs.credentialStatus !== QMLPrefs.CS_INCORRECT_USER_PASSWD) {
|
prefs.credentialStatus !== SsrfPrefs.CS_INCORRECT_USER_PASSWD) {
|
||||||
prefs.credentialStatus = oldStatus
|
prefs.credentialStatus = oldStatus
|
||||||
event.accepted = true;
|
event.accepted = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,7 @@ Kirigami.ScrollablePage {
|
||||||
Layout.preferredHeight: Kirigami.Units.gridUnit * 2
|
Layout.preferredHeight: Kirigami.Units.gridUnit * 2
|
||||||
}
|
}
|
||||||
Controls.Label {
|
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.alignment: Qt.AlignRight
|
||||||
Layout.preferredWidth: gridWidth * 0.60
|
Layout.preferredWidth: gridWidth * 0.60
|
||||||
Layout.preferredHeight: Kirigami.Units.gridUnit * 2
|
Layout.preferredHeight: Kirigami.Units.gridUnit * 2
|
||||||
|
|
|
@ -186,10 +186,10 @@ Kirigami.ApplicationWindow {
|
||||||
text: qsTr("Dive list")
|
text: qsTr("Dive list")
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
manager.appendTextToLog("requested dive list with credential status " + prefs.credentialStatus)
|
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
|
// the user has asked to change credentials - if the credentials before that
|
||||||
// were valid, go back to dive list
|
// were valid, go back to dive list
|
||||||
if (oldStatus == QMLPrefs.CS_VERIFIED) {
|
if (oldStatus == SsrfPrefs.CS_VERIFIED) {
|
||||||
prefs.credentialStatus = oldStatus
|
prefs.credentialStatus = oldStatus
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -216,8 +216,8 @@ Kirigami.ApplicationWindow {
|
||||||
name: ":/icons/ic_add.svg"
|
name: ":/icons/ic_add.svg"
|
||||||
}
|
}
|
||||||
text: qsTr("Add dive manually")
|
text: qsTr("Add dive manually")
|
||||||
enabled: prefs.credentialStatus === QMLPrefs.CS_VERIFIED ||
|
enabled: prefs.credentialStatus === SsrfPrefs.CS_VERIFIED ||
|
||||||
prefs.credentialStatus === QMLPrefs.CS_NOCLOUD
|
prefs.credentialStatus === SsrfPrefs.CS_NOCLOUD
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
globalDrawer.close()
|
globalDrawer.close()
|
||||||
returnTopPage() // otherwise odd things happen with the page stack
|
returnTopPage() // otherwise odd things happen with the page stack
|
||||||
|
@ -251,14 +251,14 @@ Kirigami.ApplicationWindow {
|
||||||
name: ":/icons/cloud_sync.svg"
|
name: ":/icons/cloud_sync.svg"
|
||||||
}
|
}
|
||||||
text: qsTr("Manual sync with cloud")
|
text: qsTr("Manual sync with cloud")
|
||||||
enabled: prefs.credentialStatus === QMLPrefs.CS_VERIFIED ||
|
enabled: prefs.credentialStatus === SsrfPrefs.CS_VERIFIED ||
|
||||||
prefs.credentialStatus === QMLPrefs.CS_NOCLOUD
|
prefs.credentialStatus === SsrfPrefs.CS_NOCLOUD
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
if (prefs.credentialStatus === QMLPrefs.CS_NOCLOUD) {
|
if (prefs.credentialStatus === SsrfPrefs.CS_NOCLOUD) {
|
||||||
returnTopPage()
|
returnTopPage()
|
||||||
oldStatus = prefs.credentialStatus
|
oldStatus = prefs.credentialStatus
|
||||||
manager.startPageText = "Enter valid cloud storage credentials"
|
manager.startPageText = "Enter valid cloud storage credentials"
|
||||||
prefs.credentialStatus = QMLPrefs.CS_UNKNOWN
|
prefs.credentialStatus = SsrfPrefs.CS_UNKNOWN
|
||||||
globalDrawer.close()
|
globalDrawer.close()
|
||||||
} else {
|
} else {
|
||||||
globalDrawer.close()
|
globalDrawer.close()
|
||||||
|
@ -273,7 +273,7 @@ Kirigami.ApplicationWindow {
|
||||||
name: syncToCloud ? ":/icons/ic_cloud_off.svg" : ":/icons/ic_cloud_done.svg"
|
name: syncToCloud ? ":/icons/ic_cloud_off.svg" : ":/icons/ic_cloud_done.svg"
|
||||||
}
|
}
|
||||||
text: syncToCloud ? qsTr("Disable auto cloud sync") : qsTr("Enable auto cloud sync")
|
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: {
|
onTriggered: {
|
||||||
syncToCloud = !syncToCloud
|
syncToCloud = !syncToCloud
|
||||||
if (!syncToCloud) {
|
if (!syncToCloud) {
|
||||||
|
|
|
@ -269,12 +269,12 @@ void QMLManager::openLocalThenRemote(QString url)
|
||||||
* no cloud repo solves this.
|
* no cloud repo solves this.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (QMLPrefs::instance()->credentialStatus() != QMLPrefs::CS_NOCLOUD)
|
if (QMLPrefs::instance()->credentialStatus() != qPref::CS_NOCLOUD)
|
||||||
QMLPrefs::instance()->setCredentialStatus(QMLPrefs::CS_NEED_TO_VERIFY);
|
QMLPrefs::instance()->setCredentialStatus(qPref::CS_NEED_TO_VERIFY);
|
||||||
} else {
|
} else {
|
||||||
// if we can load from the cache, we know that we have a valid cloud account
|
// if we can load from the cache, we know that we have a valid cloud account
|
||||||
if (QMLPrefs::instance()->credentialStatus() == QMLPrefs::CS_UNKNOWN)
|
if (QMLPrefs::instance()->credentialStatus() == qPref::CS_UNKNOWN)
|
||||||
QMLPrefs::instance()->setCredentialStatus(QMLPrefs::CS_VERIFIED);
|
QMLPrefs::instance()->setCredentialStatus(qPref::CS_VERIFIED);
|
||||||
prefs.unit_system = git_prefs.unit_system;
|
prefs.unit_system = git_prefs.unit_system;
|
||||||
if (git_prefs.unit_system == IMPERIAL)
|
if (git_prefs.unit_system == IMPERIAL)
|
||||||
git_prefs.units = IMPERIAL_units;
|
git_prefs.units = IMPERIAL_units;
|
||||||
|
@ -292,11 +292,11 @@ void QMLManager::openLocalThenRemote(QString url)
|
||||||
appendTextToLog(QStringLiteral("%1 dives loaded from cache").arg(dive_table.nr));
|
appendTextToLog(QStringLiteral("%1 dives loaded from cache").arg(dive_table.nr));
|
||||||
setNotificationText(tr("%1 dives loaded from local dive data file").arg(dive_table.nr));
|
setNotificationText(tr("%1 dives loaded from local dive data file").arg(dive_table.nr));
|
||||||
}
|
}
|
||||||
if (QMLPrefs::instance()->credentialStatus() == QMLPrefs::CS_NEED_TO_VERIFY) {
|
if (QMLPrefs::instance()->credentialStatus() == qPref::CS_NEED_TO_VERIFY) {
|
||||||
appendTextToLog(QStringLiteral("have cloud credentials, but still needs PIN"));
|
appendTextToLog(QStringLiteral("have cloud credentials, but still needs PIN"));
|
||||||
QMLPrefs::instance()->setShowPin(true);
|
QMLPrefs::instance()->setShowPin(true);
|
||||||
}
|
}
|
||||||
if (QMLPrefs::instance()->oldStatus() == QMLPrefs::CS_NOCLOUD) {
|
if (QMLPrefs::instance()->oldStatus() == qPref::CS_NOCLOUD) {
|
||||||
// if we switch to credentials from CS_NOCLOUD, we take things online temporarily
|
// if we switch to credentials from CS_NOCLOUD, we take things online temporarily
|
||||||
prefs.git_local_only = false;
|
prefs.git_local_only = false;
|
||||||
appendTextToLog(QStringLiteral("taking things online to be able to switch to cloud account"));
|
appendTextToLog(QStringLiteral("taking things online to be able to switch to cloud account"));
|
||||||
|
@ -373,7 +373,7 @@ void QMLManager::finishSetup()
|
||||||
QMLPrefs::instance()->setCloudUserName(prefs.cloud_storage_email);
|
QMLPrefs::instance()->setCloudUserName(prefs.cloud_storage_email);
|
||||||
QMLPrefs::instance()->setCloudPassword(prefs.cloud_storage_password);
|
QMLPrefs::instance()->setCloudPassword(prefs.cloud_storage_password);
|
||||||
setSyncToCloud(!prefs.git_local_only);
|
setSyncToCloud(!prefs.git_local_only);
|
||||||
QMLPrefs::instance()->setCredentialStatus((QMLPrefs::cloud_status) prefs.cloud_verification_status);
|
QMLPrefs::instance()->setCredentialStatus((qPref::cloud_status) prefs.cloud_verification_status);
|
||||||
// if the cloud credentials are valid, we should get the GPS Webservice ID as well
|
// if the cloud credentials are valid, we should get the GPS Webservice ID as well
|
||||||
QString url;
|
QString url;
|
||||||
if (!QMLPrefs::instance()->cloudUserName().isEmpty() &&
|
if (!QMLPrefs::instance()->cloudUserName().isEmpty() &&
|
||||||
|
@ -384,8 +384,8 @@ void QMLManager::finishSetup()
|
||||||
alreadySaving = true;
|
alreadySaving = true;
|
||||||
openLocalThenRemote(url);
|
openLocalThenRemote(url);
|
||||||
} else if (!empty_string(existing_filename) &&
|
} else if (!empty_string(existing_filename) &&
|
||||||
QMLPrefs::instance()->credentialStatus() != QMLPrefs::CS_UNKNOWN) {
|
QMLPrefs::instance()->credentialStatus() != qPref::CS_UNKNOWN) {
|
||||||
QMLPrefs::instance()->setCredentialStatus(QMLPrefs::CS_NOCLOUD);
|
QMLPrefs::instance()->setCredentialStatus(qPref::CS_NOCLOUD);
|
||||||
saveCloudCredentials();
|
saveCloudCredentials();
|
||||||
appendTextToLog(tr("working in no-cloud mode"));
|
appendTextToLog(tr("working in no-cloud mode"));
|
||||||
int error = parse_file(existing_filename);
|
int error = parse_file(existing_filename);
|
||||||
|
@ -399,7 +399,7 @@ void QMLManager::finishSetup()
|
||||||
appendTextToLog(QString("working in no-cloud mode, finished loading %1 dives from %2").arg(dive_table.nr).arg(existing_filename));
|
appendTextToLog(QString("working in no-cloud mode, finished loading %1 dives from %2").arg(dive_table.nr).arg(existing_filename));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
QMLPrefs::instance()->setCredentialStatus(QMLPrefs::CS_UNKNOWN);
|
QMLPrefs::instance()->setCredentialStatus(qPref::CS_UNKNOWN);
|
||||||
appendTextToLog(tr("no cloud credentials"));
|
appendTextToLog(tr("no cloud credentials"));
|
||||||
setStartPageText(RED_FONT + tr("Please enter valid cloud credentials.") + END_FONT);
|
setStartPageText(RED_FONT + tr("Please enter valid cloud credentials.") + END_FONT);
|
||||||
}
|
}
|
||||||
|
@ -437,7 +437,7 @@ void QMLManager::saveCloudCredentials()
|
||||||
bool cloudCredentialsChanged = false;
|
bool cloudCredentialsChanged = false;
|
||||||
// make sure we only have letters, numbers, and +-_. in password and email address
|
// make sure we only have letters, numbers, and +-_. in password and email address
|
||||||
QRegularExpression regExp("^[a-zA-Z0-9@.+_-]+$");
|
QRegularExpression regExp("^[a-zA-Z0-9@.+_-]+$");
|
||||||
if (QMLPrefs::instance()->credentialStatus() != QMLPrefs::CS_NOCLOUD) {
|
if (QMLPrefs::instance()->credentialStatus() != qPref::CS_NOCLOUD) {
|
||||||
// in case of NO_CLOUD, the email address + passwd do not care, so do not check it.
|
// in case of NO_CLOUD, the email address + passwd do not care, so do not check it.
|
||||||
if (QMLPrefs::instance()->cloudPassword().isEmpty() ||
|
if (QMLPrefs::instance()->cloudPassword().isEmpty() ||
|
||||||
!regExp.match(QMLPrefs::instance()->cloudPassword()).hasMatch() ||
|
!regExp.match(QMLPrefs::instance()->cloudPassword()).hasMatch() ||
|
||||||
|
@ -467,7 +467,7 @@ void QMLManager::saveCloudCredentials()
|
||||||
cloudCredentialsChanged |= !same_string(prefs.cloud_storage_password,
|
cloudCredentialsChanged |= !same_string(prefs.cloud_storage_password,
|
||||||
qPrintable(QMLPrefs::instance()->cloudPassword()));
|
qPrintable(QMLPrefs::instance()->cloudPassword()));
|
||||||
|
|
||||||
if (QMLPrefs::instance()->credentialStatus() != QMLPrefs::CS_NOCLOUD &&
|
if (QMLPrefs::instance()->credentialStatus() != qPref::CS_NOCLOUD &&
|
||||||
!cloudCredentialsChanged) {
|
!cloudCredentialsChanged) {
|
||||||
// just go back to the dive list
|
// just go back to the dive list
|
||||||
QMLPrefs::instance()->setCredentialStatus(QMLPrefs::instance()->oldStatus());
|
QMLPrefs::instance()->setCredentialStatus(QMLPrefs::instance()->oldStatus());
|
||||||
|
@ -478,7 +478,7 @@ void QMLManager::saveCloudCredentials()
|
||||||
free((void *)prefs.cloud_storage_password);
|
free((void *)prefs.cloud_storage_password);
|
||||||
prefs.cloud_storage_password = copy_qstring(QMLPrefs::instance()->cloudPassword());
|
prefs.cloud_storage_password = copy_qstring(QMLPrefs::instance()->cloudPassword());
|
||||||
}
|
}
|
||||||
if (QMLPrefs::instance()->oldStatus() == QMLPrefs::CS_NOCLOUD && cloudCredentialsChanged && dive_table.nr) {
|
if (QMLPrefs::instance()->oldStatus() == qPref::CS_NOCLOUD && cloudCredentialsChanged && dive_table.nr) {
|
||||||
// we came from NOCLOUD and are connecting to a cloud account;
|
// we came from NOCLOUD and are connecting to a cloud account;
|
||||||
// since we already have dives in the table, let's remember that so we can keep them
|
// since we already have dives in the table, let's remember that so we can keep them
|
||||||
noCloudToCloud = true;
|
noCloudToCloud = true;
|
||||||
|
@ -508,7 +508,7 @@ void QMLManager::saveCloudCredentials()
|
||||||
currentGitLocalOnly = prefs.git_local_only;
|
currentGitLocalOnly = prefs.git_local_only;
|
||||||
prefs.git_local_only = false;
|
prefs.git_local_only = false;
|
||||||
openLocalThenRemote(url);
|
openLocalThenRemote(url);
|
||||||
} else if (prefs.cloud_verification_status == QMLPrefs::CS_NEED_TO_VERIFY &&
|
} else if (prefs.cloud_verification_status == qPref::CS_NEED_TO_VERIFY &&
|
||||||
!QMLPrefs::instance()->cloudPin().isEmpty()) {
|
!QMLPrefs::instance()->cloudPin().isEmpty()) {
|
||||||
// the user entered a PIN?
|
// the user entered a PIN?
|
||||||
tryRetrieveDataFromBackend();
|
tryRetrieveDataFromBackend();
|
||||||
|
@ -542,12 +542,12 @@ void QMLManager::tryRetrieveDataFromBackend()
|
||||||
}
|
}
|
||||||
myTimer.stop();
|
myTimer.stop();
|
||||||
QMLPrefs::instance()->setCloudPin("");
|
QMLPrefs::instance()->setCloudPin("");
|
||||||
if (prefs.cloud_verification_status == QMLPrefs::CS_INCORRECT_USER_PASSWD) {
|
if (prefs.cloud_verification_status == qPref::CS_INCORRECT_USER_PASSWD) {
|
||||||
appendTextToLog(QStringLiteral("Incorrect cloud credentials"));
|
appendTextToLog(QStringLiteral("Incorrect cloud credentials"));
|
||||||
setStartPageText(RED_FONT + tr("Incorrect cloud credentials") + END_FONT);
|
setStartPageText(RED_FONT + tr("Incorrect cloud credentials") + END_FONT);
|
||||||
revertToNoCloudIfNeeded();
|
revertToNoCloudIfNeeded();
|
||||||
return;
|
return;
|
||||||
} else if (prefs.cloud_verification_status != QMLPrefs::CS_VERIFIED) {
|
} else if (prefs.cloud_verification_status != qPref::CS_VERIFIED) {
|
||||||
// here we need to enter the PIN
|
// here we need to enter the PIN
|
||||||
appendTextToLog(QStringLiteral("Need to verify the email address - enter PIN"));
|
appendTextToLog(QStringLiteral("Need to verify the email address - enter PIN"));
|
||||||
setStartPageText(RED_FONT + tr("Cannot connect to cloud storage - cloud account not verified") + END_FONT);
|
setStartPageText(RED_FONT + tr("Cannot connect to cloud storage - cloud account not verified") + END_FONT);
|
||||||
|
@ -578,7 +578,7 @@ void QMLManager::provideAuth(QNetworkReply *reply, QAuthenticator *auth)
|
||||||
// OK, credentials have been tried and didn't work, so they are invalid
|
// OK, credentials have been tried and didn't work, so they are invalid
|
||||||
appendTextToLog("Cloud credentials are invalid");
|
appendTextToLog("Cloud credentials are invalid");
|
||||||
setStartPageText(RED_FONT + tr("Cloud credentials are invalid") + END_FONT);
|
setStartPageText(RED_FONT + tr("Cloud credentials are invalid") + END_FONT);
|
||||||
QMLPrefs::instance()->setCredentialStatus(QMLPrefs::CS_INCORRECT_USER_PASSWD);
|
QMLPrefs::instance()->setCredentialStatus(qPref::CS_INCORRECT_USER_PASSWD);
|
||||||
reply->disconnect();
|
reply->disconnect();
|
||||||
reply->abort();
|
reply->abort();
|
||||||
reply->deleteLater();
|
reply->deleteLater();
|
||||||
|
@ -622,7 +622,7 @@ void QMLManager::retrieveUserid()
|
||||||
revertToNoCloudIfNeeded();
|
revertToNoCloudIfNeeded();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QMLPrefs::instance()->setCredentialStatus(QMLPrefs::CS_VERIFIED);
|
QMLPrefs::instance()->setCredentialStatus(qPref::CS_VERIFIED);
|
||||||
QString userid(prefs.userid);
|
QString userid(prefs.userid);
|
||||||
if (userid.isEmpty()) {
|
if (userid.isEmpty()) {
|
||||||
if (empty_string(prefs.cloud_storage_email) || empty_string(prefs.cloud_storage_password)) {
|
if (empty_string(prefs.cloud_storage_email) || empty_string(prefs.cloud_storage_password)) {
|
||||||
|
@ -641,7 +641,7 @@ void QMLManager::retrieveUserid()
|
||||||
s.setValue("subsurface_webservice_uid", prefs.userid);
|
s.setValue("subsurface_webservice_uid", prefs.userid);
|
||||||
s.sync();
|
s.sync();
|
||||||
}
|
}
|
||||||
QMLPrefs::instance()->setCredentialStatus(QMLPrefs::CS_VERIFIED);
|
QMLPrefs::instance()->setCredentialStatus(qPref::CS_VERIFIED);
|
||||||
setStartPageText(tr("Cloud credentials valid, loading dives..."));
|
setStartPageText(tr("Cloud credentials valid, loading dives..."));
|
||||||
// this only gets called with "alreadySaving" already locked
|
// this only gets called with "alreadySaving" already locked
|
||||||
loadDivesWithValidCredentials();
|
loadDivesWithValidCredentials();
|
||||||
|
@ -726,7 +726,7 @@ void QMLManager::revertToNoCloudIfNeeded()
|
||||||
currentGitLocalOnly = false;
|
currentGitLocalOnly = false;
|
||||||
prefs.git_local_only = true;
|
prefs.git_local_only = true;
|
||||||
}
|
}
|
||||||
if (QMLPrefs::instance()->oldStatus() == QMLPrefs::CS_NOCLOUD) {
|
if (QMLPrefs::instance()->oldStatus() == qPref::CS_NOCLOUD) {
|
||||||
// we tried to switch to a cloud account and had previously used local data,
|
// we tried to switch to a cloud account and had previously used local data,
|
||||||
// but connecting to the cloud account (and subsequently merging the local
|
// but connecting to the cloud account (and subsequently merging the local
|
||||||
// and cloud data) failed - so let's delete the cloud credentials and go
|
// and cloud data) failed - so let's delete the cloud credentials and go
|
||||||
|
@ -742,7 +742,7 @@ void QMLManager::revertToNoCloudIfNeeded()
|
||||||
prefs.cloud_storage_password = NULL;
|
prefs.cloud_storage_password = NULL;
|
||||||
QMLPrefs::instance()->setCloudUserName("");
|
QMLPrefs::instance()->setCloudUserName("");
|
||||||
QMLPrefs::instance()->setCloudPassword("");
|
QMLPrefs::instance()->setCloudPassword("");
|
||||||
QMLPrefs::instance()->setCredentialStatus(QMLPrefs::CS_NOCLOUD);
|
QMLPrefs::instance()->setCredentialStatus(qPref::CS_NOCLOUD);
|
||||||
set_filename(NOCLOUD_LOCALSTORAGE);
|
set_filename(NOCLOUD_LOCALSTORAGE);
|
||||||
setStartPageText(RED_FONT + tr("Failed to connect to cloud server, reverting to no cloud status") + END_FONT);
|
setStartPageText(RED_FONT + tr("Failed to connect to cloud server, reverting to no cloud status") + END_FONT);
|
||||||
}
|
}
|
||||||
|
@ -1202,7 +1202,7 @@ void QMLManager::openNoCloudRepo()
|
||||||
void QMLManager::saveChangesLocal()
|
void QMLManager::saveChangesLocal()
|
||||||
{
|
{
|
||||||
if (unsaved_changes()) {
|
if (unsaved_changes()) {
|
||||||
if (QMLPrefs::instance()->credentialStatus() == QMLPrefs::CS_NOCLOUD) {
|
if (QMLPrefs::instance()->credentialStatus() == qPref::CS_NOCLOUD) {
|
||||||
if (empty_string(existing_filename)) {
|
if (empty_string(existing_filename)) {
|
||||||
char *filename = NOCLOUD_LOCALSTORAGE;
|
char *filename = NOCLOUD_LOCALSTORAGE;
|
||||||
git_create_local_repo(filename);
|
git_create_local_repo(filename);
|
||||||
|
|
|
@ -11,10 +11,10 @@
|
||||||
QMLPrefs *QMLPrefs::m_instance = NULL;
|
QMLPrefs *QMLPrefs::m_instance = NULL;
|
||||||
|
|
||||||
QMLPrefs::QMLPrefs() :
|
QMLPrefs::QMLPrefs() :
|
||||||
m_credentialStatus(QMLPrefs::CS_UNKNOWN),
|
m_credentialStatus(qPref::CS_UNKNOWN),
|
||||||
m_developer(false),
|
m_developer(false),
|
||||||
m_distanceThreshold(1000),
|
m_distanceThreshold(1000),
|
||||||
m_oldStatus(QMLPrefs::CS_UNKNOWN),
|
m_oldStatus(qPref::CS_UNKNOWN),
|
||||||
m_showPin(false),
|
m_showPin(false),
|
||||||
m_timeThreshold(60)
|
m_timeThreshold(60)
|
||||||
{
|
{
|
||||||
|
@ -69,16 +69,16 @@ void QMLPrefs::setCloudUserName(const QString &cloudUserName)
|
||||||
emit cloudUserNameChanged();
|
emit cloudUserNameChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
QMLPrefs::cloud_status QMLPrefs::credentialStatus() const
|
qPref::cloud_status QMLPrefs::credentialStatus() const
|
||||||
{
|
{
|
||||||
return m_credentialStatus;
|
return m_credentialStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QMLPrefs::setCredentialStatus(const QMLPrefs::cloud_status value)
|
void QMLPrefs::setCredentialStatus(const qPref::cloud_status value)
|
||||||
{
|
{
|
||||||
if (m_credentialStatus != value) {
|
if (m_credentialStatus != value) {
|
||||||
setOldStatus(m_credentialStatus);
|
setOldStatus(m_credentialStatus);
|
||||||
if (value == QMLPrefs::CS_NOCLOUD) {
|
if (value == qPref::CS_NOCLOUD) {
|
||||||
QMLManager::instance()->appendTextToLog("Switching to no cloud mode");
|
QMLManager::instance()->appendTextToLog("Switching to no cloud mode");
|
||||||
set_filename(NOCLOUD_LOCALSTORAGE);
|
set_filename(NOCLOUD_LOCALSTORAGE);
|
||||||
clearCredentials();
|
clearCredentials();
|
||||||
|
@ -105,12 +105,12 @@ void QMLPrefs::setDistanceThreshold(int distance)
|
||||||
emit distanceThresholdChanged();
|
emit distanceThresholdChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
QMLPrefs::cloud_status QMLPrefs::oldStatus() const
|
qPref::cloud_status QMLPrefs::oldStatus() const
|
||||||
{
|
{
|
||||||
return m_oldStatus;
|
return m_oldStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QMLPrefs::setOldStatus(const QMLPrefs::cloud_status value)
|
void QMLPrefs::setOldStatus(const qPref::cloud_status value)
|
||||||
{
|
{
|
||||||
if (m_oldStatus != value) {
|
if (m_oldStatus != value) {
|
||||||
m_oldStatus = value;
|
m_oldStatus = value;
|
||||||
|
@ -177,7 +177,7 @@ void QMLPrefs::cancelCredentialsPinSetup()
|
||||||
*/
|
*/
|
||||||
QSettings s;
|
QSettings s;
|
||||||
|
|
||||||
setCredentialStatus(QMLPrefs::CS_UNKNOWN);
|
setCredentialStatus(qPref::CS_UNKNOWN);
|
||||||
s.beginGroup("CloudStorage");
|
s.beginGroup("CloudStorage");
|
||||||
s.setValue("email", m_cloudUserName);
|
s.setValue("email", m_cloudUserName);
|
||||||
s.setValue("password", m_cloudPassword);
|
s.setValue("password", m_cloudPassword);
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
|
|
||||||
class QMLPrefs : public QObject {
|
class QMLPrefs : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_ENUM(cloud_status)
|
|
||||||
Q_PROPERTY(QString cloudPassword
|
Q_PROPERTY(QString cloudPassword
|
||||||
MEMBER m_cloudPassword
|
MEMBER m_cloudPassword
|
||||||
WRITE setCloudPassword
|
WRITE setCloudPassword
|
||||||
|
@ -21,7 +20,7 @@ class QMLPrefs : public QObject {
|
||||||
MEMBER m_cloudUserName
|
MEMBER m_cloudUserName
|
||||||
WRITE setCloudUserName
|
WRITE setCloudUserName
|
||||||
NOTIFY cloudUserNameChanged)
|
NOTIFY cloudUserNameChanged)
|
||||||
Q_PROPERTY(cloud_status credentialStatus
|
Q_PROPERTY(qPref::cloud_status credentialStatus
|
||||||
MEMBER m_credentialStatus
|
MEMBER m_credentialStatus
|
||||||
WRITE setCredentialStatus
|
WRITE setCredentialStatus
|
||||||
NOTIFY credentialStatusChanged)
|
NOTIFY credentialStatusChanged)
|
||||||
|
@ -37,7 +36,7 @@ class QMLPrefs : public QObject {
|
||||||
MEMBER m_showPin
|
MEMBER m_showPin
|
||||||
WRITE setShowPin
|
WRITE setShowPin
|
||||||
NOTIFY showPinChanged)
|
NOTIFY showPinChanged)
|
||||||
Q_PROPERTY(cloud_status oldStatus
|
Q_PROPERTY(qPref::cloud_status oldStatus
|
||||||
MEMBER m_oldStatus
|
MEMBER m_oldStatus
|
||||||
WRITE setOldStatus
|
WRITE setOldStatus
|
||||||
NOTIFY oldStatusChanged)
|
NOTIFY oldStatusChanged)
|
||||||
|
@ -51,14 +50,6 @@ class QMLPrefs : public QObject {
|
||||||
NOTIFY timeThresholdChanged)
|
NOTIFY timeThresholdChanged)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum cloud_status {
|
|
||||||
CS_UNKNOWN,
|
|
||||||
CS_INCORRECT_USER_PASSWD,
|
|
||||||
CS_NEED_TO_VERIFY,
|
|
||||||
CS_VERIFIED,
|
|
||||||
CS_NOCLOUD
|
|
||||||
};
|
|
||||||
|
|
||||||
QMLPrefs();
|
QMLPrefs();
|
||||||
~QMLPrefs();
|
~QMLPrefs();
|
||||||
|
|
||||||
|
@ -73,16 +64,16 @@ public:
|
||||||
const QString cloudUserName() const;
|
const QString cloudUserName() const;
|
||||||
void setCloudUserName(const QString &cloudUserName);
|
void setCloudUserName(const QString &cloudUserName);
|
||||||
|
|
||||||
cloud_status credentialStatus() const;
|
qPref::cloud_status credentialStatus() const;
|
||||||
void setCredentialStatus(const cloud_status value);
|
void setCredentialStatus(const qPref::cloud_status value);
|
||||||
|
|
||||||
void setDeveloper(bool value);
|
void setDeveloper(bool value);
|
||||||
|
|
||||||
int distanceThreshold() const;
|
int distanceThreshold() const;
|
||||||
void setDistanceThreshold(int distance);
|
void setDistanceThreshold(int distance);
|
||||||
|
|
||||||
cloud_status oldStatus() const;
|
qPref::cloud_status oldStatus() const;
|
||||||
void setOldStatus(const cloud_status value);
|
void setOldStatus(const qPref::cloud_status value);
|
||||||
|
|
||||||
bool showPin() const;
|
bool showPin() const;
|
||||||
void setShowPin(bool enable);
|
void setShowPin(bool enable);
|
||||||
|
@ -101,11 +92,11 @@ private:
|
||||||
QString m_cloudPassword;
|
QString m_cloudPassword;
|
||||||
QString m_cloudPin;
|
QString m_cloudPin;
|
||||||
QString m_cloudUserName;
|
QString m_cloudUserName;
|
||||||
cloud_status m_credentialStatus;
|
qPref::cloud_status m_credentialStatus;
|
||||||
bool m_developer;
|
bool m_developer;
|
||||||
int m_distanceThreshold;
|
int m_distanceThreshold;
|
||||||
static QMLPrefs *m_instance;
|
static QMLPrefs *m_instance;
|
||||||
cloud_status m_oldStatus;
|
qPref::cloud_status m_oldStatus;
|
||||||
bool m_showPin;
|
bool m_showPin;
|
||||||
int m_timeThreshold;
|
int m_timeThreshold;
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
#include "qt-models/messagehandlermodel.h"
|
#include "qt-models/messagehandlermodel.h"
|
||||||
#include "map-widget/qmlmapwidgethelper.h"
|
#include "map-widget/qmlmapwidgethelper.h"
|
||||||
#include "qt-models/maplocationmodel.h"
|
#include "qt-models/maplocationmodel.h"
|
||||||
|
#include "core/settings/qPref.h"
|
||||||
|
|
||||||
#include "mobile-widgets/qml/kirigami/src/kirigamiplugin.h"
|
#include "mobile-widgets/qml/kirigami/src/kirigamiplugin.h"
|
||||||
|
|
||||||
|
@ -55,6 +56,7 @@ void init_ui()
|
||||||
void run_ui()
|
void run_ui()
|
||||||
{
|
{
|
||||||
LOG_STP("run_ui starting");
|
LOG_STP("run_ui starting");
|
||||||
|
qmlRegisterType<qPref>("org.subsurfacedivelog.mobile", 1, 0, "SsrfPrefs");
|
||||||
qmlRegisterType<QMLManager>("org.subsurfacedivelog.mobile", 1, 0, "QMLManager");
|
qmlRegisterType<QMLManager>("org.subsurfacedivelog.mobile", 1, 0, "QMLManager");
|
||||||
qmlRegisterType<QMLPrefs>("org.subsurfacedivelog.mobile", 1, 0, "QMLPrefs");
|
qmlRegisterType<QMLPrefs>("org.subsurfacedivelog.mobile", 1, 0, "QMLPrefs");
|
||||||
qmlRegisterType<QMLProfile>("org.subsurfacedivelog.mobile", 1, 0, "QMLProfile");
|
qmlRegisterType<QMLProfile>("org.subsurfacedivelog.mobile", 1, 0, "QMLProfile");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue