-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathuconfig.cpp
More file actions
50 lines (44 loc) · 854 Bytes
/
Copy pathuconfig.cpp
File metadata and controls
50 lines (44 loc) · 854 Bytes
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
#include <QMutex>
#include <QSettings>
#include "uconfig.h"
uConfig::uConfig() :
m_settings(0)
{
}
uConfig::~uConfig()
{
if (m_settings) delete m_settings;
}
void uConfig::createConfig(const QString &path)
{
if (m_settings != 0)
{
delete m_settings;
m_settings = 0;
}
m_settings = new QSettings(path, QSettings::IniFormat);
}
QVariant uConfig::value(const QString &name, const QVariant &value)
{
if (m_settings != 0)
{
return m_settings->value(name, value);
}
return value;
}
bool uConfig::contains(const QString &name)
{
if (m_settings != 0)
{
return m_settings->contains(name);
}
return false;
}
uConfig &uConfig::getInstance()
{
static QMutex mutex;
QMutexLocker lock(&mutex);
Q_UNUSED(lock);
static uConfig instance;
return instance;
}