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