-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAppConfiguration.cpp
232 lines (204 loc) · 7.27 KB
/
AppConfiguration.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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
#include "AppConfiguration.hpp"
#include "Logger/Logger.hpp"
#include "common/ConfigHelpers.hpp"
#include <QMessageBox>
//-----------------------------------------------------
void initLogs()
{
N_Logger::resetLogFile();
qInstallMessageHandler(N_Logger::message);
}
//----------------------------------------------------------------------------------------------
AppConfiguration::AppConfiguration(QObject* a_Parent)
: QObject(a_Parent)
, m_Settings(N_Common::configFilename(), QSettings::IniFormat)
{
if(logsEnabled())
{
initLogs();
}
}
//----------------------------------------------------------------------------------------------
bool AppConfiguration::settingsFileExists() const
{
m_Settings.beginGroup("Logs");
auto exists(m_Settings.contains("activated"));
m_Settings.endGroup();
return exists;
}
//----------------------------------------------------------------------------------------------
bool AppConfiguration::logsEnabled() const
{
m_Settings.beginGroup("Logs");
auto result(m_Settings.value("activated", true).toBool());
m_Settings.endGroup();
return result;
}
//----------------------------------------------------------------------------------------------
uint AppConfiguration::savingTime() const
{
m_Settings.beginGroup("SavingProcess");
auto result(m_Settings.value("savingDuration", 15000).toUInt());
m_Settings.endGroup();
return result;
}
//----------------------------------------------------------------------------------------------
QString AppConfiguration::fotozorInstanceName() const
{
m_Settings.beginGroup("Text");
auto result(m_Settings.value("instanceName", "Fotozor").toString());
m_Settings.endGroup();
return result;
}
//----------------------------------------------------------------------------------------------
QString AppConfiguration::introductionText() const
{
m_Settings.beginGroup("Text");
auto result(m_Settings.value("introductionText", "This is the introduction").toString());
m_Settings.endGroup();
return result;
}
//----------------------------------------------------------------------------------------------
QString AppConfiguration::savingText() const
{
m_Settings.beginGroup("Text");
auto result(m_Settings.value("savingText", "This is the text during saving").toString());
m_Settings.endGroup();
return result;
}
//----------------------------------------------------------------------------------------------
QString AppConfiguration::savingTitle() const
{
m_Settings.beginGroup("Text");
auto result(m_Settings.value("savingTitle", "We want to save...").toString());
m_Settings.endGroup();
return result;
}
//----------------------------------------------------------------------------------------------
QString AppConfiguration::printingText() const
{
m_Settings.beginGroup("Text");
auto result(m_Settings.value("printingText", "This is the text during printing").toString());
m_Settings.endGroup();
return result;
}
//----------------------------------------------------------------------------------------------
QString AppConfiguration::printingTitle() const
{
m_Settings.beginGroup("Text");
auto result(m_Settings.value("printingTitle", "We want to print...").toString());
m_Settings.endGroup();
return result;
}
//----------------------------------------------------------------------------------------------
qreal AppConfiguration::zoom() const
{
m_Settings.beginGroup("Camera");
auto result(m_Settings.value("zoom", 1).toReal());
m_Settings.endGroup();
return result;
}
//----------------------------------------------------------------------------------------------
void AppConfiguration::setZoom(qreal a_Value)
{
m_Settings.beginGroup("Camera");
m_Settings.setValue("zoom", a_Value);
m_Settings.endGroup();
emit zoomChanged();
}
//----------------------------------------------------------------------------------------------
qreal AppConfiguration::colorTemp() const
{
m_Settings.beginGroup("Camera");
auto result(m_Settings.value("colorTemp", 7000).toReal());
m_Settings.endGroup();
return result;
}
//----------------------------------------------------------------------------------------------
void AppConfiguration::setColorTemp(qreal a_Value)
{
m_Settings.beginGroup("Camera");
m_Settings.setValue("colorTemp", a_Value);
m_Settings.endGroup();
emit colorTempChanged();
}
//----------------------------------------------------------------------------------------------
QSize AppConfiguration::resolution() const
{
m_Settings.beginGroup("Camera");
auto result(m_Settings.value("resolution", QSize(1920, 1080)).toSize());
m_Settings.endGroup();
return result;
}
//----------------------------------------------------------------------------------------------
void AppConfiguration::setResolution(const QSize& a_Value)
{
m_Settings.beginGroup("Camera");
m_Settings.setValue("resolution", a_Value);
m_Settings.endGroup();
emit resolutionChanged();
}
//----------------------------------------------------------------------------------------------
QCamera::Position AppConfiguration::cameraPosition() const
{
m_Settings.beginGroup("Camera");
auto result(m_Settings.value("position", static_cast<int>(QCamera::FrontFace)).toInt());
m_Settings.endGroup();
return QCamera::Position(result);
}
//----------------------------------------------------------------------------------------------
void AppConfiguration::setCameraPosition(const QCamera::Position& a_Value)
{
m_Settings.beginGroup("Camera");
m_Settings.setValue("position", static_cast<int>(a_Value));
m_Settings.endGroup();
emit cameraPositionChanged();
}
//----------------------------------------------------------------------------------------------
qreal AppConfiguration::bottomMarginRatio() const
{
m_Settings.beginGroup("PicLayout");
auto result(m_Settings.value("bottomMarginRatio", 0.15).toReal());
m_Settings.endGroup();
return result;
}
//----------------------------------------------------------------------------------------------
void AppConfiguration::setBottomMarginRatio(qreal a_Value)
{
m_Settings.beginGroup("PicLayout");
m_Settings.setValue("bottomMarginRatio", a_Value);
m_Settings.endGroup();
emit bottomMarginRatioChanged();
}
//----------------------------------------------------------------------------------------------
qreal AppConfiguration::scaleFactor() const
{
m_Settings.beginGroup("PicLayout");
auto result(m_Settings.value("scaleFactor", 0.85).toReal());
m_Settings.endGroup();
return result;
}
//----------------------------------------------------------------------------------------------
void AppConfiguration::setScaleFactor(qreal a_Value)
{
m_Settings.beginGroup("PicLayout");
m_Settings.setValue("scaleFactor", a_Value);
m_Settings.endGroup();
emit scaleFactorChanged();
}
//----------------------------------------------------------------------------------------------
qreal AppConfiguration::rotationAngle() const
{
m_Settings.beginGroup("PicLayout");
auto result(m_Settings.value("rotationAngle", -90).toReal());
m_Settings.endGroup();
return result;
}
//----------------------------------------------------------------------------------------------
void AppConfiguration::setRotationAngle(qreal a_Value)
{
m_Settings.beginGroup("PicLayout");
m_Settings.setValue("rotationAngle", a_Value);
m_Settings.endGroup();
emit rotationAngleChanged();
}