summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorGravatar jan Iversen <jani@apache.org>2018-07-18 22:52:13 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2018-07-25 08:35:04 -0700
commit92ade62260c30be55632047fa97332b2d2d97a8f (patch)
treeda7b01b2a9928b70337d91e76769a9ad91c3a000 /core
parent3eae683b57d225c680a430c83db1425c38765742 (diff)
downloadsubsurface-92ade62260c30be55632047fa97332b2d2d97a8f.tar.gz
core: remove LOADSYNC* macros
expend LOADSYNC* into DISK_* macros remove LOADSYNC* from qPrefPrivate.h update qPrefDisplay to not use LOADSYNC* Signed-off-by: Jan Iversen <jani@apache.org>
Diffstat (limited to 'core')
-rw-r--r--core/settings/qPrefCloudStorage.cpp22
-rw-r--r--core/settings/qPrefDisplay.cpp8
-rw-r--r--core/settings/qPrefPrivate.h59
3 files changed, 33 insertions, 56 deletions
diff --git a/core/settings/qPrefCloudStorage.cpp b/core/settings/qPrefCloudStorage.cpp
index c77484233..0eccb616c 100644
--- a/core/settings/qPrefCloudStorage.cpp
+++ b/core/settings/qPrefCloudStorage.cpp
@@ -31,6 +31,7 @@ void qPrefCloudStorage::loadSync(bool doSync)
void qPrefCloudStorage::set_cloud_base_url(const QString& value)
{
+ QString valueGit = value + "/git";
if (value != prefs.cloud_base_url) {
// only free and set if not default
if (prefs.cloud_base_url != default_prefs.cloud_base_url) {
@@ -39,14 +40,12 @@ void qPrefCloudStorage::set_cloud_base_url(const QString& value)
}
disk_cloud_base_url(true);
+ disk_cloud_git_url(true);
emit cloud_base_url_changed(value);
+ emit cloud_git_url_changed(valueGit);
}
}
-void qPrefCloudStorage::disk_cloud_base_url(bool doSync)
-{
- LOADSYNC_TXT("/cloud_base_url", cloud_base_url);
- LOADSYNC_TXT("/cloud_git_url", cloud_git_url);
-}
+DISK_LOADSYNC_TXT(CloudStorage, "/cloud_base_url", cloud_base_url)
void qPrefCloudStorage::set_cloud_git_url(const QString& value)
{
@@ -86,8 +85,12 @@ void qPrefCloudStorage::set_cloud_storage_password(const QString& value)
}
void qPrefCloudStorage::disk_cloud_storage_password(bool doSync)
{
- if (!doSync || prefs.save_password_local)
- LOADSYNC_TXT("/password", cloud_storage_password);
+ if (doSync) {
+ if (prefs.save_password_local)
+ qPrefPrivate::instance()->setting.setValue(group + "/password", prefs.cloud_storage_password);
+ } else {
+ prefs.cloud_storage_password = copy_qstring(qPrefPrivate::instance()->setting.value(group + "/password", default_prefs.cloud_storage_password).toString());
+ }
}
HANDLE_PREFERENCE_TXT(CloudStorage, "/pin", cloud_storage_pin);
@@ -107,5 +110,8 @@ void qPrefCloudStorage::disk_userid(bool doSync)
{
//WARNING: UserId is stored outside of any group, but it belongs to Cloud Storage.
const QString group = QStringLiteral("");
- LOADSYNC_TXT("subsurface_webservice_uid", userid);
+ if (doSync)
+ qPrefPrivate::instance()->setting.setValue(group + "subsurface_webservice_uid", prefs.userid);
+ else
+ prefs.userid = copy_qstring(qPrefPrivate::instance()->setting.value(group + "subsurface_webservice_uid", default_prefs.userid).toString());
}
diff --git a/core/settings/qPrefDisplay.cpp b/core/settings/qPrefDisplay.cpp
index 1579569bf..cf08af8cd 100644
--- a/core/settings/qPrefDisplay.cpp
+++ b/core/settings/qPrefDisplay.cpp
@@ -44,7 +44,7 @@ void qPrefDisplay::set_divelist_font(const QString& value)
void qPrefDisplay::disk_divelist_font(bool doSync)
{
if (doSync)
- LOADSYNC_TXT("/divelist_font", divelist_font)
+ qPrefPrivate::instance()->setting.setValue(group + "/divelist_font", prefs.divelist_font);
else
setCorrectFont();
}
@@ -64,7 +64,7 @@ void qPrefDisplay::set_font_size(double value)
void qPrefDisplay::disk_font_size(bool doSync)
{
if (doSync)
- LOADSYNC_DOUBLE("/font_size", font_size)
+ qPrefPrivate::instance()->setting.setValue(group + "/font_size", prefs.font_size);
else
setCorrectFont();
}
@@ -78,7 +78,6 @@ HANDLE_PREFERENCE_TXT(Display, "/theme", theme);
void qPrefDisplay::setCorrectFont()
{
- bool doSync = false;
QSettings s;
QVariant v;
@@ -103,5 +102,6 @@ void qPrefDisplay::setCorrectFont()
}
defaultFont.setPointSizeF(prefs.font_size);
qApp->setFont(defaultFont);
- LOADSYNC_BOOL("/displayinvalid", display_invalid_dives);
+
+ prefs.display_invalid_dives = qPrefPrivate::instance()->setting.value(group + "/displayinvalid", default_prefs.display_invalid_dives).toBool();
}
diff --git a/core/settings/qPrefPrivate.h b/core/settings/qPrefPrivate.h
index 681627d4f..29cb9028c 100644
--- a/core/settings/qPrefPrivate.h
+++ b/core/settings/qPrefPrivate.h
@@ -29,8 +29,11 @@ private:
qPrefPrivate(QObject *parent = NULL);
};
-//****** Macros to be used in the disk functions, which are special ******
-#define LOADSYNC_BOOL(name, field) \
+
+
+//******* Macros to generate disk function
+#define DISK_LOADSYNC_BOOL(usegroup, name, field) \
+void qPref ## usegroup::disk_ ## field(bool doSync) \
{ \
if (doSync) \
qPrefPrivate::instance()->setting.setValue(group + name, prefs.field); \
@@ -38,7 +41,8 @@ private:
prefs.field = qPrefPrivate::instance()->setting.value(group + name, default_prefs.field).toBool(); \
}
-#define LOADSYNC_DOUBLE(name, field) \
+#define DISK_LOADSYNC_DOUBLE(usegroup, name, field) \
+void qPref ## usegroup::disk_ ## field(bool doSync) \
{ \
if (doSync) \
qPrefPrivate::instance()->setting.setValue(group + name, prefs.field); \
@@ -46,7 +50,8 @@ private:
prefs.field = qPrefPrivate::instance()->setting.value(group + name, default_prefs.field).toDouble(); \
}
-#define LOADSYNC_ENUM(name, type, field) \
+#define DISK_LOADSYNC_ENUM(usegroup, name, type, field) \
+void qPref ## usegroup::disk_ ## field(bool doSync) \
{ \
if (doSync) \
qPrefPrivate::instance()->setting.setValue(group + name, prefs.field); \
@@ -54,7 +59,8 @@ private:
prefs.field = (enum type)qPrefPrivate::instance()->setting.value(group + name, default_prefs.field).toInt(); \
}
-#define LOADSYNC_INT(name, field) \
+#define DISK_LOADSYNC_INT(usegroup, name, field) \
+void qPref ## usegroup::disk_ ## field(bool doSync) \
{ \
if (doSync) \
qPrefPrivate::instance()->setting.setValue(group + name, prefs.field); \
@@ -62,7 +68,8 @@ private:
prefs.field = qPrefPrivate::instance()->setting.value(group + name, default_prefs.field).toInt(); \
}
-#define LOADSYNC_INT_DEF(name, field, defval) \
+#define DISK_LOADSYNC_INT_DEF(usegroup, name, field, defval) \
+void qPref ## usegroup::disk_ ## field(bool doSync) \
{ \
if (doSync) \
qPrefPrivate::instance()->setting.setValue(group + name, prefs.field); \
@@ -70,7 +77,8 @@ private:
prefs.field = qPrefPrivate::instance()->setting.value(group + name, defval).toInt(); \
}
-#define LOADSYNC_TXT(name, field) \
+#define DISK_LOADSYNC_TXT(usegroup, name, field) \
+void qPref ## usegroup::disk_ ## field(bool doSync) \
{ \
if (doSync) \
qPrefPrivate::instance()->setting.setValue(group + name, prefs.field); \
@@ -78,43 +86,6 @@ private:
prefs.field = copy_qstring(qPrefPrivate::instance()->setting.value(group + name, default_prefs.field).toString()); \
}
-//******* Macros to generate disk function
-#define DISK_LOADSYNC_BOOL(usegroup, name, field) \
-void qPref ## usegroup::disk_ ## field(bool doSync) \
-{ \
- LOADSYNC_BOOL(name, field); \
-}
-
-#define DISK_LOADSYNC_DOUBLE(usegroup, name, field) \
-void qPref ## usegroup::disk_ ## field(bool doSync) \
-{ \
- LOADSYNC_DOUBLE(name, field); \
-}
-
-#define DISK_LOADSYNC_ENUM(usegroup, name, type, field) \
-void qPref ## usegroup::disk_ ## field(bool doSync) \
-{ \
- LOADSYNC_ENUM(name, type, field); \
-}
-
-#define DISK_LOADSYNC_INT(usegroup, name, field) \
-void qPref ## usegroup::disk_ ## field(bool doSync) \
-{ \
- LOADSYNC_INT(name, field); \
-}
-
-#define DISK_LOADSYNC_INT_DEF(usegroup, name, field, defval) \
-void qPref ## usegroup::disk_ ## field(bool doSync) \
-{ \
- LOADSYNC_INT_DEF(name, field, defval); \
-}
-
-#define DISK_LOADSYNC_TXT(usegroup, name, field) \
-void qPref ## usegroup::disk_ ## field(bool doSync) \
-{ \
- LOADSYNC_TXT(name, field); \
-}
-
//******* Macros to generate set function
#define SET_PREFERENCE_BOOL(usegroup, field) \
void qPref ## usegroup::set_ ## field (bool value) \