-
Notifications
You must be signed in to change notification settings - Fork 0
/
settings.cpp
48 lines (41 loc) · 1.89 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
#include "settings.h"
Settings::Settings()
{
}
array<bool, 4> Settings::loadSettings(){
QSettings settings("ExampleCompany", "LogAnonymizer");
settings.beginGroup("SettingsDialog");
notFirstRun = settings.value(QString::fromStdString(enumToString(FirstRun))).toBool();
hideAbsPaths = settings.value(QString::fromStdString(enumToString(AbsolutePaths))).toBool();
hideIps = settings.value(QString::fromStdString(enumToString(IpAddresses))).toBool();
hideMacs = settings.value(QString::fromStdString(enumToString(MacAddresses))).toBool();
boolSettings[0] = notFirstRun;
boolSettings[1] = hideAbsPaths;
boolSettings[2] = hideIps;
boolSettings[3] = hideMacs;
qDebug("Loading settings:");
qDebug("Is not first run : %d", notFirstRun);
qDebug("Annonymize Abs. Paths : %d, IPs %d, MACs : %d \n", hideAbsPaths, hideIps, hideMacs);
settings.endGroup();
return boolSettings;
}
void Settings::saveSettings(bool firstRun, bool hideAbsPath, bool hideIps, bool hideMacs){
QSettings settings("ExampleCompany", "LogAnonymizer");
settings.beginGroup("SettingsDialog");
settings.setValue(QString::fromStdString(enumToString(FirstRun)), firstRun);
settings.setValue(QString::fromStdString(enumToString(AbsolutePaths)), hideAbsPath);
settings.setValue(QString::fromStdString(enumToString(IpAddresses)), hideIps);
settings.setValue(QString::fromStdString(enumToString(MacAddresses)), hideMacs);
qDebug("Saving settings:");
qDebug("Annonymize Abs. Paths : %d, IPs : %d , MACs : %d \n", hideAbsPath, hideIps, hideMacs);
settings.endGroup();
}
string Settings::enumToString(SettingKeys key){
switch(key){
case FirstRun: return "first-run";
case AbsolutePaths: return "hide-abs-paths";
case IpAddresses: return "hide-ip-addresses";
case MacAddresses: return "hide-mac-addresses";
default: return "invalid key";
}
}