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