core/settings: extend qPrefCloudStorage with diveshare uid/private

Add diveshare/uid and diveshare/private to qPrefCloudStorage
to be used in Export.qml as well as diveshareexportdialog

Extending qPrefCloudStorage is more logical than adding QSettings
(and securing the same behaviour) outside qPref.

Signed-off-by: Jan Iversen <jan@casacondor.com>
This commit is contained in:
jan Iversen 2019-12-08 13:27:03 +01:00 committed by Dirk Hohndel
parent 2949ea0fd9
commit 0a01072deb
2 changed files with 29 additions and 0 deletions

View file

@ -77,3 +77,24 @@ HANDLE_PREFERENCE_INT(CloudStorage, "timeout", cloud_timeout);
HANDLE_PREFERENCE_INT(CloudStorage, "cloud_verification_status", cloud_verification_status);
HANDLE_PREFERENCE_BOOL(CloudStorage, "save_password_local", save_password_local);
QString qPrefCloudStorage::diveshare_uid()
{
return qPrefPrivate::propValue(keyFromGroupAndName("", "diveshareExport/uid"), "").toString();
}
void qPrefCloudStorage::set_diveshare_uid(const QString &value)
{
qPrefPrivate::propSetValue(keyFromGroupAndName("", "diveshareExport/uid"), value, "");
emit instance()->diveshare_uidChanged(value);
}
bool qPrefCloudStorage::diveshare_private()
{
return qPrefPrivate::propValue(keyFromGroupAndName("", "diveshareExport/private"), "").toBool();
}
void qPrefCloudStorage::set_diveshare_private(bool value)
{
qPrefPrivate::propSetValue(keyFromGroupAndName("", "diveshareExport/private"), value, false);
emit instance()->diveshare_privateChanged(value);
}

View file

@ -17,6 +17,8 @@ class qPrefCloudStorage : public QObject {
Q_PROPERTY(int cloud_verification_status READ cloud_verification_status WRITE set_cloud_verification_status NOTIFY cloud_verification_statusChanged)
Q_PROPERTY(int cloud_timeout READ cloud_timeout WRITE set_cloud_timeout NOTIFY cloud_timeoutChanged)
Q_PROPERTY(bool save_password_local READ save_password_local WRITE set_save_password_local NOTIFY save_password_localChanged)
Q_PROPERTY(QString diveshare_userid READ diveshare_uid WRITE set_diveshare_uid NOTIFY diveshare_uidChanged);
Q_PROPERTY(bool diveshare_private READ diveshare_private WRITE set_diveshare_private NOTIFY diveshare_privateChanged);
public:
static qPrefCloudStorage *instance();
@ -46,6 +48,8 @@ public:
static int cloud_timeout() { return prefs.cloud_timeout; }
static int cloud_verification_status() { return prefs.cloud_verification_status; }
static bool save_password_local() { return prefs.save_password_local; }
static QString diveshare_uid();
static bool diveshare_private();
public slots:
static void set_cloud_auto_sync(bool value);
@ -57,6 +61,8 @@ public slots:
static void set_cloud_timeout(int value);
static void set_cloud_verification_status(int value);
static void set_save_password_local(bool value);
static void set_diveshare_uid(const QString &value);
static void set_diveshare_private(bool value);
signals:
void cloud_auto_syncChanged(bool value);
@ -68,6 +74,8 @@ signals:
void cloud_timeoutChanged(int value);
void cloud_verification_statusChanged(int value);
void save_password_localChanged(bool value);
void diveshare_uidChanged(const QString &value);
void diveshare_privateChanged(bool value);
private:
qPrefCloudStorage() {}