78 * @param keyHandler |
76 * @param keyHandler |
79 */ |
77 */ |
80 void CxuiSceneModeView::construct(HbMainWindow *mainwindow, |
78 void CxuiSceneModeView::construct(HbMainWindow *mainwindow, |
81 CxeEngine *engine, |
79 CxeEngine *engine, |
82 CxuiDocumentLoader *documentLoader, |
80 CxuiDocumentLoader *documentLoader, |
83 CxuiCaptureKeyHandler *keyHandler) |
81 CxuiCaptureKeyHandler *keyHandler, |
84 { |
82 HbActivityManager *activityManager) |
85 CX_DEBUG_ENTER_FUNCTION(); |
83 { |
86 |
84 CX_DEBUG_ENTER_FUNCTION(); |
87 mMainWindow = mainwindow; |
85 CxuiView::construct(mainwindow, engine, documentLoader, keyHandler, activityManager); |
88 mDocumentLoader = documentLoader; |
86 |
89 mCaptureKeyHandler = keyHandler; |
|
90 mEngine = engine; |
|
91 mSettingsInfo = new CxuiSettingsInfo(mEngine); |
87 mSettingsInfo = new CxuiSettingsInfo(mEngine); |
92 setContentFullScreen(true); |
88 setContentFullScreen(true); |
93 loadDefaultWidgets(); |
89 loadDefaultWidgets(); |
94 |
90 |
95 mCameraReleaseTimer.setInterval(CXUI_SCENES_CAMERA_TIMEOUT); |
91 mCameraReleaseTimer.setInterval(CXUI_SCENES_CAMERA_TIMEOUT); |
96 connect(&mCameraReleaseTimer, SIGNAL(timeout()), this, SLOT(releaseCameraHw()), Qt::UniqueConnection); |
92 mCameraReleaseTimer.setSingleShot(true); |
|
93 connect(&mCameraReleaseTimer, SIGNAL(timeout()), this, SLOT(releaseCamera()), Qt::UniqueConnection); |
97 |
94 |
98 CX_DEBUG_EXIT_FUNCTION(); |
95 CX_DEBUG_EXIT_FUNCTION(); |
99 } |
96 } |
100 |
97 |
101 /*! |
98 /*! |
106 CX_DEBUG_ENTER_FUNCTION(); |
103 CX_DEBUG_ENTER_FUNCTION(); |
107 CX_DEBUG_ASSERT(mDocumentLoader); |
104 CX_DEBUG_ASSERT(mDocumentLoader); |
108 |
105 |
109 QGraphicsWidget *widget = NULL; |
106 QGraphicsWidget *widget = NULL; |
110 |
107 |
111 widget = mDocumentLoader->findWidget(SCENE_VIEW_CONTAINER); |
108 widget = mDocumentLoader->findWidget(SCENE_MODE_VIEW_CONTAINER); |
112 mScenesContainer = qobject_cast<HbWidget *> (widget); |
109 mScenesContainer = qobject_cast<HbWidget *> (widget); |
113 |
110 |
|
111 mScenesHeading = qobject_cast<HbLabel *>( |
|
112 mDocumentLoader->findWidget(SCENE_MODE_VIEW_HEADING_WIDGET)); |
|
113 CX_ASSERT_ALWAYS(mScenesHeading); |
|
114 |
114 //Now let's retreive the pointer to icon widget |
115 //Now let's retreive the pointer to icon widget |
115 widget = mDocumentLoader->findWidget(SCENE_VIEW_BG_IMAGE); |
116 widget = mDocumentLoader->findWidget(SCENE_MODE_VIEW_BG_IMAGE); |
116 mScenesBackground = qobject_cast<HbLabel *> (widget); |
117 mScenesBackground = qobject_cast<HbLabel *> (widget); |
117 |
118 |
118 widget = mDocumentLoader->findWidget(SCENE_VIEW_BG_IMAGE2); |
119 widget = mDocumentLoader->findWidget(SCENE_MODE_VIEW_BG_IMAGE2); |
119 mScenesBackground2 = qobject_cast<HbLabel *> (widget); |
120 mScenesBackground2 = qobject_cast<HbLabel *> (widget); |
120 |
121 |
121 //Assuming that the automatic scene mode is always the default one |
122 //Assuming that the automatic scene mode is always the default one |
122 CX_DEBUG(("CxuiSceneModeView::loadDefaultWidgets -> Now setting default image")); |
123 CX_DEBUG(("CxuiSceneModeView::loadDefaultWidgets -> Now setting default image")); |
123 mScenesBackground->setIcon(HbIcon(CXUI_SCENES_AUTOMATIC_IMAGE)); |
124 HbIcon background(CXUI_SCENES_AUTOMATIC_IMAGE); |
124 |
125 background.setMirroringMode(HbIcon::LayoutDirection); |
125 widget = mDocumentLoader->findWidget(SCENE_VIEW_RADIOBUTTONS); |
126 mScenesBackground->setIcon(background); |
|
127 |
|
128 widget = mDocumentLoader->findWidget(SCENE_MODE_VIEW_RADIOBUTTONS); |
126 mScenesList = qobject_cast<CxuiSettingRadioButtonList *> (widget); |
129 mScenesList = qobject_cast<CxuiSettingRadioButtonList *> (widget); |
127 |
130 |
128 mTransitionAnimation = new QPropertyAnimation(mScenesBackground2, "opacity"); |
131 mTransitionAnimation = new QPropertyAnimation(mScenesBackground2, "opacity"); |
129 mTransitionAnimation->setDuration(CXUI_SCENES_TRANSITION_TIME); |
132 mTransitionAnimation->setDuration(CXUI_SCENES_TRANSITION_TIME); |
130 |
133 |
131 createWidgetBackgroundGraphic(mScenesContainer, TRANSPARENT_BACKGROUND_GRAPHIC); |
134 createWidgetBackgroundGraphic(mScenesContainer, TRANSPARENT_BACKGROUND_GRAPHIC); |
132 |
135 |
|
136 //!@todo: View flags property is missing from HbView, |
|
137 // so can't properly hide title bar / status bar there. |
|
138 hideControls(); |
|
139 |
133 connectSignals(); |
140 connectSignals(); |
134 |
141 |
135 CX_DEBUG_EXIT_FUNCTION(); |
142 CX_DEBUG_EXIT_FUNCTION(); |
136 } |
143 } |
137 |
144 |
140 */ |
147 */ |
141 void CxuiSceneModeView::connectSignals() |
148 void CxuiSceneModeView::connectSignals() |
142 { |
149 { |
143 connect(mScenesList, SIGNAL(itemSelected(int)), this, SLOT(handleSceneRadiobuttonPress(int))); |
150 connect(mScenesList, SIGNAL(itemSelected(int)), this, SLOT(handleSceneRadiobuttonPress(int))); |
144 connect(mTransitionAnimation, SIGNAL(finished()), this, SLOT(finishScenesTransition())); |
151 connect(mTransitionAnimation, SIGNAL(finished()), this, SLOT(finishScenesTransition())); |
145 } |
|
146 |
|
147 /*! |
|
148 * Function can be used to create a graphics item and setting it as a background |
|
149 * item for HbWidget. graphicName refers to system wide graphic name. Given graphic |
|
150 * can consist of one, three or nine pieces. Nine piece graphics are used by default. |
|
151 * See HbFrameDrawer documentation for graphic naming. |
|
152 */ |
|
153 void CxuiSceneModeView::createWidgetBackgroundGraphic(HbWidget *widget, |
|
154 const QString &graphicName, |
|
155 HbFrameDrawer::FrameType frameType) |
|
156 { |
|
157 if (widget) { |
|
158 HbFrameDrawer *drawer = new HbFrameDrawer(graphicName, frameType); |
|
159 |
|
160 if (drawer) { |
|
161 HbFrameItem *backgroundItem = new HbFrameItem(drawer, widget); |
|
162 if (backgroundItem) { |
|
163 // set item to fill the whole widget |
|
164 backgroundItem->setGeometry(QRectF(QPointF(0, 0), widget->size())); |
|
165 backgroundItem->setZValue(0); |
|
166 widget->setBackgroundItem(backgroundItem); |
|
167 } |
|
168 } |
|
169 } |
|
170 } |
152 } |
171 |
153 |
172 /*! |
154 /*! |
173 * This public method assumes that the view is already properly constructed |
155 * This public method assumes that the view is already properly constructed |
174 */ |
156 */ |
182 mSettingsInfo->getSettingsContent(CxeSettingIds::VIDEO_SCENE, data); |
164 mSettingsInfo->getSettingsContent(CxeSettingIds::VIDEO_SCENE, data); |
183 } |
165 } |
184 mSettingPairList = data.mSettingPairList; |
166 mSettingPairList = data.mSettingPairList; |
185 mScenesList->init(&data); |
167 mScenesList->init(&data); |
186 |
168 |
|
169 if (mScenesHeading) { |
|
170 mScenesHeading->setPlainText(data.mHeading); |
|
171 } |
|
172 |
187 if (mScenesBackground) { |
173 if (mScenesBackground) { |
188 QString sceneId; |
174 QString sceneId; |
189 mEngine->settings().get(data.mSettingId, sceneId); |
175 mEngine->settings().get(data.mSettingId, sceneId); |
190 mScenesBackground->setIcon(HbIcon(backgroundForScene(sceneId))); |
176 HbIcon background(backgroundForScene(sceneId)); |
|
177 background.setMirroringMode(HbIcon::LayoutDirection); |
|
178 mScenesBackground->setIcon(background); |
191 } else { |
179 } else { |
192 //First time displaying a list |
180 //First time displaying a list |
193 //Assuming that the automatic scene mode is always the default one and is on top of the list |
181 //Assuming that the automatic scene mode is always the default one and is on top of the list |
194 mScenesList->setSelected(0); |
182 mScenesList->setSelected(0); |
195 } |
183 } |
196 CX_DEBUG_EXIT_FUNCTION(); |
184 CX_DEBUG_EXIT_FUNCTION(); |
197 } |
185 } |
198 |
186 |
199 /*! |
187 /*! |
|
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 /*! |
200 * Handle selecting value in scene list. |
210 * Handle selecting value in scene list. |
201 */ |
211 */ |
202 void CxuiSceneModeView::handleSceneRadiobuttonPress(int index) |
212 void CxuiSceneModeView::handleSceneRadiobuttonPress(int index) |
203 { |
213 { |
204 CX_DEBUG_ENTER_FUNCTION(); |
214 CX_DEBUG_ENTER_FUNCTION(); |
205 |
215 |
206 CxUiSettings::SettingItem item = mSettingPairList.at(index); |
216 CxUiSettings::SettingItem item = mSettingPairList.at(index); |
207 QString sceneId = item.mValue.toString(); |
217 QString sceneId = item.mValue.toString(); |
208 mScenesBackground2->setIcon(HbIcon(backgroundForScene(sceneId))); |
218 HbIcon background(backgroundForScene(sceneId)); |
|
219 background.setMirroringMode(HbIcon::LayoutDirection); |
|
220 mScenesBackground2->setIcon(background); |
209 startBackgroundTransition(); |
221 startBackgroundTransition(); |
210 CX_DEBUG_EXIT_FUNCTION(); |
222 CX_DEBUG_EXIT_FUNCTION(); |
211 } |
223 } |
212 |
224 |
213 |
225 |
216 * for each of the scenes. |
228 * for each of the scenes. |
217 */ |
229 */ |
218 QString CxuiSceneModeView::backgroundForScene(const QString& sceneId) |
230 QString CxuiSceneModeView::backgroundForScene(const QString& sceneId) |
219 { |
231 { |
220 //!@todo: This mapping should be added to the setting xml. |
232 //!@todo: This mapping should be added to the setting xml. |
221 if (sceneId == CxeSettingIds::IMAGE_SCENE_AUTO) { |
233 if (sceneId == Cxe::IMAGE_SCENE_AUTO) { |
222 return CXUI_SCENES_AUTOMATIC_IMAGE; |
234 return CXUI_SCENES_AUTOMATIC_IMAGE; |
223 } else if (sceneId == CxeSettingIds::IMAGE_SCENE_PORTRAIT) { |
235 } else if (sceneId == Cxe::IMAGE_SCENE_PORTRAIT) { |
224 return CXUI_SCENES_PORTRAIT_IMAGE; |
236 return CXUI_SCENES_PORTRAIT_IMAGE; |
225 } else if (sceneId == CxeSettingIds::IMAGE_SCENE_SCENERY) { |
237 } else if (sceneId == Cxe::IMAGE_SCENE_SCENERY) { |
226 return CXUI_SCENES_LANDSCAPE_IMAGE; |
238 return CXUI_SCENES_LANDSCAPE_IMAGE; |
227 } else if (sceneId == CxeSettingIds::IMAGE_SCENE_MACRO) { |
239 } else if (sceneId == Cxe::IMAGE_SCENE_MACRO) { |
228 return CXUI_SCENES_CLOSEUP_IMAGE; |
240 return CXUI_SCENES_CLOSEUP_IMAGE; |
229 } else if (sceneId == CxeSettingIds::IMAGE_SCENE_SPORTS) { |
241 } else if (sceneId == Cxe::IMAGE_SCENE_SPORTS) { |
230 return CXUI_SCENES_SPORT_IMAGE; |
242 return CXUI_SCENES_SPORT_IMAGE; |
231 } else if (sceneId == CxeSettingIds::IMAGE_SCENE_NIGHT) { |
243 } else if (sceneId == Cxe::IMAGE_SCENE_NIGHT) { |
232 return CXUI_SCENES_NIGHT_IMAGE; |
244 return CXUI_SCENES_NIGHT_IMAGE; |
233 } else if (sceneId == CxeSettingIds::IMAGE_SCENE_NIGHTPORTRAIT) { |
245 } else if (sceneId == Cxe::IMAGE_SCENE_NIGHTPORTRAIT) { |
234 return CXUI_SCENES_NIGHT_PORTRAIT_IMAGE; |
246 return CXUI_SCENES_NIGHT_PORTRAIT_IMAGE; |
235 } else if (sceneId == CxeSettingIds::VIDEO_SCENE_AUTO) { |
247 } else if (sceneId == Cxe::VIDEO_SCENE_AUTO) { |
236 return CXUI_SCENES_AUTOMATIC_IMAGE; |
248 return CXUI_SCENES_AUTOMATIC_IMAGE; |
237 } else if (sceneId == CxeSettingIds::VIDEO_SCENE_LOWLIGHT) { |
249 } else if (sceneId == Cxe::VIDEO_SCENE_LOWLIGHT) { |
238 return CXUI_SCENES_LOW_LIGHT_IMAGE; |
250 return CXUI_SCENES_LOW_LIGHT_IMAGE; |
239 } else if (sceneId == CxeSettingIds::VIDEO_SCENE_NIGHT) { |
251 } else if (sceneId == Cxe::VIDEO_SCENE_NIGHT) { |
240 return CXUI_SCENES_NIGHT_IMAGE; |
252 return CXUI_SCENES_NIGHT_IMAGE; |
241 } else { |
253 } else { |
242 return ""; |
254 return ""; |
243 } |
255 } |
244 |
256 |
300 QGraphicsWidget::showEvent(event); |
312 QGraphicsWidget::showEvent(event); |
301 CX_DEBUG_EXIT_FUNCTION(); |
313 CX_DEBUG_EXIT_FUNCTION(); |
302 } |
314 } |
303 |
315 |
304 /*! |
316 /*! |
|
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 /*! |
305 * Slot to handle capture key full press. |
335 * Slot to handle capture key full press. |
306 */ |
336 */ |
307 void CxuiSceneModeView::handleCaptureKeyPressed() |
337 void CxuiSceneModeView::handleCaptureKeyPressed() |
308 { |
338 { |
309 CX_DEBUG_ENTER_FUNCTION(); |
339 CX_DEBUG_ENTER_FUNCTION(); |
327 void CxuiSceneModeView::closeView() |
357 void CxuiSceneModeView::closeView() |
328 { |
358 { |
329 CX_DEBUG_ENTER_FUNCTION(); |
359 CX_DEBUG_ENTER_FUNCTION(); |
330 mScenesList->handleClose(); |
360 mScenesList->handleClose(); |
331 mScenesBackground->setIcon(HbIcon()); |
361 mScenesBackground->setIcon(HbIcon()); |
332 // Make sure engine prepares for new image/video if necessary |
362 mScenesHeading = NULL; |
333 mEngine->initMode(mEngine->mode()); |
|
334 emit viewCloseEvent(); |
363 emit viewCloseEvent(); |
335 CX_DEBUG_EXIT_FUNCTION(); |
364 CX_DEBUG_EXIT_FUNCTION(); |
336 } |
365 } |
337 |
366 |
338 /*! |
|
339 * Slot to handle camera hw release timeout |
|
340 */ |
|
341 void CxuiSceneModeView::releaseCameraHw() |
|
342 { |
|
343 CX_DEBUG_ENTER_FUNCTION(); |
|
344 mCameraReleaseTimer.stop(); |
|
345 mEngine->cameraDeviceControl().release(); |
|
346 CX_DEBUG_EXIT_FUNCTION(); |
|
347 } |
|
348 |
|
349 // end of file |
367 // end of file |
350 |
368 |