-
Notifications
You must be signed in to change notification settings - Fork 0
/
settings.cpp
90 lines (76 loc) · 2.28 KB
/
settings.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#include "settings.h"
Settings::Settings() {
qSettings = new QSettings("randcp2.ini",QSettings::IniFormat);
keys[OUTDIR] = "outdir";
keys[SRCDIR] = "srcdir";
keys[SRCPATH] = "srcpath";
keys[DIR_TREE] = "withoutdirtree";
keys[EN_EXTFILTER] = "enextfilter";
keys[EXTFILTER] = "extfilter";
keys[EN_IGNOREFILTER] = "enignorefilter";
keys[IGNOREFILTER] = "ignorefilter";
keys[MODE] = "mode";
keys[EN_MAXFILECOUNT] = "enablemaxfilecount";
keys[MAXFILECOUNT] = "maxfilecount";
keys[EN_MINFREESPACE] = "enminfreespace";
keys[MINFREESPACE] = "minfreespace";
keys[EN_LIMIT] = "enlimit";
keys[SIZE_LIMIT] = "limit";
keys[EN_MAXDST] = "enmaxdst";
keys[MAXDST] = "maxdst";
}
Settings::~Settings() {
qSettings->deleteLater();
}
bool Settings::getBool(int index) {
QString key = keys[index];
return qSettings->value(key).toBool();
}
double Settings::getDouble(int index) {
QString key = keys[index];
return qSettings->value(key).toDouble();
}
int Settings::getInt(int index) {
return getInt(index, 0);
}
int Settings::getInt(int index, int defaultValue) {
QString key = keys[index];
return qSettings->value(key, defaultValue).toInt();
}
QString Settings::getOutputDir() {
QString outDir = qSettings->value(keys[OUTDIR]).toString();
#ifdef Q_OS_WIN
if (outDir.length() == 3 and outDir[1] == ':')
outDir.remove(2,1);
#endif
return outDir;
}
QString Settings::getString(int index) {
QString key = keys[index];
return qSettings->value(key).toString();
}
void Settings::setBool(int index, bool value) {
QString key = keys[index];
qSettings->setValue(key, value);
}
void Settings::setDouble(int index, double value) {
QString key = keys[index];
qSettings->setValue(key, value);
}
void Settings::setInt(int index, int value) {
QString key = keys[index];
qSettings->setValue(key, value);
}
void Settings::setString(int index, QString value) {
QString key = keys[index];
qSettings->setValue(key, value);
}
void Settings::sync() {
qSettings->sync();
}
void Settings::setMode(bool mode) {
if (mode)
setInt(MODE, SHUFFLE_MODE);
else
setInt(MODE, SYNCHRONIZE_MODE);
}