1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 ** |
|
7 ** This file is part of the Qt Mobility Components. |
|
8 ** |
|
9 ** $QT_BEGIN_LICENSE:LGPL$ |
|
10 ** No Commercial Usage |
|
11 ** This file contains pre-release code and may not be distributed. |
|
12 ** You may use this file in accordance with the terms and conditions |
|
13 ** contained in the Technology Preview License Agreement accompanying |
|
14 ** this package. |
|
15 ** |
|
16 ** GNU Lesser General Public License Usage |
|
17 ** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 ** General Public License version 2.1 as published by the Free Software |
|
19 ** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 ** packaging of this file. Please review the following information to |
|
21 ** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 ** |
|
24 ** In addition, as a special exception, Nokia gives you certain additional |
|
25 ** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 ** |
|
28 ** If you have questions regarding the use of this file, please contact |
|
29 ** Nokia at qt-info@nokia.com. |
|
30 ** |
|
31 ** |
|
32 ** |
|
33 ** |
|
34 ** |
|
35 ** |
|
36 ** |
|
37 ** |
|
38 ** $QT_END_LICENSE$ |
|
39 ** |
|
40 ****************************************************************************/ |
|
41 |
|
42 #include "s60cameraexposurecontrol.h" |
|
43 #include "s60cameraservice.h" |
|
44 #include "s60camerasession.h" |
|
45 |
|
46 #include <QtCore/qdebug.h> |
|
47 #include <QtCore/qstring.h> |
|
48 |
|
49 |
|
50 S60CameraExposureControl::S60CameraExposureControl(QObject *parent) |
|
51 :QCameraExposureControl(parent) |
|
52 { |
|
53 } |
|
54 |
|
55 S60CameraExposureControl::S60CameraExposureControl(QObject *session, QObject *parent) |
|
56 :QCameraExposureControl(parent) |
|
57 , m_error(QCamera::NoError) |
|
58 , m_flashMode(QCamera::FlashOff) |
|
59 , m_exposureMode(QCamera::ExposureAuto) |
|
60 , m_meteringMode(QCamera::MeteringMatrix) |
|
61 , m_ev(0.0) |
|
62 { |
|
63 // use cast if we want to change session class later on.. |
|
64 m_session = qobject_cast<S60CameraSession*>(session); |
|
65 m_advancedSettings = m_session->advancedSettings(); |
|
66 |
|
67 connect(m_advancedSettings, SIGNAL(exposureLocked()), this, SIGNAL(exposureLocked())); |
|
68 connect(m_advancedSettings, SIGNAL(flashReady(bool)), this, SIGNAL(flashReady(bool))); |
|
69 connect(m_advancedSettings, SIGNAL(apertureChanged(qreal)), this, SIGNAL(apertureChanged(qreal))); |
|
70 connect(m_advancedSettings, SIGNAL(apertureRangeChanged()), this, SIGNAL(apertureRangeChanged())); |
|
71 connect(m_advancedSettings, SIGNAL(shutterSpeedChanged(qreal)), this, SIGNAL(shutterSpeedChanged(qreal))); |
|
72 connect(m_advancedSettings, SIGNAL(isoSensitivityChanged(int)), this, SIGNAL(isoSensitivityChanged(int))); |
|
73 } |
|
74 |
|
75 S60CameraExposureControl::~S60CameraExposureControl() |
|
76 { |
|
77 m_advancedSettings = NULL; |
|
78 } |
|
79 |
|
80 |
|
81 QCamera::FlashMode S60CameraExposureControl::flashMode() const |
|
82 { |
|
83 return m_session->flashMode(); |
|
84 } |
|
85 |
|
86 void S60CameraExposureControl::setFlashMode(QCamera::FlashMode mode) |
|
87 { |
|
88 QCamera::FlashModes supportedModes = supportedFlashModes(); |
|
89 if (supportedModes & mode) { |
|
90 m_flashMode = mode; |
|
91 m_session->setFlashMode(m_flashMode); |
|
92 } |
|
93 } |
|
94 |
|
95 QCamera::FlashModes S60CameraExposureControl::supportedFlashModes() const |
|
96 { |
|
97 return m_session->supportedFlashModes(); |
|
98 } |
|
99 |
|
100 bool S60CameraExposureControl::isFlashReady() const |
|
101 { |
|
102 return m_advancedSettings->isFlashReady(); |
|
103 } |
|
104 |
|
105 QCamera::ExposureMode S60CameraExposureControl::exposureMode() const |
|
106 { |
|
107 return m_session->exposureMode(); |
|
108 } |
|
109 |
|
110 void S60CameraExposureControl::setExposureMode(QCamera::ExposureMode mode) |
|
111 { |
|
112 //qDebug() << "S60CameraExposureControl::setExposureMode"; |
|
113 QCamera::ExposureModes supportedModes = supportedExposureModes(); |
|
114 if (supportedModes & mode) { |
|
115 m_exposureMode = mode; |
|
116 //qDebug() << "Set exposure mode"; |
|
117 m_session->setExposureMode(m_exposureMode); |
|
118 } |
|
119 } |
|
120 |
|
121 QCamera::ExposureModes S60CameraExposureControl::supportedExposureModes() const |
|
122 { |
|
123 return m_session->supportedExposureModes(); |
|
124 } |
|
125 |
|
126 qreal S60CameraExposureControl::exposureCompensation() const |
|
127 { |
|
128 return m_advancedSettings->exposureCompensation(); |
|
129 } |
|
130 |
|
131 void S60CameraExposureControl::setExposureCompensation(qreal ev) |
|
132 { |
|
133 m_advancedSettings->setExposureCompensation(ev); |
|
134 m_ev = ev; |
|
135 } |
|
136 |
|
137 QCamera::MeteringMode S60CameraExposureControl::meteringMode() const |
|
138 { |
|
139 return m_advancedSettings->meteringMode(); |
|
140 } |
|
141 |
|
142 void S60CameraExposureControl::setMeteringMode(QCamera::MeteringMode mode) |
|
143 { |
|
144 QCamera::MeteringModes supportedModes = supportedMeteringModes(); |
|
145 if (supportedModes & mode) { |
|
146 m_meteringMode = mode; |
|
147 m_advancedSettings->setMeteringMode(mode); |
|
148 } |
|
149 } |
|
150 |
|
151 QCamera::MeteringModes S60CameraExposureControl::supportedMeteringModes() const |
|
152 { |
|
153 return m_advancedSettings->supportedMeteringModes(); |
|
154 } |
|
155 |
|
156 int S60CameraExposureControl::isoSensitivity() const |
|
157 { |
|
158 return m_advancedSettings->isoSensitivity(); |
|
159 } |
|
160 |
|
161 QList<int> S60CameraExposureControl::supportedIsoSensitivities(bool *continuous) const |
|
162 { |
|
163 Q_UNUSED(continuous); |
|
164 return m_advancedSettings->supportedIsoSensitivities(); |
|
165 } |
|
166 |
|
167 void S60CameraExposureControl::setManualIsoSensitivity(int iso) |
|
168 { |
|
169 int minIso = supportedIsoSensitivities().first(); |
|
170 int maxIso = supportedIsoSensitivities().last(); |
|
171 if (iso < minIso) { |
|
172 iso = minIso; |
|
173 } else if (iso > maxIso) { |
|
174 iso = maxIso; |
|
175 } |
|
176 m_advancedSettings->setManualIsoSensitivity(iso); |
|
177 } |
|
178 |
|
179 void S60CameraExposureControl::setAutoIsoSensitivity() |
|
180 { |
|
181 m_error = QCamera::NotSupportedFeatureError; |
|
182 } |
|
183 |
|
184 qreal S60CameraExposureControl::aperture() const |
|
185 { |
|
186 return m_advancedSettings->aperture(); |
|
187 } |
|
188 |
|
189 QList<qreal> S60CameraExposureControl::supportedApertures(bool *continuous) const |
|
190 { |
|
191 return m_advancedSettings->supportedApertures(continuous); |
|
192 } |
|
193 |
|
194 void S60CameraExposureControl::setManualAperture(qreal aperture) |
|
195 { |
|
196 int minIso = supportedApertures().first(); |
|
197 int maxIso = supportedApertures().last(); |
|
198 if (aperture < minIso) { |
|
199 aperture = minIso; |
|
200 } else if (aperture > maxIso) { |
|
201 aperture = maxIso; |
|
202 } |
|
203 m_advancedSettings->setManualAperture(aperture); |
|
204 } |
|
205 |
|
206 void S60CameraExposureControl::setAutoAperture() |
|
207 { |
|
208 m_error = QCamera::NotSupportedFeatureError; |
|
209 } |
|
210 |
|
211 qreal S60CameraExposureControl::shutterSpeed() const |
|
212 { |
|
213 return m_advancedSettings->shutterSpeed(); |
|
214 } |
|
215 |
|
216 /* |
|
217 Returns the list of shutter speed values if camera supports only fixed set of shutter speed values, |
|
218 otherwise returns an empty list. |
|
219 */ |
|
220 QList<qreal> S60CameraExposureControl::supportedShutterSpeeds(bool *continuous) const |
|
221 { |
|
222 return m_advancedSettings->supportedShutterSpeeds(continuous);; |
|
223 } |
|
224 |
|
225 void S60CameraExposureControl::setManualShutterSpeed(qreal seconds) |
|
226 { |
|
227 m_advancedSettings->setShutterSpeed(seconds); |
|
228 } |
|
229 |
|
230 void S60CameraExposureControl::setAutoShutterSpeed() |
|
231 { |
|
232 m_error = QCamera::NotSupportedFeatureError; |
|
233 } |
|
234 |
|
235 bool S60CameraExposureControl::isExposureLocked() const |
|
236 { |
|
237 return m_advancedSettings->isExposureLocked(); |
|
238 } |
|
239 |
|
240 void S60CameraExposureControl::lockExposure() |
|
241 { |
|
242 m_advancedSettings->lockExposure(true); |
|
243 } |
|
244 |
|
245 void S60CameraExposureControl::unlockExposure() |
|
246 { |
|
247 m_advancedSettings->lockExposure(false); |
|
248 } |
|