diff options
author | jan Iversen <jani@apache.org> | 2018-08-17 22:08:52 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2018-08-25 11:49:47 -0700 |
commit | be9c47954cbed040c15d6f3d9441e463dc5433a5 (patch) | |
tree | b1c7bb0951b533a180695627317fa58440b0a189 | |
parent | 69f21d9aedcea8713cf5af6463ebacba5832162e (diff) | |
download | subsurface-be9c47954cbed040c15d6f3d9441e463dc5433a5.tar.gz |
core: qPrivate add handle macros for class variables
Some variables are not in structure prefs, but are static class
variables, these will not be synced on exit, because they can only
be changed through the setter, but loaded on startup.
Signed-off-by: Jan Iversen <jani@apache.org>
-rw-r--r-- | core/settings/qPrefPrivate.h | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/core/settings/qPrefPrivate.h b/core/settings/qPrefPrivate.h index 3242b5fdc..e3376a3a2 100644 --- a/core/settings/qPrefPrivate.h +++ b/core/settings/qPrefPrivate.h @@ -217,4 +217,87 @@ private: #define HANDLE_PREFERENCE_TXT(usegroup, name, field) \ HANDLE_PREFERENCE_TXT_EXT(usegroup, name, field, ) +#define HANDLE_PROP_QPOINTF(useclass, name, field) \ + void qPref##useclass::set_##field(const QPointF& value) \ + { \ + if (value != st_##field) { \ + st_##field = value; \ + qPrefPrivate::propSetValue(name, st_##field); \ + emit qPref##useclass::instance()->field##_changed(value); \ + } \ + } \ + void qPref##useclass::load_##field() \ + { \ + st_##field = qPrefPrivate::propValue(name, st_##field##_default).toPointF(); \ + } + +#define HANDLE_PROP_QSTRING(useclass, name, field) \ + void qPref##useclass::set_##field(const QString& value) \ + { \ + if (value != st_##field) { \ + st_##field = value; \ + qPrefPrivate::propSetValue(name, st_##field); \ + emit qPref##useclass::instance()->field##_changed(value); \ + } \ + } \ + void qPref##useclass::load_##field() \ + { \ + st_##field = qPrefPrivate::propValue(name, st_##field##_default).toString(); \ + } + +#define HANDLE_PROP_BOOL(useclass, name, field) \ + void qPref##useclass::set_##field(bool value) \ + { \ + if (value != st_##field) { \ + st_##field = value; \ + qPrefPrivate::propSetValue(name, st_##field); \ + emit qPref##useclass::instance()->field##_changed(value); \ + } \ + } \ + void qPref##useclass::load_##field() \ + { \ + st_##field = qPrefPrivate::propValue(name, st_##field##_default).toBool(); \ + } + +#define HANDLE_PROP_DOUBLE(useclass, name, field) \ + void qPref##useclass::set_##field(double value) \ + { \ + if (value != st_##field) { \ + st_##field = value; \ + qPrefPrivate::propSetValue(name, st_##field); \ + emit qPref##useclass::instance()->field##_changed(value); \ + } \ + } \ + void qPref##useclass::load_##field() \ + { \ + st_##field = qPrefPrivate::propValue(name, st_##field##_default).toDouble(); \ + } + +#define HANDLE_PROP_INT(useclass, name, field) \ + void qPref##useclass::set_##field(int value) \ + { \ + if (value != st_##field) { \ + st_##field = value; \ + qPrefPrivate::propSetValue(name, st_##field); \ + emit qPref##useclass::instance()->field##_changed(value); \ + } \ + } \ + void qPref##useclass::load_##field() \ + { \ + st_##field = qPrefPrivate::propValue(name, st_##field##_default).toInt(); \ + } + +#define HANDLE_PROP_QBYTEARRAY(useclass, name, field) \ + void qPref##useclass::set_##field(const QByteArray& value) \ + { \ + if (value != st_##field) { \ + st_##field = value; \ + qPrefPrivate::propSetValue(name, st_##field); \ + emit qPref##useclass::instance()->field##_changed(value); \ + } \ + } \ + void qPref##useclass::load_##field() \ + { \ + st_##field = qPrefPrivate::propValue(name, st_##field##_default).toByteArray(); \ + } #endif |