4 * This file is part of CameraPlus.
6 * Copyright (C) 2012-2013 Mohammed Sameer <msameer@foolab.org>
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.
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.
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
23 #include "devicesettings.h"
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"
42 DeviceSettings::DeviceSettings(const QHash<QString, QVariant>& defaultSettings) :
43 m_settings(defaultSettings) {
47 DeviceSettings::~DeviceSettings() {
51 QVariant DeviceSettings::value(const QString& key) const {
52 if (!m_settings.contains(key)) {
53 qFatal("%s not found", qPrintable(key));
58 return m_settings[key];
61 QVariant DeviceSettings::defaultImageResolution() const {
62 return value(IMAGE_RESOLUTION_KEY);
65 QVariant DeviceSettings::defaultVideoResolution() const {
66 return value(VIDEO_RESOLUTION_KEY);
69 QVariant DeviceSettings::defaultImageAspectRatio() const {
70 return value(IMAGE_ASPECT_RATIO_KEY);
73 QVariant DeviceSettings::defaultVideoAspectRatio() const {
74 return value(VIDEO_ASPECT_RATIO_KEY);
77 QVariant DeviceSettings::defaultImageSceneMode() const {
78 return value(IMAGE_SCENE_MODE_KEY);
81 QVariant DeviceSettings::defaultVideoSceneMode() const {
82 return value(VIDEO_SCENE_MODE_KEY);
85 QVariant DeviceSettings::defaultImageColorFilter() const {
86 return value(IMAGE_COLOR_FILTER_KEY);
89 QVariant DeviceSettings::defaultVideoColorFilter() const {
90 return value(VIDEO_COLOR_FILTER_KEY);
93 QVariant DeviceSettings::defaultImageWhiteBalance() const {
94 return value(IMAGE_WHITE_BALANCE_KEY);
97 QVariant DeviceSettings::defaultVideoWhiteBalance() const {
98 return value(VIDEO_WHITE_BALANCE_KEY);
101 QVariant DeviceSettings::defaultImageEvComp() const {
102 return value(IMAGE_EV_COMP_KEY);
105 QVariant DeviceSettings::defaultVideoEvComp() const {
106 return value(VIDEO_EV_COMP_KEY);
109 QVariant DeviceSettings::defaultImageFlashMode() const {
110 return value(IMAGE_FLASH_MODE_KEY);
113 QVariant DeviceSettings::defaultImageIso() const {
114 return value(IMAGE_ISO_KEY);
117 QVariant DeviceSettings::defaultVideoTorchOn() const {
118 return value(VIDEO_TORCH_ON_KEY);
121 PrimaryDeviceSettings::PrimaryDeviceSettings() :
122 DeviceSettings(settings()) {
126 QString PrimaryDeviceSettings::id() const {
130 QHash<QString, QVariant> PrimaryDeviceSettings::settings() const {
131 QHash<QString, QVariant> hash;
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;
152 SecondaryDeviceSettings::SecondaryDeviceSettings() :
153 DeviceSettings(settings()) {
157 QString SecondaryDeviceSettings::id() const {
161 QHash<QString, QVariant> SecondaryDeviceSettings::settings() const {
162 QHash<QString, QVariant> hash;
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;