-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfigmanager.cpp
More file actions
39 lines (32 loc) · 861 Bytes
/
configmanager.cpp
File metadata and controls
39 lines (32 loc) · 861 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
#include "configmanager.h"
#include "localization.h"
ConfigManager::ConfigManager(QObject *parent)
: QObject(parent)
{
settings = new QSettings("config.ini", QSettings::IniFormat, this);
}
ConfigManager::~ConfigManager()
{
delete settings;
}
int ConfigManager::getGold() const
{
return settings->value("Gold", 0).toInt();
}
void ConfigManager::addGold(int gold){
int initialGold = getGold();
int finalGold = initialGold + gold;
setGold(finalGold);
}
void ConfigManager::setGold(int gold)
{
settings->setValue("Gold", gold);
}
QString ConfigManager::getLanguage() const
{
return Localization::normalizeLanguageCode(settings->value("Language", "zh-CN").toString());
}
void ConfigManager::setLanguage(const QString &languageCode)
{
settings->setValue("Language", Localization::normalizeLanguageCode(languageCode));
}