Added an option to enable using proximity sensor to capture
[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
70 public:
71   Settings(QObject *parent = 0);
72   ~Settings();
73
74   int mode() const;
75   void setMode(int mode);
76
77   QString creatorName() const;
78   void setCreatorName(const QString& name);
79
80   bool useGps() const;
81   void setUseGps(bool enable);
82
83   bool useGeotags() const;
84   void setUseGeotags(bool enable);
85
86   int imageSceneMode();
87   void setImageSceneMode(int mode);
88
89   int imageColorFilter();
90   void setImageColorFilter(int filter);
91
92   int imageWhiteBalance();
93   void setImageWhiteBalance(int wb);
94
95   qreal imageEvComp();
96   void setImageEvComp(qreal ev);
97
98   int videoSceneMode();
99   void setVideoSceneMode(int mode);
100
101   int videoColorFilter();
102   void setVideoColorFilter(int filter);
103
104   int videoWhiteBalance();
105   void setVideoWhiteBalance(int wb);
106
107   qreal videoEvComp();
108   void setVideoEvComp(qreal ev);
109
110   int imageFlashMode();
111   void setImageFlashMode(int mode);
112
113   int imageIso();
114   void setImageIso(int iso);
115
116   QString imageAspectRatio();
117   void setImageAspectRatio(const QString& aspectRatio);
118
119   QString imageResolution();
120   void setImageResolution(const QString& resolution);
121
122   QString videoAspectRatio();
123   void setVideoAspectRatio(const QString& aspectRatio);
124
125   QString videoResolution();
126   void setVideoResolution(const QString& resolution);
127
128   bool isSoundEnabled() const;
129   void setSoundEnabled(bool enabled);
130
131   bool isVideoTorchOn();
132   void setVideoTorchOn(bool on);
133
134   bool isToolBarShown() const;
135   void setToolBarShown(bool shown);
136
137   bool isVideoMuted() const;
138   void setVideoMuted(bool muted);
139
140   bool isGridEnabled() const;
141   void setGridEnabled(bool enabled);
142
143   bool isFaceDetectionEnabled() const;
144   void setFaceDetectionEnabled(bool enabled);
145
146   bool isZoomAsShutterEnabled() const;
147   void setZoomAsShutterEnabled(bool enabled);
148
149   bool isProximityAsShutterEnabled() const;
150   void setProximityAsShutterEnabled(bool enabled);
151
152   int device() const;
153   void setDevice(int device);
154
155   QString fileNamingStamp() const;
156   void setFileNamingStamp(const QString& stamp);
157
158   int fileNamingCounter() const;
159   void setFileNamingCounter(int counter);
160
161 signals:
162   void modeChanged();
163   void creatorNameChanged();
164   void useGpsChanged();
165   void useGeotagsChanged();
166   void imageSceneModeChanged();
167   void imageColorFilterChanged();
168   void imageWhiteBalanceChanged();
169   void imageEvCompChanged();
170   void videoSceneModeChanged();
171   void videoColorFilterChanged();
172   void videoWhiteBalanceChanged();
173   void videoEvCompChanged();
174   void imageFlashModeChanged();
175   void imageIsoChanged();
176   void imageAspectRatioChanged();
177   void imageResolutionChanged();
178   void videoAspectRatioChanged();
179   void videoResolutionChanged();
180   void soundEnabledChanged();
181   void videoTorchOnChanged();
182   void toolBarShownChanged();
183   void videoMutedChanged();
184   void gridEnabledChanged();
185   void faceDetectionEnabledChanged();
186   void zoomAsShutterChanged();
187   void proximityAsShutterChanged();
188   void deviceAboutToChange();
189   void deviceChanged();
190
191 private:
192   DeviceSettings *deviceSettings();
193   QVariant deviceValue(const char *key, const QVariant& defaultValue);
194   void setDeviceValue(const char *key, const QVariant& value);
195
196   QSettings *m_settings;
197   DeviceSettings *m_device;
198 };
199
200 #endif /* SETTINGS_H */