2 * This file is part of CameraPlus.
4 * Copyright (C) 2012 Mohammed Sameer <msameer@foolab.org>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
25 #define PATH QString("%1%2.config%2/cameraplus.conf").arg(QDir::homePath()).arg(QDir::separator())
27 #define DEFAULT_MODE 0
28 #define DEFAULT_SCENE_MODE 6 // Auto
29 #define DEFAULT_TIMEOUT 0
30 #define DEFAULT_USE_GPS true
31 #define DEFAULT_USE_GEOTAGS true
32 #define DEFAULT_COLOR_FILTER 0
33 #define DEFAULT_WHITE_BALANCE 0
34 #define DEFAULT_EV_COMP 0.0
35 #define DEFAULT_FLASH_MODE 0
36 #define DEFAULT_IMAGE_ISO 0
37 #define DEFAULT_IMAGE_RESOLUTION "high"
38 #define DEFAULT_IMAGE_ASPECT_RATIO "16:9"
39 #define DEFAULT_VIDEO_RESOLUTION "high"
41 Settings::Settings(QObject *parent) :
43 m_settings(new QSettings(PATH, QSettings::IniFormat, this)) {
47 Settings::~Settings() {
48 delete m_settings; m_settings = 0;
51 int Settings::mode() const {
52 return m_settings->value("camera/mode", DEFAULT_MODE).toInt();
55 void Settings::setMode(int mode) {
56 if (mode != Settings::mode()) {
57 m_settings->setValue("camera/mode", mode);
63 QString Settings::creatorName() const {
64 return m_settings->value("camera/creatorName").toString();
67 void Settings::setCreatorName(const QString& name) {
68 if (name != creatorName()) {
69 m_settings->setValue("camera/creatorName", name);
71 emit creatorNameChanged();
75 int Settings::postCaptureTimeout() const {
76 return m_settings->value("camera/postCaptureTimeout", DEFAULT_TIMEOUT).toInt();
79 void Settings::setPostCaptureTimeout(int timeout) {
80 if (timeout != postCaptureTimeout()) {
81 m_settings->setValue("camera/postCaptureTimeout", timeout);
83 emit postCaptureTimeoutChanged();
87 bool Settings::useGps() const {
88 return m_settings->value("camera/useGps", DEFAULT_USE_GPS).toBool();
91 void Settings::setUseGps(bool enable) {
92 if (enable != useGps()) {
93 m_settings->setValue("camera/useGps", enable);
99 bool Settings::useGeotags() const {
100 return m_settings->value("camera/useGeotags", DEFAULT_USE_GEOTAGS).toBool();
103 void Settings::setUseGeotags(bool enable) {
104 if (enable != useGeotags()) {
105 m_settings->setValue("camera/useGeotags", enable);
107 emit useGeotagsChanged();
111 int Settings::imageSceneMode() const {
112 return m_settings->value("image/sceneMode", DEFAULT_SCENE_MODE).toInt();
115 void Settings::setImageSceneMode(int mode) {
116 if (mode != imageSceneMode()) {
117 m_settings->setValue("image/sceneMode", mode);
119 emit imageSceneModeChanged();
123 int Settings::imageColorFilter() const {
124 return m_settings->value("image/colorFilter", DEFAULT_COLOR_FILTER).toInt();
127 void Settings::setImageColorFilter(int filter) {
128 if (filter != imageColorFilter()) {
129 m_settings->setValue("image/colorFilter", filter);
131 emit imageColorFilterChanged();
135 int Settings::imageWhiteBalance() const {
136 return m_settings->value("image/whiteBalance", DEFAULT_WHITE_BALANCE).toInt();
139 void Settings::setImageWhiteBalance(int wb) {
140 if (wb != imageWhiteBalance()) {
141 m_settings->setValue("image/whiteBalance", wb);
143 emit imageWhiteBalanceChanged();
147 qreal Settings::imageEvComp() const {
148 return m_settings->value("image/evComp", DEFAULT_EV_COMP).toReal();
151 void Settings::setImageEvComp(qreal ev) {
152 if (ev != imageEvComp()) {
153 m_settings->setValue("image/evComp", ev);
155 emit imageEvCompChanged();
159 int Settings::videoSceneMode() const {
160 return m_settings->value("video/sceneMode", DEFAULT_SCENE_MODE).toInt();
163 void Settings::setVideoSceneMode(int mode) {
164 if (mode != videoSceneMode()) {
165 m_settings->setValue("video/sceneMode", mode);
167 emit videoSceneModeChanged();
171 int Settings::videoColorFilter() const {
172 return m_settings->value("video/colorFilter", DEFAULT_COLOR_FILTER).toInt();
175 void Settings::setVideoColorFilter(int filter) {
176 if (filter != videoColorFilter()) {
177 m_settings->setValue("video/colorFilter", filter);
179 emit videoColorFilterChanged();
183 int Settings::videoWhiteBalance() const {
184 return m_settings->value("video/whiteBalance", DEFAULT_WHITE_BALANCE).toInt();
187 void Settings::setVideoWhiteBalance(int wb) {
188 if (wb != videoWhiteBalance()) {
189 m_settings->setValue("video/whiteBalance", wb);
191 emit videoWhiteBalanceChanged();
195 qreal Settings::videoEvComp() const {
196 return m_settings->value("video/evComp", DEFAULT_EV_COMP).toReal();
199 void Settings::setVideoEvComp(qreal ev) {
200 if (ev != videoEvComp()) {
201 m_settings->setValue("video/evComp", ev);
203 emit videoEvCompChanged();
207 int Settings::imageFlashMode() const {
208 return m_settings->value("image/flashMode", DEFAULT_FLASH_MODE).toInt();
211 void Settings::setImageFlashMode(int mode) {
212 if (mode != imageFlashMode()) {
213 m_settings->setValue("image/flashMode", mode);
215 emit imageFlashModeChanged();
219 int Settings::imageIso() const {
220 return m_settings->value("image/iso", DEFAULT_IMAGE_ISO).toInt();
223 void Settings::setImageIso(int iso) {
224 if (imageIso() != iso) {
225 m_settings->setValue("image/iso", iso);
226 emit imageIsoChanged();
230 QString Settings::imageAspectRatio() const {
231 return m_settings->value("image/aspectRatio", DEFAULT_IMAGE_ASPECT_RATIO).toString();
234 void Settings::setImageAspectRatio(const QString& aspectRatio) {
235 if (aspectRatio != imageAspectRatio()) {
236 m_settings->setValue("image/aspectRatio", aspectRatio);
237 emit imageAspectRatioChanged();
241 QString Settings::imageResolution() const {
242 return m_settings->value("image/resolution", DEFAULT_IMAGE_RESOLUTION).toString();
245 void Settings::setImageResolution(const QString& resolution) {
246 if (resolution != imageResolution()) {
247 m_settings->setValue("image/resolution", resolution);
248 emit imageResolutionChanged();
252 QString Settings::videoAspectRatio() const {
253 // This is not used for anything so we will return an empty string for now
254 // which will make the backend return all resolutions.
259 void Settings::setVideoAspectRatio(const QString& aspectRatio) {
260 Q_UNUSED(aspectRatio);
262 // This is not used for anything so we will just ignore it.
265 QString Settings::videoResolution() const {
266 return m_settings->value("video/resolution", DEFAULT_VIDEO_RESOLUTION).toString();
269 void Settings::setVideoResolution(const QString& resolution) {
270 if (resolution != videoResolution()) {
271 m_settings->setValue("video/resolution", resolution);
272 emit videoResolutionChanged();