-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.cpp
113 lines (90 loc) · 2.2 KB
/
config.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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#include "Config.hpp"
const QString Config::DEFAULT_MONETARY_SYMBOL = "€";
int Config::getLanguage() const
{
return language;
}
void Config::setLanguage(int value)
{
language = value;
}
QString Config::cleanPathIfFile(const QString &filePath)
{
QFileInfo tmp(filePath);
if (tmp.isFile()){
return tmp.absoluteDir().absolutePath();
}
return filePath;
}
QString Config::getApplicationDataPath()
{
QStringList sl = QStandardPaths::standardLocations(QStandardPaths::DataLocation);
if (sl.size()>0) return sl.first().append(QDir::separator());
else return "";
}
Config::Config()
{
monetarySymbol = Config::DEFAULT_MONETARY_SYMBOL;
order = SYMBOL_AFTER_AMOUNT;
}
Config::Config(const QString &monetarySymbol, int order)
{
this->monetarySymbol = monetarySymbol;
this->order = order;
}
void Config::setMonetarySymbol(const QString &symbol){
this->monetarySymbol = symbol;
}
QString Config::getMonetarySymbol(){
return monetarySymbol;
}
void Config::setOrder(int order){
this->order = order;
}
int Config::getOrder(){
return order;
}
QString Config::constructMoney(float amount){
if (order==SYMBOL_BEFORE_AMOUNT){
return QString("%1%2").arg(getMonetarySymbol()).arg(QLocale::system().toString(amount));
}
else if (order==SYMBOL_AFTER_AMOUNT){
return QString("%2%1").arg(getMonetarySymbol()).arg(QLocale::system().toString(amount));
}
return "";
}
void Config::setVersion(int major, int minor){
version.setMajor(major);
version.setMinor(minor);
}
Version Config::getVersion(){
return this->version;
}
void Config::setLastUpdateCheck(QDate date){
this->lastUpdateCheck = date;
}
QDate Config::getLastUpdateCheck(){
return this->lastUpdateCheck;
}
void Config::setUpdatesEnabled(bool enabled){
this->updatesEnabled = enabled;
}
bool Config::getUpdatesEnabled(){
return this->updatesEnabled;
}
QString Config::getExportPath() const
{
return exportPath;
}
void Config::setExportPath(const QString &value)
{
exportPath = cleanPathIfFile(value);
}
QString Config::getSavePath() const
{
return savePath;
}
void Config::setSavePath(const QString &value)
{
savePath = cleanPathIfFile(value);
}