summaryrefslogtreecommitdiffstats
path: root/core/settings/qPrefPrivate.h
diff options
context:
space:
mode:
authorGravatar jan Iversen <jani@apache.org>2018-08-02 19:35:04 +0200
committerGravatar Robert C. Helling <helling@atdotde.de>2018-08-08 14:29:50 +0200
commit334099951ab350de3e690ca238370d2696dc98f3 (patch)
treef00f818657db0492829b034d36c7808827f15e86 /core/settings/qPrefPrivate.h
parenta12588ad8219e8b24fe52044d46a8b35c1d2fd73 (diff)
downloadsubsurface-334099951ab350de3e690ca238370d2696dc98f3.tar.gz
core: qPref add STRUCT macro
In order to solve use of e.g. depth_t a new macro is added Signed-off-by: Jan Iversen <jani@apache.org>
Diffstat (limited to 'core/settings/qPrefPrivate.h')
-rw-r--r--core/settings/qPrefPrivate.h29
1 files changed, 29 insertions, 0 deletions
diff --git a/core/settings/qPrefPrivate.h b/core/settings/qPrefPrivate.h
index 5ef60fbc8..5e18e7126 100644
--- a/core/settings/qPrefPrivate.h
+++ b/core/settings/qPrefPrivate.h
@@ -90,6 +90,17 @@ private:
#define DISK_LOADSYNC_INT_DEF(usegroup, name, field, defval) \
DISK_LOADSYNC_INT_DEF_EXT(usegroup, name, field, defval, )
+#define DISK_LOADSYNC_STRUCT_EXT(usegroup, name, field, var, usestruct) \
+ void qPref##usegroup::disk_##field(bool doSync) \
+ { \
+ if (doSync) \
+ qPrefPrivate::instance()->setting.setValue(group + name, prefs.usestruct field . var); \
+ else \
+ prefs.usestruct field . var = qPrefPrivate::instance()->setting.value(group + name, default_prefs.usestruct field . var).toInt(); \
+ }
+#define DISK_LOADSYNC_STRUCT(usegroup, name, field, var) \
+ DISK_LOADSYNC_STRUCT_EXT(usegroup, name, field, var, )
+
#define DISK_LOADSYNC_TXT_EXT(usegroup, name, field, usestruct) \
void qPref##usegroup::disk_##field(bool doSync) \
{ \
@@ -150,6 +161,18 @@ private:
#define SET_PREFERENCE_INT(usegroup, field) \
SET_PREFERENCE_INT_EXT(usegroup, field, )
+#define SET_PREFERENCE_STRUCT_EXT(usegroup, type, field, var, usestruct) \
+ void qPref##usegroup::set_##field(type value) \
+ { \
+ if (value. var != prefs.usestruct field . var) { \
+ prefs.usestruct field . var = value . var; \
+ disk_##field(true); \
+ emit field##_changed(value); \
+ } \
+ }
+#define SET_PREFERENCE_STRUCT(usegroup, type, field, var) \
+ SET_PREFERENCE_STRUCT_EXT(usegroup, type, field, var, )
+
#define SET_PREFERENCE_TXT_EXT(usegroup, field, usestruct) \
void qPref##usegroup::set_##field(const QString &value) \
{ \
@@ -193,6 +216,12 @@ private:
#define HANDLE_PREFERENCE_INT_DEF(usegroup, name, field, defval) \
HANDLE_PREFERENCE_INT_DEF_EXT(usegroup, name, field, defval, )
+#define HANDLE_PREFERENCE_STRUCT_EXT(usegroup, type, name, field, var, usestruct) \
+ SET_PREFERENCE_STRUCT_EXT(usegroup, type, field, var, usestruct) \
+ DISK_LOADSYNC_STRUCT_EXT(usegroup, name, field, var, usestruct)
+#define HANDLE_PREFERENCE_STRUCT(usegroup, type, name, field, var) \
+ HANDLE_PREFERENCE_STRUCT_EXT(usegroup, type, name, field, var, )
+
#define HANDLE_PREFERENCE_TXT_EXT(usegroup, name, field, usestruct) \
SET_PREFERENCE_TXT_EXT(usegroup, field, usestruct); \
DISK_LOADSYNC_TXT_EXT(usegroup, name, field, usestruct);