From 334099951ab350de3e690ca238370d2696dc98f3 Mon Sep 17 00:00:00 2001 From: jan Iversen Date: Thu, 2 Aug 2018 19:35:04 +0200 Subject: [PATCH] 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 --- core/settings/qPrefPrivate.h | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) 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);