28
|
1 |
/*
|
|
2 |
* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
#include <hbframeitem.h>
|
|
18 |
|
|
19 |
#include "cxenamespace.h"
|
|
20 |
#include "cxesettings.h"
|
|
21 |
#include "cxuiscenemodeview.h"
|
|
22 |
#include "cxuienums.h"
|
|
23 |
#include "cxutils.h"
|
|
24 |
#include "cxuicapturekeyhandler.h"
|
|
25 |
#include "cxuisettingsinfo.h"
|
|
26 |
#include "cxeviewfindercontrol.h"
|
|
27 |
#include "cxecameradevicecontrol.h"
|
|
28 |
#include "cxuidocumentloader.h"
|
|
29 |
|
|
30 |
using namespace Cxe;
|
|
31 |
using namespace CxUi;
|
|
32 |
using namespace CxUiLayout;
|
|
33 |
using namespace CxUiSettings;
|
|
34 |
using namespace CxeSettingIds;
|
|
35 |
|
|
36 |
const int CXUI_SCENES_TRANSITION_TIME = 350; // 350 milliseconds
|
|
37 |
const int CXUI_SCENES_CAMERA_TIMEOUT = 60000; // 60 seconds for the camera hw release timeout
|
|
38 |
const QString CXUI_SCENES_AUTOMATIC_IMAGE=":/camerax/scene_automatic.png";
|
|
39 |
const QString CXUI_SCENES_LANDSCAPE_IMAGE=":/camerax/scene_landscape.png";
|
|
40 |
const QString CXUI_SCENES_CLOSEUP_IMAGE=":/camerax/scene_close-up.png";
|
|
41 |
const QString CXUI_SCENES_PORTRAIT_IMAGE=":/camerax/scene_portrait.png";
|
|
42 |
const QString CXUI_SCENES_SPORT_IMAGE=":/camerax/scene_sport.png";
|
|
43 |
const QString CXUI_SCENES_NIGHT_IMAGE=":/camerax/scene_night.png";
|
|
44 |
const QString CXUI_SCENES_NIGHT_PORTRAIT_IMAGE=":/camerax/scene_nightportrait.png";
|
|
45 |
const QString CXUI_SCENES_LOW_LIGHT_IMAGE=":/camerax/scene_lowlight.png";
|
|
46 |
|
|
47 |
|
|
48 |
/*!
|
|
49 |
* Constructor
|
|
50 |
*/
|
|
51 |
CxuiSceneModeView::CxuiSceneModeView(QGraphicsItem *parent) :
|
39
|
52 |
CxuiView(parent),
|
28
|
53 |
mSettingsInfo(NULL),
|
40
|
54 |
mScenesBackground(NULL),
|
|
55 |
mScenesHeading(NULL)
|
28
|
56 |
{
|
|
57 |
CX_DEBUG_IN_FUNCTION();
|
|
58 |
}
|
|
59 |
|
|
60 |
/*!
|
|
61 |
* Destructor
|
|
62 |
*/
|
|
63 |
CxuiSceneModeView::~CxuiSceneModeView()
|
|
64 |
{
|
|
65 |
CX_DEBUG_ENTER_FUNCTION();
|
|
66 |
CX_DEBUG_EXIT_FUNCTION();
|
|
67 |
}
|
|
68 |
|
|
69 |
/*!
|
|
70 |
* Construct-method handles initialisation tasks for this class. Needs to be called
|
|
71 |
* before the instance of this class is used.
|
|
72 |
* @param mainwindow
|
|
73 |
* @param engine
|
|
74 |
* @param documentLoader
|
|
75 |
* @param keyHandler
|
|
76 |
*/
|
|
77 |
void CxuiSceneModeView::construct(HbMainWindow *mainwindow,
|
|
78 |
CxeEngine *engine,
|
|
79 |
CxuiDocumentLoader *documentLoader,
|
|
80 |
CxuiCaptureKeyHandler *keyHandler)
|
|
81 |
{
|
|
82 |
CX_DEBUG_ENTER_FUNCTION();
|
39
|
83 |
CxuiView::construct(mainwindow, engine, documentLoader, keyHandler);
|
28
|
84 |
|
|
85 |
mSettingsInfo = new CxuiSettingsInfo(mEngine);
|
|
86 |
setContentFullScreen(true);
|
|
87 |
loadDefaultWidgets();
|
|
88 |
|
39
|
89 |
mCameraReleaseTimer.setInterval(CXUI_SCENES_CAMERA_TIMEOUT);
|
|
90 |
mCameraReleaseTimer.setSingleShot(true);
|
|
91 |
connect(&mCameraReleaseTimer, SIGNAL(timeout()), this, SLOT(releaseCamera()), Qt::UniqueConnection);
|
28
|
92 |
|
|
93 |
CX_DEBUG_EXIT_FUNCTION();
|
|
94 |
}
|
|
95 |
|
|
96 |
/*!
|
|
97 |
* Load widgets from DocML.
|
|
98 |
*/
|
|
99 |
void CxuiSceneModeView::loadDefaultWidgets()
|
|
100 |
{
|
|
101 |
CX_DEBUG_ENTER_FUNCTION();
|
|
102 |
CX_DEBUG_ASSERT(mDocumentLoader);
|
|
103 |
|
|
104 |
QGraphicsWidget *widget = NULL;
|
|
105 |
|
|
106 |
widget = mDocumentLoader->findWidget(SCENE_VIEW_CONTAINER);
|
|
107 |
mScenesContainer = qobject_cast<HbWidget *> (widget);
|
|
108 |
|
40
|
109 |
mScenesHeading = qobject_cast<HbLabel *>(
|
|
110 |
mDocumentLoader->findWidget(SCENE_VIEW_HEADING_WIDGET));
|
|
111 |
CX_ASSERT_ALWAYS(mScenesHeading);
|
|
112 |
|
28
|
113 |
//Now let's retreive the pointer to icon widget
|
|
114 |
widget = mDocumentLoader->findWidget(SCENE_VIEW_BG_IMAGE);
|
|
115 |
mScenesBackground = qobject_cast<HbLabel *> (widget);
|
|
116 |
|
|
117 |
widget = mDocumentLoader->findWidget(SCENE_VIEW_BG_IMAGE2);
|
|
118 |
mScenesBackground2 = qobject_cast<HbLabel *> (widget);
|
|
119 |
|
|
120 |
//Assuming that the automatic scene mode is always the default one
|
|
121 |
CX_DEBUG(("CxuiSceneModeView::loadDefaultWidgets -> Now setting default image"));
|
|
122 |
mScenesBackground->setIcon(HbIcon(CXUI_SCENES_AUTOMATIC_IMAGE));
|
|
123 |
|
|
124 |
widget = mDocumentLoader->findWidget(SCENE_VIEW_RADIOBUTTONS);
|
|
125 |
mScenesList = qobject_cast<CxuiSettingRadioButtonList *> (widget);
|
|
126 |
|
|
127 |
mTransitionAnimation = new QPropertyAnimation(mScenesBackground2, "opacity");
|
|
128 |
mTransitionAnimation->setDuration(CXUI_SCENES_TRANSITION_TIME);
|
|
129 |
|
|
130 |
createWidgetBackgroundGraphic(mScenesContainer, TRANSPARENT_BACKGROUND_GRAPHIC);
|
|
131 |
|
39
|
132 |
//!@todo: View flags property is missing from HbView,
|
|
133 |
// so can't properly hide title bar / status bar there.
|
|
134 |
hideControls();
|
|
135 |
|
28
|
136 |
connectSignals();
|
|
137 |
|
|
138 |
CX_DEBUG_EXIT_FUNCTION();
|
|
139 |
}
|
|
140 |
|
|
141 |
/*!
|
|
142 |
* Helper function to connect signals needed in this class.
|
|
143 |
*/
|
|
144 |
void CxuiSceneModeView::connectSignals()
|
|
145 |
{
|
|
146 |
connect(mScenesList, SIGNAL(itemSelected(int)), this, SLOT(handleSceneRadiobuttonPress(int)));
|
|
147 |
connect(mTransitionAnimation, SIGNAL(finished()), this, SLOT(finishScenesTransition()));
|
|
148 |
}
|
|
149 |
|
|
150 |
/*!
|
|
151 |
* This public method assumes that the view is already properly constructed
|
|
152 |
*/
|
|
153 |
void CxuiSceneModeView::loadBackgroundImages()
|
|
154 |
{
|
|
155 |
CX_DEBUG_ENTER_FUNCTION();
|
|
156 |
RadioButtonListParams data;
|
|
157 |
if (mEngine->mode() == Cxe::ImageMode) {
|
|
158 |
mSettingsInfo->getSettingsContent(CxeSettingIds::IMAGE_SCENE, data);
|
|
159 |
} else {
|
|
160 |
mSettingsInfo->getSettingsContent(CxeSettingIds::VIDEO_SCENE, data);
|
|
161 |
}
|
|
162 |
mSettingPairList = data.mSettingPairList;
|
|
163 |
mScenesList->init(&data);
|
|
164 |
|
40
|
165 |
if (mScenesHeading) {
|
|
166 |
mScenesHeading->setPlainText(data.mHeading);
|
|
167 |
}
|
|
168 |
|
28
|
169 |
if (mScenesBackground) {
|
|
170 |
QString sceneId;
|
|
171 |
mEngine->settings().get(data.mSettingId, sceneId);
|
|
172 |
mScenesBackground->setIcon(HbIcon(backgroundForScene(sceneId)));
|
|
173 |
} else {
|
|
174 |
//First time displaying a list
|
|
175 |
//Assuming that the automatic scene mode is always the default one and is on top of the list
|
|
176 |
mScenesList->setSelected(0);
|
|
177 |
}
|
|
178 |
CX_DEBUG_EXIT_FUNCTION();
|
|
179 |
}
|
|
180 |
|
|
181 |
/*!
|
|
182 |
* Handle selecting value in scene list.
|
|
183 |
*/
|
|
184 |
void CxuiSceneModeView::handleSceneRadiobuttonPress(int index)
|
|
185 |
{
|
|
186 |
CX_DEBUG_ENTER_FUNCTION();
|
|
187 |
|
|
188 |
CxUiSettings::SettingItem item = mSettingPairList.at(index);
|
|
189 |
QString sceneId = item.mValue.toString();
|
|
190 |
mScenesBackground2->setIcon(HbIcon(backgroundForScene(sceneId)));
|
|
191 |
startBackgroundTransition();
|
|
192 |
CX_DEBUG_EXIT_FUNCTION();
|
|
193 |
}
|
|
194 |
|
|
195 |
|
|
196 |
/*!
|
|
197 |
* Helper method for getting the background graphic name
|
|
198 |
* for each of the scenes.
|
|
199 |
*/
|
|
200 |
QString CxuiSceneModeView::backgroundForScene(const QString& sceneId)
|
|
201 |
{
|
|
202 |
//!@todo: This mapping should be added to the setting xml.
|
|
203 |
if (sceneId == CxeSettingIds::IMAGE_SCENE_AUTO) {
|
|
204 |
return CXUI_SCENES_AUTOMATIC_IMAGE;
|
|
205 |
} else if (sceneId == CxeSettingIds::IMAGE_SCENE_PORTRAIT) {
|
|
206 |
return CXUI_SCENES_PORTRAIT_IMAGE;
|
|
207 |
} else if (sceneId == CxeSettingIds::IMAGE_SCENE_SCENERY) {
|
|
208 |
return CXUI_SCENES_LANDSCAPE_IMAGE;
|
|
209 |
} else if (sceneId == CxeSettingIds::IMAGE_SCENE_MACRO) {
|
|
210 |
return CXUI_SCENES_CLOSEUP_IMAGE;
|
|
211 |
} else if (sceneId == CxeSettingIds::IMAGE_SCENE_SPORTS) {
|
|
212 |
return CXUI_SCENES_SPORT_IMAGE;
|
|
213 |
} else if (sceneId == CxeSettingIds::IMAGE_SCENE_NIGHT) {
|
|
214 |
return CXUI_SCENES_NIGHT_IMAGE;
|
|
215 |
} else if (sceneId == CxeSettingIds::IMAGE_SCENE_NIGHTPORTRAIT) {
|
|
216 |
return CXUI_SCENES_NIGHT_PORTRAIT_IMAGE;
|
|
217 |
} else if (sceneId == CxeSettingIds::VIDEO_SCENE_AUTO) {
|
|
218 |
return CXUI_SCENES_AUTOMATIC_IMAGE;
|
|
219 |
} else if (sceneId == CxeSettingIds::VIDEO_SCENE_LOWLIGHT) {
|
|
220 |
return CXUI_SCENES_LOW_LIGHT_IMAGE;
|
|
221 |
} else if (sceneId == CxeSettingIds::VIDEO_SCENE_NIGHT) {
|
|
222 |
return CXUI_SCENES_NIGHT_IMAGE;
|
|
223 |
} else {
|
|
224 |
return "";
|
|
225 |
}
|
|
226 |
|
|
227 |
}
|
|
228 |
|
|
229 |
/*!
|
|
230 |
* Start animation for changing the scene background graphic.
|
|
231 |
*/
|
|
232 |
void CxuiSceneModeView::startBackgroundTransition()
|
|
233 |
{
|
|
234 |
mTransitionAnimation->setStartValue(0.0);
|
|
235 |
mTransitionAnimation->setEndValue(1.0);
|
|
236 |
mTransitionAnimation->start();
|
|
237 |
|
|
238 |
}
|
|
239 |
|
|
240 |
/*!
|
|
241 |
* Handle scene background graphic animation finishing.
|
|
242 |
*/
|
|
243 |
void CxuiSceneModeView::finishScenesTransition()
|
|
244 |
{
|
|
245 |
mScenesBackground->setIcon(mScenesBackground2->icon());
|
|
246 |
mScenesBackground2->setOpacity(0);
|
|
247 |
mScenesBackground2->setIcon(HbIcon());
|
|
248 |
}
|
|
249 |
|
|
250 |
/*!
|
|
251 |
* Handle press of ok button.
|
|
252 |
*/
|
|
253 |
void CxuiSceneModeView::handleOkButtonPress()
|
|
254 |
{
|
|
255 |
CX_DEBUG_ENTER_FUNCTION();
|
|
256 |
mScenesList->handleSelectionAccepted();
|
|
257 |
closeView();
|
|
258 |
CX_DEBUG_EXIT_FUNCTION();
|
|
259 |
}
|
|
260 |
|
|
261 |
/*!
|
|
262 |
* Handle press of cancel button.
|
|
263 |
*/
|
|
264 |
void CxuiSceneModeView::handleCancelButtonPress()
|
|
265 |
{
|
|
266 |
CX_DEBUG_ENTER_FUNCTION();
|
|
267 |
closeView();
|
|
268 |
CX_DEBUG_EXIT_FUNCTION();
|
|
269 |
}
|
|
270 |
|
|
271 |
/*!
|
|
272 |
* This view is about to be shown.
|
|
273 |
* Update the view to match currently selected scene.
|
|
274 |
*/
|
|
275 |
void CxuiSceneModeView::showEvent(QShowEvent *event)
|
|
276 |
{
|
|
277 |
CX_DEBUG_ENTER_FUNCTION();
|
|
278 |
mScenesList->scrollTo(mScenesList->currentIndex(), HbAbstractItemView::PositionAtTop);
|
|
279 |
|
|
280 |
mEngine->viewfinderControl().stop();
|
|
281 |
mCameraReleaseTimer.start();
|
|
282 |
QGraphicsWidget::showEvent(event);
|
|
283 |
CX_DEBUG_EXIT_FUNCTION();
|
|
284 |
}
|
|
285 |
|
|
286 |
/*!
|
39
|
287 |
* Allow showing UI controls?
|
|
288 |
* Title bar and other UI chrome is never shown in scene mode view.
|
|
289 |
*/
|
|
290 |
bool CxuiSceneModeView::allowShowControls() const
|
|
291 |
{
|
|
292 |
return false;
|
|
293 |
}
|
|
294 |
|
|
295 |
/*!
|
28
|
296 |
* Slot to handle capture key full press.
|
|
297 |
*/
|
|
298 |
void CxuiSceneModeView::handleCaptureKeyPressed()
|
|
299 |
{
|
|
300 |
CX_DEBUG_ENTER_FUNCTION();
|
|
301 |
closeView();
|
|
302 |
CX_DEBUG_EXIT_FUNCTION();
|
|
303 |
}
|
|
304 |
|
|
305 |
/*!
|
|
306 |
* Slot to handle capture key half press / autofocus key press.
|
|
307 |
*/
|
|
308 |
void CxuiSceneModeView::handleAutofocusKeyPressed()
|
|
309 |
{
|
|
310 |
CX_DEBUG_ENTER_FUNCTION();
|
|
311 |
closeView();
|
|
312 |
CX_DEBUG_EXIT_FUNCTION();
|
|
313 |
}
|
|
314 |
|
|
315 |
/*!
|
|
316 |
* Closing the view and reactivating camera hw if needed
|
|
317 |
*/
|
|
318 |
void CxuiSceneModeView::closeView()
|
|
319 |
{
|
|
320 |
CX_DEBUG_ENTER_FUNCTION();
|
|
321 |
mScenesList->handleClose();
|
|
322 |
mScenesBackground->setIcon(HbIcon());
|
40
|
323 |
mScenesHeading = NULL;
|
28
|
324 |
// Make sure engine prepares for new image/video if necessary
|
|
325 |
mEngine->initMode(mEngine->mode());
|
|
326 |
emit viewCloseEvent();
|
|
327 |
CX_DEBUG_EXIT_FUNCTION();
|
|
328 |
}
|
|
329 |
|
|
330 |
// end of file
|
|
331 |
|