diff options
-rw-r--r-- | qt-mobile/Preferences.qml | 2 | ||||
-rw-r--r-- | qt-mobile/qmlmanager.cpp | 26 | ||||
-rw-r--r-- | qt-mobile/qmlmanager.h | 6 |
3 files changed, 30 insertions, 4 deletions
diff --git a/qt-mobile/Preferences.qml b/qt-mobile/Preferences.qml index f03ab8a02..8f4a15328 100644 --- a/qt-mobile/Preferences.qml +++ b/qt-mobile/Preferences.qml @@ -50,6 +50,7 @@ Item { } CheckBox { + checked: manager.saveCloudPassword id: savePassword } @@ -63,6 +64,7 @@ Item { onClicked: { manager.cloudUserName = login.text manager.cloudPassword = password.text + manager.saveCloudPassword = savePassword.checked manager.savePreferences() stackView.pop() } diff --git a/qt-mobile/qmlmanager.cpp b/qt-mobile/qmlmanager.cpp index a1c64191b..8cefbe95f 100644 --- a/qt-mobile/qmlmanager.cpp +++ b/qt-mobile/qmlmanager.cpp @@ -20,6 +20,7 @@ QMLManager::QMLManager() //Initialize cloud credentials. setCloudUserName(prefs.cloud_storage_email); setCloudPassword(prefs.cloud_storage_password); + setSaveCloudPassword(prefs.save_password_local); } QMLManager::~QMLManager() @@ -31,15 +32,22 @@ void QMLManager::savePreferences() QSettings s; s.beginGroup("CloudStorage"); s.setValue("email", cloudUserName()); - s.setValue("password", cloudPassword()); + s.setValue("save_password_local", saveCloudPassword()); + if (saveCloudPassword()) + s.setValue("password", cloudPassword()); s.sync(); if (!same_string(prefs.cloud_storage_email, qPrintable(cloudUserName()))) { free(prefs.cloud_storage_email); prefs.cloud_storage_email = strdup(qPrintable(cloudUserName())); } - if (!same_string(prefs.cloud_storage_password, qPrintable(cloudPassword()))) { - free(prefs.cloud_storage_password); - prefs.cloud_storage_password = strdup(qPrintable(cloudPassword())); + if (saveCloudPassword() != prefs.save_password_local) { + prefs.save_password_local = saveCloudPassword(); + } + if (saveCloudPassword()) { + if (!same_string(prefs.cloud_storage_password, qPrintable(cloudPassword()))) { + free(prefs.cloud_storage_password); + prefs.cloud_storage_password = strdup(qPrintable(cloudPassword())); + } } } @@ -114,6 +122,16 @@ void QMLManager::saveChanges() set_filename(fileName.toUtf8().data(), true); mark_divelist_changed(false); } +bool QMLManager::saveCloudPassword() const +{ + return m_saveCloudPassword; +} + +void QMLManager::setSaveCloudPassword(bool saveCloudPassword) +{ + m_saveCloudPassword = saveCloudPassword; +} + QString QMLManager::cloudPassword() const { diff --git a/qt-mobile/qmlmanager.h b/qt-mobile/qmlmanager.h index 2f5ac2894..0f1df2b59 100644 --- a/qt-mobile/qmlmanager.h +++ b/qt-mobile/qmlmanager.h @@ -9,6 +9,7 @@ class QMLManager : public QObject Q_OBJECT Q_PROPERTY(QString cloudUserName READ cloudUserName WRITE setCloudUserName NOTIFY cloudUserNameChanged) Q_PROPERTY(QString cloudPassword READ cloudPassword WRITE setCloudPassword NOTIFY cloudPasswordChanged) + Q_PROPERTY(bool saveCloudPassword READ saveCloudPassword WRITE setSaveCloudPassword NOTIFY saveCloudPasswordChanged) public: QMLManager(); ~QMLManager(); @@ -19,6 +20,9 @@ public: QString cloudPassword() const; void setCloudPassword(const QString &cloudPassword); + bool saveCloudPassword() const; + void setSaveCloudPassword(bool saveCloudPassword); + public slots: void savePreferences(); void loadDives(); @@ -27,10 +31,12 @@ public slots: private: QString m_cloudUserName; QString m_cloudPassword; + bool m_saveCloudPassword; signals: void cloudUserNameChanged(); void cloudPasswordChanged(); + void saveCloudPasswordChanged(); }; #endif |