2018-06-16 14:03:31 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
|
|
|
#ifndef QPREFPRIVATE_H
|
|
|
|
#define QPREFPRIVATE_H
|
|
|
|
|
|
|
|
// Header used by all qPref<class> implementations to avoid duplicating code
|
2018-07-25 17:49:48 +00:00
|
|
|
#include "core/qthelper.h"
|
2018-07-18 18:58:13 +00:00
|
|
|
#include "qPref.h"
|
2018-07-25 17:49:48 +00:00
|
|
|
#include <QObject>
|
2018-06-16 14:03:31 +00:00
|
|
|
#include <QVariant>
|
|
|
|
|
2018-07-17 13:22:51 +00:00
|
|
|
// implementation class of the interface classes
|
2018-08-15 11:26:09 +00:00
|
|
|
class qPrefPrivate {
|
2018-07-17 13:22:51 +00:00
|
|
|
|
|
|
|
public:
|
2018-07-18 18:47:59 +00:00
|
|
|
// Helper functions
|
2018-07-25 17:49:48 +00:00
|
|
|
static void copy_txt(const char **name, const QString &string);
|
2018-07-18 18:47:59 +00:00
|
|
|
|
2018-09-06 22:15:19 +00:00
|
|
|
static void propSetValue(const QString &key, const QVariant &value, const QVariant &defaultValue);
|
2018-08-15 11:26:09 +00:00
|
|
|
static QVariant propValue(const QString &key, const QVariant &defaultValue);
|
|
|
|
|
|
|
|
private:
|
|
|
|
qPrefPrivate() {}
|
2018-07-17 13:22:51 +00:00
|
|
|
};
|
|
|
|
|
2018-09-07 16:06:00 +00:00
|
|
|
// helper function to ensure there's a '/' between group and name
|
|
|
|
extern QString keyFromGroupAndName(QString group, QString name);
|
2018-07-18 20:52:13 +00:00
|
|
|
|
|
|
|
//******* Macros to generate disk function
|
2018-08-17 18:51:03 +00:00
|
|
|
#define DISK_LOADSYNC_BOOL_EXT(usegroup, name, field, usestruct) \
|
|
|
|
void qPref##usegroup::disk_##field(bool doSync) \
|
|
|
|
{ \
|
2018-09-07 18:13:12 +00:00
|
|
|
static bool current_state; \
|
|
|
|
if (doSync) { \
|
|
|
|
if (current_state != prefs.usestruct field) { \
|
|
|
|
current_state = prefs.usestruct field; \
|
|
|
|
qPrefPrivate::propSetValue(keyFromGroupAndName(group, name), prefs.usestruct field, default_prefs.usestruct field); \
|
|
|
|
} \
|
|
|
|
} else { \
|
2018-09-07 16:06:00 +00:00
|
|
|
prefs.usestruct field = qPrefPrivate::propValue(keyFromGroupAndName(group, name), default_prefs.usestruct field).toBool(); \
|
2018-09-07 18:13:12 +00:00
|
|
|
current_state = prefs.usestruct field; \
|
|
|
|
} \
|
2018-07-25 17:49:48 +00:00
|
|
|
}
|
2018-07-22 13:30:07 +00:00
|
|
|
#define DISK_LOADSYNC_BOOL(usegroup, name, field) \
|
2018-07-25 17:49:48 +00:00
|
|
|
DISK_LOADSYNC_BOOL_EXT(usegroup, name, field, )
|
|
|
|
|
2018-08-17 18:51:03 +00:00
|
|
|
#define DISK_LOADSYNC_DOUBLE_EXT(usegroup, name, field, usestruct) \
|
|
|
|
void qPref##usegroup::disk_##field(bool doSync) \
|
|
|
|
{ \
|
2018-09-07 18:13:12 +00:00
|
|
|
static double current_state; \
|
|
|
|
if (doSync) { \
|
|
|
|
if (current_state != prefs.usestruct field) { \
|
|
|
|
current_state = prefs.usestruct field; \
|
|
|
|
qPrefPrivate::propSetValue(keyFromGroupAndName(group, name), prefs.usestruct field, default_prefs.usestruct field); \
|
|
|
|
} \
|
|
|
|
} else { \
|
2018-09-07 16:06:00 +00:00
|
|
|
prefs.usestruct field = qPrefPrivate::propValue(keyFromGroupAndName(group, name), default_prefs.usestruct field).toDouble(); \
|
2018-09-07 18:13:12 +00:00
|
|
|
current_state = prefs.usestruct field; \
|
|
|
|
} \
|
2018-07-25 17:49:48 +00:00
|
|
|
}
|
2018-07-22 13:30:07 +00:00
|
|
|
#define DISK_LOADSYNC_DOUBLE(usegroup, name, field) \
|
2018-07-25 17:49:48 +00:00
|
|
|
DISK_LOADSYNC_DOUBLE_EXT(usegroup, name, field, )
|
|
|
|
|
2018-08-17 18:51:03 +00:00
|
|
|
#define DISK_LOADSYNC_ENUM_EXT(usegroup, name, type, field, usestruct) \
|
|
|
|
void qPref##usegroup::disk_##field(bool doSync) \
|
|
|
|
{ \
|
2018-09-07 18:13:12 +00:00
|
|
|
static enum type current_state; \
|
|
|
|
if (doSync) { \
|
|
|
|
if (current_state != prefs.usestruct field) { \
|
|
|
|
current_state = prefs.usestruct field; \
|
|
|
|
qPrefPrivate::propSetValue(keyFromGroupAndName(group, name), prefs.usestruct field, default_prefs.usestruct field); \
|
|
|
|
} \
|
|
|
|
} else { \
|
2018-09-07 16:06:00 +00:00
|
|
|
prefs.usestruct field = (enum type)qPrefPrivate::propValue(keyFromGroupAndName(group, name), default_prefs.usestruct field).toInt(); \
|
2018-09-07 18:13:12 +00:00
|
|
|
current_state = prefs.usestruct field; \
|
|
|
|
} \
|
2018-07-25 17:49:48 +00:00
|
|
|
}
|
2018-07-22 13:30:07 +00:00
|
|
|
#define DISK_LOADSYNC_ENUM(usegroup, name, type, field) \
|
2018-07-25 17:49:48 +00:00
|
|
|
DISK_LOADSYNC_ENUM_EXT(usegroup, name, type, field, )
|
|
|
|
|
2018-08-17 18:51:03 +00:00
|
|
|
#define DISK_LOADSYNC_INT_EXT(usegroup, name, field, usestruct) \
|
|
|
|
void qPref##usegroup::disk_##field(bool doSync) \
|
|
|
|
{ \
|
2018-09-07 18:13:12 +00:00
|
|
|
static int current_state; \
|
|
|
|
if (doSync) { \
|
|
|
|
if (current_state != prefs.usestruct field) { \
|
|
|
|
current_state = prefs.usestruct field; \
|
|
|
|
qPrefPrivate::propSetValue(keyFromGroupAndName(group, name), prefs.usestruct field, default_prefs.usestruct field); \
|
|
|
|
} \
|
|
|
|
} else { \
|
2018-09-07 16:06:00 +00:00
|
|
|
prefs.usestruct field = qPrefPrivate::propValue(keyFromGroupAndName(group, name), default_prefs.usestruct field).toInt(); \
|
2018-09-07 18:13:12 +00:00
|
|
|
current_state = prefs.usestruct field; \
|
|
|
|
} \
|
2018-07-25 17:49:48 +00:00
|
|
|
}
|
2018-07-22 13:30:07 +00:00
|
|
|
#define DISK_LOADSYNC_INT(usegroup, name, field) \
|
2018-07-27 18:35:48 +00:00
|
|
|
DISK_LOADSYNC_INT_EXT(usegroup, name, field, )
|
2018-07-25 17:49:48 +00:00
|
|
|
|
2018-08-17 18:51:03 +00:00
|
|
|
#define DISK_LOADSYNC_INT_DEF_EXT(usegroup, name, field, defval, usestruct) \
|
|
|
|
void qPref##usegroup::disk_##field(bool doSync) \
|
|
|
|
{ \
|
2018-09-07 18:13:12 +00:00
|
|
|
static int current_state; \
|
|
|
|
if (doSync) { \
|
|
|
|
if (current_state != prefs.usestruct field) { \
|
|
|
|
current_state = prefs.usestruct field; \
|
|
|
|
qPrefPrivate::propSetValue(keyFromGroupAndName(group, name), prefs.usestruct field, default_prefs.usestruct field); \
|
|
|
|
} \
|
|
|
|
} else { \
|
2018-09-07 16:06:00 +00:00
|
|
|
prefs.usestruct field = qPrefPrivate::propValue(keyFromGroupAndName(group, name), defval).toInt(); \
|
2018-09-07 18:13:12 +00:00
|
|
|
current_state = prefs.usestruct field; \
|
|
|
|
} \
|
2018-07-25 17:49:48 +00:00
|
|
|
}
|
2018-07-22 13:30:07 +00:00
|
|
|
#define DISK_LOADSYNC_INT_DEF(usegroup, name, field, defval) \
|
2018-07-25 17:49:48 +00:00
|
|
|
DISK_LOADSYNC_INT_DEF_EXT(usegroup, name, field, defval, )
|
|
|
|
|
2018-08-17 18:51:03 +00:00
|
|
|
#define DISK_LOADSYNC_STRUCT_EXT(usegroup, name, field, var, usestruct) \
|
|
|
|
void qPref##usegroup::disk_##field(bool doSync) \
|
|
|
|
{ \
|
2018-09-07 18:13:12 +00:00
|
|
|
static int current_state; \
|
|
|
|
if (doSync) { \
|
|
|
|
if (current_state != prefs.usestruct field . var) { \
|
|
|
|
current_state = prefs.usestruct field . var; \
|
|
|
|
qPrefPrivate::propSetValue(keyFromGroupAndName(group, name), prefs.usestruct field . var, default_prefs.usestruct field . var); \
|
|
|
|
} \
|
|
|
|
} else { \
|
2018-09-07 16:06:00 +00:00
|
|
|
prefs.usestruct field . var = qPrefPrivate::propValue(keyFromGroupAndName(group, name), default_prefs.usestruct field . var).toInt(); \
|
2018-09-07 18:13:12 +00:00
|
|
|
current_state = prefs.usestruct field . var; \
|
|
|
|
} \
|
2018-08-02 17:35:04 +00:00
|
|
|
}
|
|
|
|
#define DISK_LOADSYNC_STRUCT(usegroup, name, field, var) \
|
|
|
|
DISK_LOADSYNC_STRUCT_EXT(usegroup, name, field, var, )
|
|
|
|
|
2018-08-17 18:51:03 +00:00
|
|
|
#define DISK_LOADSYNC_TXT_EXT(usegroup, name, field, usestruct) \
|
|
|
|
void qPref##usegroup::disk_##field(bool doSync) \
|
|
|
|
{ \
|
2018-09-07 18:13:12 +00:00
|
|
|
static QString current_state; \
|
|
|
|
if (doSync) { \
|
|
|
|
if (current_state != QString(prefs.usestruct field)) { \
|
|
|
|
current_state = QString(prefs.usestruct field); \
|
|
|
|
qPrefPrivate::propSetValue(keyFromGroupAndName(group, name), prefs.usestruct field, default_prefs.usestruct field); \
|
|
|
|
} \
|
|
|
|
} else { \
|
2018-09-07 16:06:00 +00:00
|
|
|
prefs.usestruct field = copy_qstring(qPrefPrivate::propValue(keyFromGroupAndName(group, name), default_prefs.usestruct field).toString()); \
|
2018-09-07 18:13:12 +00:00
|
|
|
current_state = QString(prefs.usestruct field); \
|
|
|
|
} \
|
2018-07-25 17:49:48 +00:00
|
|
|
}
|
2018-07-22 13:30:07 +00:00
|
|
|
#define DISK_LOADSYNC_TXT(usegroup, name, field) \
|
2018-07-25 17:49:48 +00:00
|
|
|
DISK_LOADSYNC_TXT_EXT(usegroup, name, field, )
|
2018-06-16 14:03:31 +00:00
|
|
|
|
2018-07-02 07:25:20 +00:00
|
|
|
//******* Macros to generate set function
|
2018-07-22 13:30:07 +00:00
|
|
|
#define SET_PREFERENCE_BOOL_EXT(usegroup, field, usestruct) \
|
2018-08-17 18:51:03 +00:00
|
|
|
void qPref##usegroup::set_##field(bool value) \
|
|
|
|
{ \
|
|
|
|
if (value != prefs.usestruct field) { \
|
|
|
|
prefs.usestruct field = value; \
|
|
|
|
disk_##field(true); \
|
|
|
|
emit qPref##usegroup::instance()->field##_changed(value); \
|
|
|
|
} \
|
2018-07-25 17:49:48 +00:00
|
|
|
}
|
2018-07-22 13:30:07 +00:00
|
|
|
#define SET_PREFERENCE_BOOL(usegroup, field) \
|
2018-07-25 17:49:48 +00:00
|
|
|
SET_PREFERENCE_BOOL_EXT(usegroup, field, )
|
2018-07-02 07:25:20 +00:00
|
|
|
|
2018-07-22 13:30:07 +00:00
|
|
|
#define SET_PREFERENCE_DOUBLE_EXT(usegroup, field, usestruct) \
|
2018-08-17 18:51:03 +00:00
|
|
|
void qPref##usegroup::set_##field(double value) \
|
|
|
|
{ \
|
|
|
|
if (value != prefs.usestruct field) { \
|
|
|
|
prefs.usestruct field = value; \
|
|
|
|
disk_##field(true); \
|
|
|
|
emit qPref##usegroup::instance()->field##_changed(value); \
|
|
|
|
} \
|
2018-07-25 17:49:48 +00:00
|
|
|
}
|
2018-07-22 13:30:07 +00:00
|
|
|
#define SET_PREFERENCE_DOUBLE(usegroup, field) \
|
2018-07-25 17:49:48 +00:00
|
|
|
SET_PREFERENCE_DOUBLE_EXT(usegroup, field, )
|
2018-07-02 07:25:20 +00:00
|
|
|
|
2018-07-22 13:30:07 +00:00
|
|
|
#define SET_PREFERENCE_ENUM_EXT(usegroup, type, field, usestruct) \
|
2018-08-17 18:51:03 +00:00
|
|
|
void qPref##usegroup::set_##field(type value) \
|
|
|
|
{ \
|
|
|
|
if (value != prefs.usestruct field) { \
|
|
|
|
prefs.usestruct field = value; \
|
|
|
|
disk_##field(true); \
|
|
|
|
emit qPref##usegroup::instance()->field##_changed(value); \
|
|
|
|
} \
|
2018-07-25 17:49:48 +00:00
|
|
|
}
|
2018-07-22 13:30:07 +00:00
|
|
|
#define SET_PREFERENCE_ENUM(usegroup, type, field) \
|
2018-07-25 17:49:48 +00:00
|
|
|
SET_PREFERENCE_ENUM_EXT(usegroup, type, field, )
|
2018-07-02 07:25:20 +00:00
|
|
|
|
2018-07-22 13:30:07 +00:00
|
|
|
#define SET_PREFERENCE_INT_EXT(usegroup, field, usestruct) \
|
2018-08-17 18:51:03 +00:00
|
|
|
void qPref##usegroup::set_##field(int value) \
|
|
|
|
{ \
|
|
|
|
if (value != prefs.usestruct field) { \
|
|
|
|
prefs.usestruct field = value; \
|
|
|
|
disk_##field(true); \
|
|
|
|
emit qPref##usegroup::instance()->field##_changed(value); \
|
|
|
|
} \
|
2018-07-25 17:49:48 +00:00
|
|
|
}
|
2018-07-22 13:30:07 +00:00
|
|
|
#define SET_PREFERENCE_INT(usegroup, field) \
|
2018-07-25 17:49:48 +00:00
|
|
|
SET_PREFERENCE_INT_EXT(usegroup, field, )
|
|
|
|
|
2018-08-02 17:35:04 +00:00
|
|
|
#define SET_PREFERENCE_STRUCT_EXT(usegroup, type, field, var, usestruct) \
|
2018-08-17 18:51:03 +00:00
|
|
|
void qPref##usegroup::set_##field(type value) \
|
|
|
|
{ \
|
|
|
|
if (value. var != prefs.usestruct field . var) { \
|
|
|
|
prefs.usestruct field . var = value . var; \
|
|
|
|
disk_##field(true); \
|
|
|
|
emit qPref##usegroup::instance()->field##_changed(value); \
|
|
|
|
} \
|
2018-08-02 17:35:04 +00:00
|
|
|
}
|
|
|
|
#define SET_PREFERENCE_STRUCT(usegroup, type, field, var) \
|
|
|
|
SET_PREFERENCE_STRUCT_EXT(usegroup, type, field, var, )
|
|
|
|
|
2018-08-17 18:51:03 +00:00
|
|
|
#define SET_PREFERENCE_TXT_EXT(usegroup, field, usestruct) \
|
|
|
|
void qPref##usegroup::set_##field(const QString &value) \
|
|
|
|
{ \
|
|
|
|
if (value != prefs.usestruct field) { \
|
2018-08-15 11:26:09 +00:00
|
|
|
qPrefPrivate::copy_txt(&prefs.usestruct field, value); \
|
2018-08-17 18:51:03 +00:00
|
|
|
disk_##field(true); \
|
|
|
|
emit qPref##usegroup::instance()->field##_changed(value); \
|
|
|
|
} \
|
2018-07-25 17:49:48 +00:00
|
|
|
}
|
2018-07-22 13:30:07 +00:00
|
|
|
#define SET_PREFERENCE_TXT(usegroup, field) \
|
2018-07-25 17:49:48 +00:00
|
|
|
SET_PREFERENCE_TXT_EXT(usegroup, field, )
|
2018-07-04 12:13:48 +00:00
|
|
|
|
|
|
|
//******* Macros to generate set/set/loadsync combined
|
2018-07-22 13:30:07 +00:00
|
|
|
#define HANDLE_PREFERENCE_BOOL_EXT(usegroup, name, field, usestruct) \
|
2018-08-17 18:51:03 +00:00
|
|
|
SET_PREFERENCE_BOOL_EXT(usegroup, field, usestruct); \
|
2018-07-25 17:49:48 +00:00
|
|
|
DISK_LOADSYNC_BOOL_EXT(usegroup, name, field, usestruct);
|
2018-07-04 12:13:48 +00:00
|
|
|
#define HANDLE_PREFERENCE_BOOL(usegroup, name, field) \
|
2018-07-25 17:49:48 +00:00
|
|
|
HANDLE_PREFERENCE_BOOL_EXT(usegroup, name, field, )
|
2018-07-04 12:13:48 +00:00
|
|
|
|
2018-07-22 13:30:07 +00:00
|
|
|
#define HANDLE_PREFERENCE_DOUBLE_EXT(usegroup, name, field, usestruct) \
|
2018-08-17 18:51:03 +00:00
|
|
|
SET_PREFERENCE_DOUBLE_EXT(usegroup, field, usestruct); \
|
2018-07-25 17:49:48 +00:00
|
|
|
DISK_LOADSYNC_DOUBLE_EXT(usegroup, name, field, usestruct);
|
2018-07-04 12:13:48 +00:00
|
|
|
#define HANDLE_PREFERENCE_DOUBLE(usegroup, name, field) \
|
2018-07-25 17:49:48 +00:00
|
|
|
HANDLE_PREFERENCE_DOUBLE_EXT(usegroup, name, field, )
|
2018-07-04 12:13:48 +00:00
|
|
|
|
2018-07-22 13:30:07 +00:00
|
|
|
#define HANDLE_PREFERENCE_ENUM_EXT(usegroup, type, name, field, usestruct) \
|
2018-08-17 18:51:03 +00:00
|
|
|
SET_PREFERENCE_ENUM_EXT(usegroup, type, field, usestruct); \
|
2018-07-25 17:49:48 +00:00
|
|
|
DISK_LOADSYNC_ENUM_EXT(usegroup, name, type, field, usestruct);
|
2018-07-04 12:13:48 +00:00
|
|
|
#define HANDLE_PREFERENCE_ENUM(usegroup, type, name, field) \
|
2018-07-25 17:49:48 +00:00
|
|
|
HANDLE_PREFERENCE_ENUM_EXT(usegroup, type, name, field, )
|
2018-07-04 12:13:48 +00:00
|
|
|
|
2018-07-22 13:30:07 +00:00
|
|
|
#define HANDLE_PREFERENCE_INT_EXT(usegroup, name, field, usestruct) \
|
2018-08-17 18:51:03 +00:00
|
|
|
SET_PREFERENCE_INT_EXT(usegroup, field, usestruct); \
|
2018-07-25 17:49:48 +00:00
|
|
|
DISK_LOADSYNC_INT_EXT(usegroup, name, field, usestruct);
|
2018-07-04 12:13:48 +00:00
|
|
|
#define HANDLE_PREFERENCE_INT(usegroup, name, field) \
|
2018-07-25 17:49:48 +00:00
|
|
|
HANDLE_PREFERENCE_INT_EXT(usegroup, name, field, )
|
2018-07-04 12:13:48 +00:00
|
|
|
|
2018-07-27 18:35:48 +00:00
|
|
|
#define HANDLE_PREFERENCE_INT_DEF_EXT(usegroup, name, field, defval, usestruct) \
|
2018-08-17 18:51:03 +00:00
|
|
|
SET_PREFERENCE_INT_EXT(usegroup, field, usestruct); \
|
2018-07-27 18:35:48 +00:00
|
|
|
DISK_LOADSYNC_INT_DEF_EXT(usegroup, name, field, defval, usestruct);
|
|
|
|
#define HANDLE_PREFERENCE_INT_DEF(usegroup, name, field, defval) \
|
|
|
|
HANDLE_PREFERENCE_INT_DEF_EXT(usegroup, name, field, defval, )
|
|
|
|
|
2018-08-02 17:35:04 +00:00
|
|
|
#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, )
|
|
|
|
|
2018-07-22 13:30:07 +00:00
|
|
|
#define HANDLE_PREFERENCE_TXT_EXT(usegroup, name, field, usestruct) \
|
2018-08-17 18:51:03 +00:00
|
|
|
SET_PREFERENCE_TXT_EXT(usegroup, field, usestruct); \
|
2018-07-25 17:49:48 +00:00
|
|
|
DISK_LOADSYNC_TXT_EXT(usegroup, name, field, usestruct);
|
2018-07-04 12:13:48 +00:00
|
|
|
#define HANDLE_PREFERENCE_TXT(usegroup, name, field) \
|
2018-07-25 17:49:48 +00:00
|
|
|
HANDLE_PREFERENCE_TXT_EXT(usegroup, name, field, )
|
2018-07-04 12:13:48 +00:00
|
|
|
|
2018-08-17 20:08:52 +00:00
|
|
|
#define HANDLE_PROP_QPOINTF(useclass, name, field) \
|
|
|
|
void qPref##useclass::set_##field(const QPointF& value) \
|
|
|
|
{ \
|
|
|
|
if (value != st_##field) { \
|
|
|
|
st_##field = value; \
|
2018-09-06 22:15:19 +00:00
|
|
|
qPrefPrivate::propSetValue(name, st_##field, QPointF()); \
|
2018-08-17 20:08:52 +00:00
|
|
|
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; \
|
2018-09-06 22:15:19 +00:00
|
|
|
qPrefPrivate::propSetValue(name, st_##field, ""); \
|
2018-08-17 20:08:52 +00:00
|
|
|
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; \
|
2018-09-06 22:15:19 +00:00
|
|
|
qPrefPrivate::propSetValue(name, st_##field, false); \
|
2018-08-17 20:08:52 +00:00
|
|
|
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; \
|
2018-09-06 22:15:19 +00:00
|
|
|
qPrefPrivate::propSetValue(name, st_##field, 0.0); \
|
2018-08-17 20:08:52 +00:00
|
|
|
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; \
|
2018-09-06 22:15:19 +00:00
|
|
|
qPrefPrivate::propSetValue(name, st_##field, 0); \
|
2018-08-17 20:08:52 +00:00
|
|
|
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; \
|
2018-09-06 22:15:19 +00:00
|
|
|
qPrefPrivate::propSetValue(name, st_##field, QByteArray()); \
|
2018-08-17 20:08:52 +00:00
|
|
|
emit qPref##useclass::instance()->field##_changed(value); \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
void qPref##useclass::load_##field() \
|
|
|
|
{ \
|
|
|
|
st_##field = qPrefPrivate::propValue(name, st_##field##_default).toByteArray(); \
|
|
|
|
}
|
2018-06-16 14:03:31 +00:00
|
|
|
#endif
|