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
38 Settings::Settings(QObject *parent) :
40 m_settings(new QSettings(PATH, QSettings::IniFormat, this)) {
44 Settings::~Settings() {
45 delete m_settings; m_settings = 0;
48 int Settings::mode() const {
49 return m_settings->value("camera/mode", DEFAULT_MODE).toInt();
52 void Settings::setMode(int mode) {
53 if (mode != Settings::mode()) {
54 m_settings->setValue("camera/mode", mode);
60 QString Settings::creatorName() const {
61 return m_settings->value("camera/creatorName").toString();
64 void Settings::setCreatorName(const QString& name) {
65 if (name != creatorName()) {
66 m_settings->setValue("camera/creatorName", name);
68 emit creatorNameChanged();
72 int Settings::postCaptureTimeout() const {
73 return m_settings->value("camera/postCaptureTimeout", DEFAULT_TIMEOUT).toInt();
76 void Settings::setPostCaptureTimeout(int timeout) {
77 if (timeout != postCaptureTimeout()) {
78 m_settings->setValue("camera/postCaptureTimeout", timeout);
80 emit postCaptureTimeoutChanged();
84 bool Settings::useGps() const {
85 return m_settings->value("camera/useGps", DEFAULT_USE_GPS).toBool();
88 void Settings::setUseGps(bool enable) {
89 if (enable != useGps()) {
90 m_settings->setValue("camera/useGps", enable);
96 bool Settings::useGeotags() const {
97 return m_settings->value("camera/useGeotags", DEFAULT_USE_GEOTAGS).toBool();
100 void Settings::setUseGeotags(bool enable) {
101 if (enable != useGeotags()) {
102 m_settings->setValue("camera/useGeotags", enable);
104 emit useGeotagsChanged();
108 int Settings::imageSceneMode() const {
109 return m_settings->value("image/sceneMode", DEFAULT_SCENE_MODE).toInt();
112 void Settings::setImageSceneMode(int mode) {
113 if (mode != imageSceneMode()) {
114 m_settings->setValue("image/sceneMode", mode);
116 emit imageSceneModeChanged();
120 int Settings::imageColorFilter() const {
121 return m_settings->value("image/colorFilter", DEFAULT_COLOR_FILTER).toInt();
124 void Settings::setImageColorFilter(int filter) {
125 if (filter != imageColorFilter()) {
126 m_settings->setValue("image/colorFilter", filter);
128 emit imageColorFilterChanged();
132 int Settings::imageWhiteBalance() const {
133 return m_settings->value("image/whiteBalance", DEFAULT_WHITE_BALANCE).toInt();
136 void Settings::setImageWhiteBalance(int wb) {
137 if (wb != imageWhiteBalance()) {
138 m_settings->setValue("image/whiteBalance", wb);
140 emit imageWhiteBalanceChanged();
144 qreal Settings::imageEvComp() const {
145 return m_settings->value("image/evComp", DEFAULT_EV_COMP).toReal();
148 void Settings::setImageEvComp(qreal ev) {
149 if (ev != imageEvComp()) {
150 m_settings->setValue("image/evComp", ev);
152 emit imageEvCompChanged();
156 int Settings::videoSceneMode() const {
157 return m_settings->value("video/sceneMode", DEFAULT_SCENE_MODE).toInt();
160 void Settings::setVideoSceneMode(int mode) {
161 if (mode != videoSceneMode()) {
162 m_settings->setValue("video/sceneMode", mode);
164 emit videoSceneModeChanged();
168 int Settings::videoColorFilter() const {
169 return m_settings->value("video/colorFilter", DEFAULT_COLOR_FILTER).toInt();
172 void Settings::setVideoColorFilter(int filter) {
173 if (filter != videoColorFilter()) {
174 m_settings->setValue("video/colorFilter", filter);
176 emit videoColorFilterChanged();
180 int Settings::videoWhiteBalance() const {
181 return m_settings->value("video/whiteBalance", DEFAULT_WHITE_BALANCE).toInt();
184 void Settings::setVideoWhiteBalance(int wb) {
185 if (wb != videoWhiteBalance()) {
186 m_settings->setValue("video/whiteBalance", wb);
188 emit videoWhiteBalanceChanged();
192 qreal Settings::videoEvComp() const {
193 return m_settings->value("video/evComp", DEFAULT_EV_COMP).toReal();
196 void Settings::setVideoEvComp(qreal ev) {
197 if (ev != videoEvComp()) {
198 m_settings->setValue("video/evComp", ev);
200 emit videoEvCompChanged();
204 int Settings::imageFlashMode() const {
205 return m_settings->value("image/flashMode", DEFAULT_FLASH_MODE).toInt();
208 void Settings::setImageFlashMode(int mode) {
209 if (mode != imageFlashMode()) {
210 m_settings->setValue("image/flashMode", mode);
212 emit imageFlashModeChanged();
216 int Settings::imageIso() const {
217 return m_settings->value("image/iso", DEFAULT_IMAGE_ISO).toInt();
220 void Settings::setImageIso(int iso) {
221 if (imageIso() != iso) {
222 m_settings->setValue("image/iso", iso);
223 emit imageIsoChanged();