summaryrefslogtreecommitdiffstats
path: root/core/settings/qPref_private.h
blob: 96a3b1e5ee181990110eeb953739073fb3591b11 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
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