diff options
Diffstat (limited to 'core/settings')
-rw-r--r-- | core/settings/qPref.cpp | 18 | ||||
-rw-r--r-- | core/settings/qPref.h | 25 | ||||
-rw-r--r-- | core/settings/qPref_private.h | 72 |
3 files changed, 115 insertions, 0 deletions
diff --git a/core/settings/qPref.cpp b/core/settings/qPref.cpp new file mode 100644 index 000000000..b703c1fcb --- /dev/null +++ b/core/settings/qPref.cpp @@ -0,0 +1,18 @@ +// SPDX-License-Identifier: GPL-2.0 +#include "qPref_private.h" +#include "qPref.h" + + +qPref *qPref::m_instance = NULL; +qPref *qPref::instance() +{ + if (!m_instance) + m_instance = new qPref; + return m_instance; +} + + + +void qPref::loadSync(bool doSync) +{ +} diff --git a/core/settings/qPref.h b/core/settings/qPref.h new file mode 100644 index 000000000..4170e5e64 --- /dev/null +++ b/core/settings/qPref.h @@ -0,0 +1,25 @@ +// SPDX-License-Identifier: GPL-2.0 +#ifndef QPREF_H +#define QPREF_H + +#include <QObject> +#include "core/pref.h" + +class qPref : public QObject { + Q_OBJECT + +public: + qPref(QObject *parent = NULL) : QObject(parent) {}; + ~qPref() {}; + static qPref *instance(); + + // Load/Sync local settings (disk) and struct preference + void loadSync(bool doSync); + +public: + +private: + static qPref *m_instance; +}; + +#endif diff --git a/core/settings/qPref_private.h b/core/settings/qPref_private.h new file mode 100644 index 000000000..96a3b1e5e --- /dev/null +++ b/core/settings/qPref_private.h @@ -0,0 +1,72 @@ +// SPDX-License-Identifier: GPL-2.0 +#ifndef QPREFPRIVATE_H +#define QPREFPRIVATE_H + +// Header used by all qPref<class> implementations to avoid duplicating code + +#include <QObject> +#include <QSettings> +#include <QVariant> +#include "core/qthelper.h" + +#define COPY_TXT(name, string) \ +{ \ + free((void *)prefs.name); \ + prefs.name = copy_qstring(string); \ +} + +#define LOADSYNC_INT(name, field) \ +{ \ + QSettings s; \ + if (doSync) \ + s.setValue(group + name, prefs.field); \ + else \ + prefs.field = s.value(group + name, default_prefs.field).toInt(); \ +} + +#define LOADSYNC_INT_DEF(name, field, defval) \ +{ \ + QSettings s; \ + if (doSync) \ + s.setValue(group + name, prefs.field); \ + else \ + prefs.field = s.value(group + name, defval).toInt(); \ +} + +#define LOADSYNC_ENUM(name, type, field) \ +{ \ + QSettings s; \ + if (doSync) \ + s.setValue(group + name, prefs.field); \ + else \ + prefs.field = (enum type)s.value(group + name, default_prefs.field).toInt(); \ +} + +#define LOADSYNC_BOOL(name, field) \ +{ \ + QSettings s; \ + if (doSync) \ + s.setValue(group + name, prefs.field); \ + else \ + prefs.field = s.value(group + name, default_prefs.field).toBool(); \ +} + +#define LOADSYNC_DOUBLE(name, field) \ +{ \ + QSettings s; \ + if (doSync) \ + s.setValue(group + name, prefs.field); \ + else \ + prefs.field = s.value(group + name, default_prefs.field).toDouble(); \ +} + +#define LOADSYNC_TXT(name, field) \ +{ \ + QSettings s; \ + if (doSync) \ + s.setValue(group + name, prefs.field); \ + else \ + prefs.field = copy_qstring(s.value(group + name, default_prefs.field).toString()); \ +} + +#endif |