Added a setting for imageFlashMode
[harmattan/cameraplus] / src / settings.cpp
1 #include "settings.h"
2 #include <QSettings>
3 #include <QDir>
4
5 #define PATH QString("%1%2.config%2/cameraplus.conf").arg(QDir::homePath()).arg(QDir::separator())
6
7 #define DEFAULT_MODE          0
8 #define DEFAULT_SCENE_MODE    6 // Auto
9 #define DEFAULT_TIMEOUT       0
10 #define DEFAULT_USE_GPS       true
11 #define DEFAULT_USE_GEOTAGS   true
12 #define DEFAULT_COLOR_FILTER  0
13 #define DEFAULT_WHITE_BALANCE 0
14 #define DEFAULT_EV_COMP       0.0
15 #define DEFAULT_FLASH_MODE    0
16
17 Settings::Settings(QObject *parent) :
18   QObject(parent),
19   m_settings(new QSettings(PATH, QSettings::IniFormat, this)) {
20
21 }
22
23 Settings::~Settings() {
24   delete m_settings; m_settings = 0;
25 }
26
27 int Settings::mode() const {
28   return m_settings->value("camera/mode", DEFAULT_MODE).toInt();
29 }
30
31 void Settings::setMode(int mode) {
32   if (mode != Settings::mode()) {
33     m_settings->setValue("camera/mode", mode);
34
35     emit modeChanged();
36   }
37 }
38
39 QString Settings::creatorName() const {
40   return m_settings->value("camera/creatorName").toString();
41 }
42
43 void Settings::setCreatorName(const QString& name) {
44   if (name != creatorName()) {
45     m_settings->setValue("camera/creatorName", name);
46
47     emit creatorNameChanged();
48   }
49 }
50
51 int Settings::postCaptureTimeout() const {
52   return m_settings->value("camera/postCaptureTimeout", DEFAULT_TIMEOUT).toInt();
53 }
54
55 void Settings::setPostCaptureTimeout(int timeout) {
56   if (timeout != postCaptureTimeout()) {
57     m_settings->setValue("camera/postCaptureTimeout", timeout);
58
59     emit postCaptureTimeoutChanged();
60   }
61 }
62
63 bool Settings::useGps() const {
64   return m_settings->value("camera/useGps", DEFAULT_USE_GPS).toBool();
65 }
66
67 void Settings::setUseGps(bool enable) {
68   if (enable == useGps()) {
69     m_settings->setValue("camera/useGps", enable);
70
71     emit useGpsChanged();
72   }
73 }
74
75 bool Settings::useGeotags() const {
76   return m_settings->value("camera/useGeotags", DEFAULT_USE_GEOTAGS).toBool();
77 }
78
79 void Settings::setUseGeotags(bool enable) {
80   if (enable != useGeotags()) {
81     m_settings->setValue("camera/useGeotags", enable);
82
83     emit useGeotagsChanged();
84   }
85 }
86
87 int Settings::imageSceneMode() const {
88   return m_settings->value("image/sceneMode", DEFAULT_SCENE_MODE).toInt();
89 }
90
91 void Settings::setImageSceneMode(int mode) {
92   if (mode != imageSceneMode()) {
93     m_settings->setValue("image/sceneMode", mode);
94
95     emit imageSceneModeChanged();
96   }
97 }
98
99 int Settings::imageColorFilter() const {
100   return m_settings->value("image/colorFilter", DEFAULT_COLOR_FILTER).toInt();
101 }
102
103 void Settings::setImageColorFilter(int filter) {
104   if (filter != imageColorFilter()) {
105     m_settings->setValue("image/colorFilter", filter);
106
107     emit imageColorFilterChanged();
108   }
109 }
110
111 int Settings::imageWhiteBalance() const {
112   return m_settings->value("image/whiteBalance", DEFAULT_WHITE_BALANCE).toInt();
113 }
114
115 void Settings::setImageWhiteBalance(int wb) {
116   if (wb != imageWhiteBalance()) {
117     m_settings->setValue("image/whiteBalance", wb);
118
119     emit imageWhiteBalanceChanged();
120   }
121 }
122
123 qreal Settings::imageEvComp() const {
124   return m_settings->value("image/evComp", DEFAULT_EV_COMP).toReal();
125 }
126
127 void Settings::setImageEvComp(qreal ev) {
128   if (ev != imageEvComp()) {
129     m_settings->setValue("image/evComp", ev);
130
131     emit imageEvCompChanged();
132   }
133 }
134
135 int Settings::videoSceneMode() const {
136   return m_settings->value("video/sceneMode", DEFAULT_SCENE_MODE).toInt();
137 }
138
139 void Settings::setVideoSceneMode(int mode) {
140   if (mode != videoSceneMode()) {
141     m_settings->setValue("video/sceneMode", mode);
142
143     emit videoSceneModeChanged();
144   }
145 }
146
147 int Settings::videoColorFilter() const {
148   return m_settings->value("video/colorFilter", DEFAULT_COLOR_FILTER).toInt();
149 }
150
151 void Settings::setVideoColorFilter(int filter) {
152   if (filter != videoColorFilter()) {
153     m_settings->setValue("video/colorFilter", filter);
154
155     emit videoColorFilterChanged();
156   }
157 }
158
159 int Settings::videoWhiteBalance() const {
160   return m_settings->value("video/whiteBalance", DEFAULT_WHITE_BALANCE).toInt();
161 }
162
163 void Settings::setVideoWhiteBalance(int wb) {
164   if (wb != videoWhiteBalance()) {
165     m_settings->setValue("video/whiteBalance", wb);
166
167     emit videoWhiteBalanceChanged();
168   }
169 }
170
171 qreal Settings::videoEvComp() const {
172   return m_settings->value("video/evComp", DEFAULT_EV_COMP).toReal();
173 }
174
175 void Settings::setVideoEvComp(qreal ev) {
176   if (ev != videoEvComp()) {
177     m_settings->setValue("video/evComp", ev);
178
179     emit videoEvCompChanged();
180   }
181 }
182
183 int Settings::imageFlashMode() const {
184   return m_settings->value("image/flashMode", DEFAULT_FLASH_MODE).toInt();
185 }
186
187 void Settings::setImageFlashMode(int mode) {
188   if (mode != imageFlashMode()) {
189     m_settings->setValue("image/flashMode", mode);
190
191     emit imageFlashModeChanged();
192   }
193 }