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