74b0d05187a441633324a27de224b6d3fb1d4f32
[harmattan/cameraplus] / src / settings.h
1 // -*- c++ -*-
2
3 /*!
4  * This file is part of CameraPlus.
5  *
6  * Copyright (C) 2012-2013 Mohammed Sameer <msameer@foolab.org>
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
21  */
22
23 #ifndef SETTINGS_H
24 #define SETTINGS_H
25
26 #include <QObject>
27
28 class QSettings;
29 class DeviceSettings;
30
31 class Settings : public QObject {
32   Q_OBJECT
33
34   Q_PROPERTY(int mode READ mode WRITE setMode NOTIFY modeChanged);
35   Q_PROPERTY(QString creatorName READ creatorName WRITE setCreatorName NOTIFY creatorNameChanged);
36   Q_PROPERTY(bool useGps READ useGps WRITE setUseGps NOTIFY useGpsChanged);
37   Q_PROPERTY(bool useGeotags READ useGeotags WRITE setUseGeotags NOTIFY useGeotagsChanged);
38   Q_PROPERTY(int imageSceneMode READ imageSceneMode WRITE setImageSceneMode NOTIFY imageSceneModeChanged);
39   Q_PROPERTY(int imageColorFilter READ imageColorFilter WRITE setImageColorFilter NOTIFY imageColorFilterChanged);
40   Q_PROPERTY(int imageWhiteBalance READ imageWhiteBalance WRITE setImageWhiteBalance NOTIFY imageWhiteBalanceChanged);
41   Q_PROPERTY(qreal imageEvComp READ imageEvComp WRITE setImageEvComp NOTIFY imageEvCompChanged);
42
43   Q_PROPERTY(int videoSceneMode READ videoSceneMode WRITE setVideoSceneMode NOTIFY videoSceneModeChanged);
44   Q_PROPERTY(int videoColorFilter READ videoColorFilter WRITE setVideoColorFilter NOTIFY videoColorFilterChanged);
45   Q_PROPERTY(int videoWhiteBalance READ videoWhiteBalance WRITE setVideoWhiteBalance NOTIFY videoWhiteBalanceChanged);
46   Q_PROPERTY(qreal videoEvComp READ videoEvComp WRITE setVideoEvComp NOTIFY videoEvCompChanged);
47
48   Q_PROPERTY(int imageFlashMode READ imageFlashMode WRITE setImageFlashMode NOTIFY imageFlashModeChanged);
49   Q_PROPERTY(int imageIso READ imageIso WRITE setImageIso NOTIFY imageIsoChanged);
50
51   Q_PROPERTY(QString imageAspectRatio READ imageAspectRatio WRITE setImageAspectRatio NOTIFY imageAspectRatioChanged);
52   Q_PROPERTY(QString imageResolution READ imageResolution WRITE setImageResolution NOTIFY imageResolutionChanged);
53
54   Q_PROPERTY(QString videoAspectRatio READ videoAspectRatio WRITE setVideoAspectRatio NOTIFY videoAspectRatioChanged);
55   Q_PROPERTY(QString videoResolution READ videoResolution WRITE setVideoResolution NOTIFY videoResolutionChanged);
56
57   Q_PROPERTY(bool soundEnabled READ isSoundEnabled WRITE setSoundEnabled NOTIFY soundEnabledChanged);
58   Q_PROPERTY(bool videoTorchOn READ isVideoTorchOn WRITE setVideoTorchOn NOTIFY videoTorchOnChanged);
59
60   Q_PROPERTY(bool showToolBar READ isToolBarShown WRITE setToolBarShown NOTIFY toolBarShownChanged);
61   Q_PROPERTY(bool videoMuted READ isVideoMuted WRITE setVideoMuted NOTIFY videoMutedChanged);
62
63   Q_PROPERTY(bool gridEnabled READ isGridEnabled WRITE setGridEnabled NOTIFY gridEnabledChanged);
64
65   Q_PROPERTY(bool faceDetectionEnabled READ isFaceDetectionEnabled WRITE setFaceDetectionEnabled NOTIFY faceDetectionEnabledChanged);
66   Q_PROPERTY(bool zoomAsShutter READ isZoomAsShutterEnabled WRITE setZoomAsShutterEnabled NOTIFY zoomAsShutterChanged);
67   Q_PROPERTY(bool proximityAsShutter READ isProximityAsShutterEnabled WRITE setProximityAsShutterEnabled NOTIFY proximityAsShutterChanged);
68   Q_PROPERTY(int device READ device WRITE setDevice NOTIFY deviceChanged);
69   Q_PROPERTY(bool enablePreview READ isPreviewEnabled WRITE setPreviewEnabled NOTIFY previewEnabledChanged);
70   Q_PROPERTY(bool useUtcForFileNaming READ isUtcForFileNamingUsed CONSTANT);
71
72 public:
73   Settings(QObject *parent = 0);
74   ~Settings();
75
76   int mode() const;
77   void setMode(int mode);
78
79   QString creatorName() const;
80   void setCreatorName(const QString& name);
81
82   bool useGps() const;
83   void setUseGps(bool enable);
84
85   bool useGeotags() const;
86   void setUseGeotags(bool enable);
87
88   int imageSceneMode();
89   void setImageSceneMode(int mode);
90
91   int imageColorFilter();
92   void setImageColorFilter(int filter);
93
94   int imageWhiteBalance();
95   void setImageWhiteBalance(int wb);
96
97   qreal imageEvComp();
98   void setImageEvComp(qreal ev);
99
100   int videoSceneMode();
101   void setVideoSceneMode(int mode);
102
103   int videoColorFilter();
104   void setVideoColorFilter(int filter);
105
106   int videoWhiteBalance();
107   void setVideoWhiteBalance(int wb);
108
109   qreal videoEvComp();
110   void setVideoEvComp(qreal ev);
111
112   int imageFlashMode();
113   void setImageFlashMode(int mode);
114
115   int imageIso();
116   void setImageIso(int iso);
117
118   QString imageAspectRatio();
119   void setImageAspectRatio(const QString& aspectRatio);
120
121   QString imageResolution();
122   void setImageResolution(const QString& resolution);
123
124   QString videoAspectRatio();
125   void setVideoAspectRatio(const QString& aspectRatio);
126
127   QString videoResolution();
128   void setVideoResolution(const QString& resolution);
129
130   bool isSoundEnabled() const;
131   void setSoundEnabled(bool enabled);
132
133   bool isVideoTorchOn();
134   void setVideoTorchOn(bool on);
135
136   bool isToolBarShown() const;
137   void setToolBarShown(bool shown);
138
139   bool isVideoMuted() const;
140   void setVideoMuted(bool muted);
141
142   bool isGridEnabled() const;
143   void setGridEnabled(bool enabled);
144
145   bool isFaceDetectionEnabled() const;
146   void setFaceDetectionEnabled(bool enabled);
147
148   bool isZoomAsShutterEnabled() const;
149   void setZoomAsShutterEnabled(bool enabled);
150
151   bool isProximityAsShutterEnabled() const;
152   void setProximityAsShutterEnabled(bool enabled);
153
154   int device() const;
155   void setDevice(int device);
156
157   QString fileNamingStamp(const QString& id) const;
158   void setFileNamingStamp(const QString& id, const QString& stamp);
159
160   int fileNamingCounter(const QString& id) const;
161   void setFileNamingCounter(const QString& id, int counter);
162
163   bool isPreviewEnabled() const;
164   void setPreviewEnabled(bool enabled);
165
166   bool isUtcForFileNamingUsed() const;
167
168 signals:
169   void modeChanged();
170   void creatorNameChanged();
171   void useGpsChanged();
172   void useGeotagsChanged();
173   void imageSceneModeChanged();
174   void imageColorFilterChanged();
175   void imageWhiteBalanceChanged();
176   void imageEvCompChanged();
177   void videoSceneModeChanged();
178   void videoColorFilterChanged();
179   void videoWhiteBalanceChanged();
180   void videoEvCompChanged();
181   void imageFlashModeChanged();
182   void imageIsoChanged();
183   void imageAspectRatioChanged();
184   void imageResolutionChanged();
185   void videoAspectRatioChanged();
186   void videoResolutionChanged();
187   void soundEnabledChanged();
188   void videoTorchOnChanged();
189   void toolBarShownChanged();
190   void videoMutedChanged();
191   void gridEnabledChanged();
192   void faceDetectionEnabledChanged();
193   void zoomAsShutterChanged();
194   void proximityAsShutterChanged();
195   void deviceAboutToChange();
196   void deviceChanged();
197   void previewEnabledChanged();
198
199 private:
200   DeviceSettings *deviceSettings();
201   QVariant deviceValue(const char *key, const QVariant& defaultValue);
202   void setDeviceValue(const char *key, const QVariant& value);
203
204   QSettings *m_settings;
205   DeviceSettings *m_device;
206 };
207
208 #endif /* SETTINGS_H */