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 "s60camerafocuscontrol.h" |
|
43 #include "s60cameraservice.h" |
|
44 #include "s60camerasession.h" |
|
45 |
|
46 #include <QtCore/qdebug.h> |
|
47 #include <QtCore/qstring.h> |
|
48 |
|
49 |
|
50 S60CameraFocusControl::S60CameraFocusControl(QObject *parent) |
|
51 :QCameraFocusControl(parent) |
|
52 { |
|
53 m_session = qobject_cast<S60CameraSession*>(parent); |
|
54 } |
|
55 |
|
56 S60CameraFocusControl::S60CameraFocusControl(QObject *session, QObject *parent) |
|
57 :QCameraFocusControl(parent) |
|
58 , m_focusLocked(false) |
|
59 , m_opticalZoomValue(1.0) |
|
60 , m_digitalZoomValue(1.0) |
|
61 , m_maxZoom(1.0) |
|
62 , m_maxDigitalZoom(1.0) |
|
63 , m_macroFocusingEnabled(false) |
|
64 , m_focusMode(QCamera::AutoFocus) |
|
65 , m_focusStatus(QCamera::FocusInitial) |
|
66 , m_error(QCamera::NoError) |
|
67 { |
|
68 // use cast if we want to change session class later on.. |
|
69 m_session = qobject_cast<S60CameraSession*>(session); |
|
70 m_advancedSettings = m_session->advancedSettings(); |
|
71 connect(m_session, SIGNAL(opticalZoomChanged(qreal)), this, SIGNAL(opticalZoomChanged(qreal))); |
|
72 connect(m_session, SIGNAL(digitalZoomChanged(qreal)), this, SIGNAL(digitalZoomChanged(qreal))); |
|
73 connect(m_session, SIGNAL(focusStatusChanged(QCamera::FocusStatus)), this, SLOT(focusChanged(QCamera::FocusStatus))); |
|
74 m_advancedSettings->setFocusMode(m_focusMode); |
|
75 m_session->setZoomFactor(m_opticalZoomValue, m_digitalZoomValue); |
|
76 } |
|
77 |
|
78 S60CameraFocusControl::~S60CameraFocusControl() |
|
79 { |
|
80 } |
|
81 |
|
82 QCamera::FocusMode S60CameraFocusControl::focusMode() const |
|
83 { |
|
84 return m_advancedSettings->focusMode(); |
|
85 } |
|
86 |
|
87 void S60CameraFocusControl::setFocusMode(QCamera::FocusMode mode) |
|
88 { |
|
89 m_advancedSettings->setFocusMode(mode); |
|
90 m_focusMode = mode; |
|
91 } |
|
92 |
|
93 QCamera::FocusModes S60CameraFocusControl::supportedFocusModes() const |
|
94 { |
|
95 return m_advancedSettings->supportedFocusModes(); |
|
96 } |
|
97 |
|
98 QCamera::FocusStatus S60CameraFocusControl::focusStatus() const |
|
99 { |
|
100 return m_focusStatus; |
|
101 } |
|
102 |
|
103 bool S60CameraFocusControl::macroFocusingEnabled() const |
|
104 { |
|
105 return m_macroFocusingEnabled; |
|
106 } |
|
107 |
|
108 bool S60CameraFocusControl::isMacroFocusingSupported() const |
|
109 { |
|
110 // not supported |
|
111 return false; |
|
112 } |
|
113 |
|
114 void S60CameraFocusControl::setMacroFocusingEnabled(bool /*e*/) |
|
115 { |
|
116 // not supported |
|
117 m_error = QCamera::NotSupportedFeatureError; |
|
118 } |
|
119 |
|
120 qreal S60CameraFocusControl::maximumOpticalZoom() const |
|
121 { |
|
122 return m_session->maximumZoom(); |
|
123 } |
|
124 |
|
125 qreal S60CameraFocusControl::maximumDigitalZoom() const |
|
126 { |
|
127 return m_session->maxDigitalZoom(); |
|
128 } |
|
129 |
|
130 qreal S60CameraFocusControl::opticalZoom() const |
|
131 { |
|
132 return m_session->zoomFactor(); |
|
133 } |
|
134 |
|
135 qreal S60CameraFocusControl::digitalZoom() const |
|
136 { |
|
137 return m_session->digitalZoomFactor(); |
|
138 } |
|
139 |
|
140 void S60CameraFocusControl::zoomTo(qreal optical, qreal digital) |
|
141 { |
|
142 m_session->setZoomFactor(optical, digital); |
|
143 m_opticalZoomValue = optical; |
|
144 m_digitalZoomValue = digital; |
|
145 } |
|
146 |
|
147 void S60CameraFocusControl::startFocusing() |
|
148 { |
|
149 m_session->startFocus(); |
|
150 m_focusStatus = QCamera::FocusRequested; |
|
151 emit focusStatusChanged(QCamera::FocusRequested); |
|
152 } |
|
153 |
|
154 void S60CameraFocusControl::cancelFocusing() |
|
155 { |
|
156 m_session->cancelFocus(); |
|
157 m_focusStatus = QCamera::FocusCanceled; |
|
158 emit focusStatusChanged(QCamera::FocusCanceled); |
|
159 } |
|
160 |
|
161 void S60CameraFocusControl::focusChanged(QCamera::FocusStatus status) |
|
162 { |
|
163 m_focusStatus = status; |
|
164 emit focusStatusChanged(status); |
|
165 } |
|
166 |
|