blob: 6650c111b7a6e6df02692589307f5f0fd36771e8 (
plain)
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
|
#pragma once
// qt
#include <QMutex>
#include <QVariant>
// goodies
#include "g_property.h"
#define INI_SINGLETON(type) IniSingleton<type>::get()
template <class T> class IniSingleton
{
public:
static T get()
{
static QMutex mtx;
QMutexLocker l(&mtx);
auto variant =
GlobalSettings::instance()->value(T::staticMetaObject.className());
qDebug() << "classname" << T::staticMetaObject.className();
qDebug() << "VARIANT" << variant;
return T(variant);
}
static void set(const T& value)
{
static QMutex mtx;
QMutexLocker l(&mtx);
GlobalSettings::instance()->setValue(
T::staticMetaObject.className(),
QVariant(value)
);
GlobalSettings::instance()->sync();
}
static void cleanup()
{
static QMutex mtx;
QMutexLocker l(&mtx);
GlobalSettings::instance()->setValue(
T::staticMetaObject.className(),
QVariant()
);
GlobalSettings::instance()->sync();
}
};
|