-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathexphoneconfig.cpp
67 lines (56 loc) · 1.33 KB
/
exphoneconfig.cpp
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
#include "exphoneconfig.h"
#include <QCoreApplication>
#ifdef MER_EDITION_SAILFISH
#include <MDConfGroup>
#endif
#include <functional>
ExphoneConfig::ExphoneConfig(QObject *parent)
: QObject(parent)
#ifdef MER_EDITION_SAILFISH
, m_group(new MDConfGroup(QStringLiteral("/com/github/jmlich/exphone"), this))
#endif
{
}
ExphoneConfig *ExphoneConfig::instance()
{
static ExphoneConfig *inst = nullptr;
if (!inst) {
inst = new ExphoneConfig(qApp);
}
return inst;
}
QVariant ExphoneConfig::value(const QString &key, const QVariant &def) const
{
#ifdef MER_EDITION_SAILFISH
return m_group->value(key, def);
#else
QSettings settings;
return settings.value(key, def);
#endif
}
void ExphoneConfig::setValue(const QString &key, const QVariant &value)
{
#ifdef MER_EDITION_SAILFISH
m_group->setValue(key, value);
#else
QSettings settings;
settings.setValue(key, value);
#endif
}
void ExphoneConfig::setValue(const QString &key, const QVariant &value, signal_ptr signal)
{
#ifdef MER_EDITION_SAILFISH
auto prev = m_group->value(key);
#else
QSettings settings;
auto prev = settings.value(key);
#endif
if (value != prev) {
#ifdef MER_EDITION_SAILFISH
m_group->setValue(key, value);
#else
settings.setValue(key, value);
#endif
emit std::bind(signal, this)();
}
}