blob: f2218540d7482afc44c1e8b8ec5f55e4e01a4074 (
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
/**
* Copyright (c) 2012 Nokia Corporation.
* All rights reserved.
*
* For the applicable distribution terms see the license text file included in
* the distribution.
*/
#include "settings.h"
#include <QtCore/QSettings>
#include <QDebug>
#include <QGuiApplication>
/*!
\class Settings
\brief This class loads and stores settings used by client application.
*/
/*!
Constructor.
*/
Settings::Settings(QObject *parent)
: QObject(parent)
{
}
/*!
Copy constructor.
Not used.
*/
Settings::Settings(const Settings &settings)
: QObject(0)
{
Q_UNUSED(settings)
}
/*!
Stores the setting as a key value pair.
*/
void Settings::setSetting(const QString &setting, const QVariant &value)
{
QSettings settings;
settings.setValue(setting, value);
//qDebug() << "changed setting: " << setting << "to value: " << value;
emit settingChanged(setting, value);
}
/*!
Loads the setting by key. Returns value or the default value if no setting is found.
*/
QVariant Settings::setting(const QString &setting, const QVariant &defaultValue)
{
QSettings settings;
//qDebug() << "returning settings value: " << settings.value(setting);
return settings.value(setting, defaultValue);
}
/*!
Loads the setting by key. Returns value.
*/
QVariant Settings::setting(const QString &setting)
{
QSettings settings;
//qDebug() << "returning settings value: " << settings.value(setting);
return settings.value(setting);
}
/*!
Removes the setting by key. Returns true, if setting removed
successfully. Otherwise false.
*/
bool Settings::removeSetting(const QString &setting)
{
QSettings settings;
if (!settings.contains(setting)) {
return false;
}
settings.remove(setting);
return true;
}
/*!
Removes all settings.
*/
void Settings::clear()
{
QSettings settings;
settings.clear();
}
|