Switch toolbar animation to opacity
[harmattan/cameraplus] / src / devicesettings.cpp
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 #include "devicesettings.h"
24 #include <QDebug>
25
26 #define IMAGE_RESOLUTION_KEY        "imageResolution"
27 #define IMAGE_ASPECT_RATIO_KEY      "imageAspectRatio"
28 #define VIDEO_RESOLUTION_KEY        "videoResolution"
29 #define VIDEO_ASPECT_RATIO_KEY      "videoAspectRatio"
30 #define IMAGE_SCENE_MODE_KEY        "imageSceneMode"
31 #define VIDEO_SCENE_MODE_KEY        "videoSceneMode"
32 #define IMAGE_COLOR_FILTER_KEY      "imageColorFilter"
33 #define VIDEO_COLOR_FILTER_KEY      "videoColorFilter"
34 #define IMAGE_WHITE_BALANCE_KEY     "imageWhiteBalance"
35 #define VIDEO_WHITE_BALANCE_KEY     "videoWhiteBalance"
36 #define IMAGE_EV_COMP_KEY           "imageEvComp"
37 #define VIDEO_EV_COMP_KEY           "videoEvComp"
38 #define IMAGE_FLASH_MODE_KEY        "imageFlashMode"
39 #define VIDEO_TORCH_ON_KEY          "videoTorchOn"
40 #define IMAGE_ISO_KEY               "imageIso"
41
42 DeviceSettings::DeviceSettings(const QHash<QString, QVariant>& defaultSettings) :
43   m_settings(defaultSettings) {
44
45 }
46
47 DeviceSettings::~DeviceSettings() {
48
49 }
50
51 QVariant DeviceSettings::value(const QString& key) const {
52   if (!m_settings.contains(key)) {
53     qFatal("%s not found", qPrintable(key));
54
55     return QVariant();
56   }
57
58   return m_settings[key];
59 }
60
61 QVariant DeviceSettings::defaultImageResolution() const {
62   return value(IMAGE_RESOLUTION_KEY);
63 }
64
65 QVariant DeviceSettings::defaultVideoResolution() const {
66   return value(VIDEO_RESOLUTION_KEY);
67 }
68
69 QVariant DeviceSettings::defaultImageAspectRatio() const {
70   return value(IMAGE_ASPECT_RATIO_KEY);
71 }
72
73 QVariant DeviceSettings::defaultVideoAspectRatio() const {
74   return value(VIDEO_ASPECT_RATIO_KEY);
75 }
76
77 QVariant DeviceSettings::defaultImageSceneMode() const {
78   return value(IMAGE_SCENE_MODE_KEY);
79 }
80
81 QVariant DeviceSettings::defaultVideoSceneMode() const {
82   return value(VIDEO_SCENE_MODE_KEY);
83 }
84
85 QVariant DeviceSettings::defaultImageColorFilter() const {
86   return value(IMAGE_COLOR_FILTER_KEY);
87 }
88
89 QVariant DeviceSettings::defaultVideoColorFilter() const {
90   return value(VIDEO_COLOR_FILTER_KEY);
91 }
92
93 QVariant DeviceSettings::defaultImageWhiteBalance() const {
94   return value(IMAGE_WHITE_BALANCE_KEY);
95 }
96
97 QVariant DeviceSettings::defaultVideoWhiteBalance() const {
98   return value(VIDEO_WHITE_BALANCE_KEY);
99 }
100
101 QVariant DeviceSettings::defaultImageEvComp() const {
102   return value(IMAGE_EV_COMP_KEY);
103 }
104
105 QVariant DeviceSettings::defaultVideoEvComp() const {
106   return value(VIDEO_EV_COMP_KEY);
107 }
108
109 QVariant DeviceSettings::defaultImageFlashMode() const {
110   return value(IMAGE_FLASH_MODE_KEY);
111 }
112
113 QVariant DeviceSettings::defaultImageIso() const {
114   return value(IMAGE_ISO_KEY);
115 }
116
117 QVariant DeviceSettings::defaultVideoTorchOn() const {
118   return value(VIDEO_TORCH_ON_KEY);
119 }
120
121 PrimaryDeviceSettings::PrimaryDeviceSettings() :
122   DeviceSettings(settings()) {
123
124 }
125
126 QString PrimaryDeviceSettings::id() const {
127   return "primary";
128 }
129
130 QHash<QString, QVariant> PrimaryDeviceSettings::settings() const {
131   QHash<QString, QVariant> hash;
132
133   hash[IMAGE_RESOLUTION_KEY] = "high";
134   hash[IMAGE_ASPECT_RATIO_KEY] = "16:9";
135   hash[VIDEO_RESOLUTION_KEY] = "high";
136   hash[VIDEO_ASPECT_RATIO_KEY] = "16:9";
137   hash[IMAGE_SCENE_MODE_KEY] = 6;
138   hash[VIDEO_SCENE_MODE_KEY] = 6;
139   hash[IMAGE_COLOR_FILTER_KEY] = 0;
140   hash[VIDEO_COLOR_FILTER_KEY] = 0;
141   hash[IMAGE_WHITE_BALANCE_KEY] = 0;
142   hash[VIDEO_WHITE_BALANCE_KEY] = 0;
143   hash[IMAGE_EV_COMP_KEY] = 0.0;
144   hash[VIDEO_EV_COMP_KEY] = 0.0;
145   hash[IMAGE_FLASH_MODE_KEY] = 0;
146   hash[VIDEO_TORCH_ON_KEY] = false;
147   hash[IMAGE_ISO_KEY] = 0;
148
149   return hash;
150 }
151
152 SecondaryDeviceSettings::SecondaryDeviceSettings() :
153   DeviceSettings(settings()) {
154
155 }
156
157 QString SecondaryDeviceSettings::id() const {
158   return "secondary";
159 }
160
161 QHash<QString, QVariant> SecondaryDeviceSettings::settings() const {
162   QHash<QString, QVariant> hash;
163
164   hash[IMAGE_RESOLUTION_KEY] = "low";
165   hash[IMAGE_ASPECT_RATIO_KEY] = "4:3";
166   hash[VIDEO_RESOLUTION_KEY] = "low";
167   hash[VIDEO_ASPECT_RATIO_KEY] = "4:3";
168   hash[IMAGE_SCENE_MODE_KEY] = 6;
169   hash[VIDEO_SCENE_MODE_KEY] = 6;
170   hash[IMAGE_COLOR_FILTER_KEY] = 0;
171   hash[VIDEO_COLOR_FILTER_KEY] = 0;
172   hash[IMAGE_WHITE_BALANCE_KEY] = 0;
173   hash[VIDEO_WHITE_BALANCE_KEY] = 0;
174   hash[IMAGE_EV_COMP_KEY] = 0.0;
175   hash[VIDEO_EV_COMP_KEY] = 0.0;
176   hash[IMAGE_FLASH_MODE_KEY] = 0;
177   hash[VIDEO_TORCH_ON_KEY] = false;
178   hash[IMAGE_ISO_KEY] = 0;
179
180   return hash;
181 }