-
Notifications
You must be signed in to change notification settings - Fork 1
/
settings.cpp
53 lines (39 loc) · 1.56 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
#include "settings.h"
#include "cheatshconstants.h"
#include <QDebug>
#include <QSettings>
#include <tuple>
namespace CheatSh {
namespace Internal {
void Settings::save(QSettings* settings) const
{
settings->beginGroup((Constants::SETTINGS_GROUP));
settings->setValue(Constants::CHT_CONTEXT, context);
settings->setValue(Constants::CHT_URL, url);
settings->setValue(Constants::CHT_COMMENTS, comments_enabled);
settings->setValue(Constants::CHT_CHECK_UPDATES, check_updates);
settings->setValue(Constants::CHT_LAST_CHECK_DATE, last_check_date);
settings->endGroup();
settings->sync();
}
void Settings::load(QSettings* settings)
{
settings->beginGroup((Constants::SETTINGS_GROUP));
context = settings->value(Constants::CHT_CONTEXT, Constants::CHT_DEFAULT_CONTEXT).toString();
url = settings->value(Constants::CHT_URL, Constants::CHT_DEFAULT_URL).toUrl();
comments_enabled = settings->value(Constants::CHT_COMMENTS, true).toBool();
check_updates = settings->value(Constants::CHT_CHECK_UPDATES, true).toBool();
last_check_date = settings->value(Constants::CHT_LAST_CHECK_DATE, QDate(2000, 1, 1)).toDate();
settings->endGroup();
}
bool operator ==(Settings& lhs, Settings& rhs)
{
return std::tie(lhs.context, lhs.url, lhs.comments_enabled, lhs.check_updates, lhs.last_check_date) ==
std::tie(rhs.context, rhs.url, rhs.comments_enabled, rhs.check_updates, rhs.last_check_date);
}
bool operator !=(Settings& lhs, Settings& rhs)
{
return ! operator==(lhs, rhs);
}
} // namespace Internal
} // namespace CheatSh