42 #include "cxuienums.h" |
44 #include "cxuienums.h" |
43 #include "cxutils.h" |
45 #include "cxutils.h" |
44 #include "cxuizoomslider.h" |
46 #include "cxuizoomslider.h" |
45 #include "cxuicapturekeyhandler.h" |
47 #include "cxuicapturekeyhandler.h" |
46 #include "cxuidocumentloader.h" |
48 #include "cxuidocumentloader.h" |
|
49 #include "cxuiserviceprovider.h" |
|
50 |
47 #include "OstTraceDefinitions.h" |
51 #include "OstTraceDefinitions.h" |
48 #ifdef OST_TRACE_COMPILER_IN_USE |
52 #ifdef OST_TRACE_COMPILER_IN_USE |
49 #include "cxuivideoprecaptureviewTraces.h" |
53 #include "cxuivideoprecaptureviewTraces.h" |
50 #endif |
54 #endif |
51 #include "cxuiserviceprovider.h" |
|
52 |
55 |
53 |
56 |
54 using namespace Cxe; |
57 using namespace Cxe; |
55 using namespace CxUiLayout; |
58 using namespace CxUiLayout; |
56 using namespace CxUiInternal; |
59 using namespace CxUiInternal; |
92 mElapsedTimer.stop(); |
95 mElapsedTimer.stop(); |
93 delete mMenu; |
96 delete mMenu; |
94 CX_DEBUG_EXIT_FUNCTION(); |
97 CX_DEBUG_EXIT_FUNCTION(); |
95 } |
98 } |
96 |
99 |
|
100 /*! |
|
101 * Construct-method handles initialisation tasks for this class. |
|
102 * @param mainwindow |
|
103 * @param engine |
|
104 * @param documentLoader |
|
105 * @param keyHandler |
|
106 */ |
97 void CxuiVideoPrecaptureView::construct(HbMainWindow *mainwindow, CxeEngine *engine, |
107 void CxuiVideoPrecaptureView::construct(HbMainWindow *mainwindow, CxeEngine *engine, |
98 CxuiDocumentLoader *documentLoader, |
108 CxuiDocumentLoader *documentLoader, |
99 CxuiCaptureKeyHandler *keyHandler) |
109 CxuiCaptureKeyHandler *keyHandler, |
100 { |
110 HbActivityManager *activityManager) |
101 CX_DEBUG_ENTER_FUNCTION(); |
111 { |
102 |
112 CX_DEBUG_ENTER_FUNCTION(); |
103 CxuiPrecaptureView::construct(mainwindow, engine, documentLoader, keyHandler); |
113 |
104 mKeyHandler = keyHandler; |
114 CxuiPrecaptureView::construct(mainwindow, engine, documentLoader, keyHandler, activityManager); |
|
115 mCaptureKeyHandler = keyHandler; |
105 |
116 |
106 mVideoCaptureControl = &(engine->videoCaptureControl()); |
117 mVideoCaptureControl = &(engine->videoCaptureControl()); |
107 |
118 |
108 connect(&mElapsedTimer, SIGNAL(timeout()), this, SLOT(updateTimeLabels())); |
119 connect(&mElapsedTimer, SIGNAL(timeout()), this, SLOT(updateTimeLabels())); |
109 connect(mVideoCaptureControl, SIGNAL(snapshotReady(CxeError::Id, const QPixmap&, const QString&)), |
120 connect(mVideoCaptureControl, SIGNAL(snapshotReady(CxeError::Id, const QImage&, const QString&)), |
110 this, SLOT(handleSnapshot(CxeError::Id))); |
121 this, SLOT(handleSnapshot(CxeError::Id))); |
111 connect(mVideoCaptureControl, SIGNAL(stateChanged(CxeVideoCaptureControl::State, CxeError::Id)), |
122 connect(mVideoCaptureControl, SIGNAL(stateChanged(CxeVideoCaptureControl::State, CxeError::Id)), |
112 this, SLOT(handleVideoStateChanged(CxeVideoCaptureControl::State,CxeError::Id))); |
123 this, SLOT(handleVideoStateChanged(CxeVideoCaptureControl::State,CxeError::Id))); |
|
124 connect(&(mEngine->settings()), SIGNAL(sceneChanged(CxeScene&)), |
|
125 this, SLOT(handleSceneChanged(CxeScene&))); |
113 connect(mVideoCaptureControl, SIGNAL(remainingTimeChanged()), |
126 connect(mVideoCaptureControl, SIGNAL(remainingTimeChanged()), |
114 this, SLOT(updateTimeLabels())); |
127 this, SLOT(updateTimeLabels())); |
115 |
128 |
116 mPauseTimer.setSingleShot(true); |
129 mPauseTimer.setSingleShot(true); |
117 connect(&mPauseTimer, SIGNAL(timeout()), this, SLOT(stop())); |
130 connect(&mPauseTimer, SIGNAL(timeout()), this, SLOT(stop())); |
127 |
140 |
128 CX_DEBUG_EXIT_FUNCTION(); |
141 CX_DEBUG_EXIT_FUNCTION(); |
129 |
142 |
130 } |
143 } |
131 |
144 |
|
145 /*! |
|
146 * Loads widgets that are needed right from the start. |
|
147 */ |
132 void CxuiVideoPrecaptureView::loadDefaultWidgets() |
148 void CxuiVideoPrecaptureView::loadDefaultWidgets() |
133 { |
149 { |
134 CX_DEBUG_ENTER_FUNCTION(); |
150 CX_DEBUG_ENTER_FUNCTION(); |
135 CX_DEBUG_ASSERT(mDocumentLoader); |
151 CX_ASSERT_ALWAYS(mDocumentLoader); |
136 |
152 |
137 // get pointers to ui components from the layout data |
153 // get pointers to ui components from the layout data |
138 QGraphicsWidget *widget = NULL; |
154 QGraphicsWidget *widget = NULL; |
139 widget = mDocumentLoader->findWidget(VIDEO_PRE_CAPTURE_VIEWFINDER); |
155 widget = mDocumentLoader->findWidget(VIDEO_PRE_CAPTURE_VIEWFINDER); |
140 mViewfinder = qobject_cast<HbTransparentWindow *> (widget); |
156 mViewfinder = qobject_cast<HbTransparentWindow *> (widget); |
141 CX_DEBUG_ASSERT(mViewfinder); |
157 CX_ASSERT_ALWAYS(mViewfinder); |
142 |
158 |
|
159 reloadIndicatorWidgets(); |
|
160 |
|
161 CX_DEBUG_EXIT_FUNCTION(); |
|
162 } |
|
163 |
|
164 /*! |
|
165 * Loads default indicators from docml and modifies the visibility |
|
166 * according to current settings. |
|
167 */ |
|
168 void CxuiVideoPrecaptureView::reloadIndicatorWidgets() |
|
169 { |
|
170 CX_DEBUG_ENTER_FUNCTION(); |
|
171 CX_ASSERT_ALWAYS(mDocumentLoader); |
|
172 |
|
173 bool ok = false; |
|
174 mDocumentLoader->load(VIDEO_1ST_XML, VIDEO_PRE_CAPTURE_INDICATORS_SECTION, &ok); |
|
175 CX_ASSERT_ALWAYS(ok); |
|
176 |
|
177 QGraphicsWidget *widget = NULL; |
143 widget = mDocumentLoader->findWidget(VIDEO_PRE_CAPTURE_QUALITY_ICON); |
178 widget = mDocumentLoader->findWidget(VIDEO_PRE_CAPTURE_QUALITY_ICON); |
144 mQualityIcon = qobject_cast<HbLabel *> (widget); |
179 mQualityIcon = qobject_cast<HbLabel *> (widget); |
145 CX_DEBUG_ASSERT(mQualityIcon); |
180 CX_ASSERT_ALWAYS(mQualityIcon); |
|
181 |
|
182 widget = mDocumentLoader->findWidget(VIDEO_PRE_CAPTURE_VIDEOAUDIOMUTE_INDICATOR_ICON); |
|
183 HbLabel *videoaudiomuteIndicatorIcon = qobject_cast<HbLabel *>(widget); |
|
184 CX_ASSERT_ALWAYS(videoaudiomuteIndicatorIcon); |
|
185 |
|
186 widget = mDocumentLoader->findWidget(VIDEO_PRE_CAPTURE_STABILITY_INDICATOR_ICON); |
|
187 HbLabel *videoStabilityIndicatorIcon = qobject_cast<HbLabel *>(widget); |
|
188 CX_ASSERT_ALWAYS(videoStabilityIndicatorIcon); |
146 |
189 |
147 widget = mDocumentLoader->findWidget(VIDEO_PRE_CAPTURE_INDICATOR_CONTAINER_TOP); |
190 widget = mDocumentLoader->findWidget(VIDEO_PRE_CAPTURE_INDICATOR_CONTAINER_TOP); |
148 mIndicators = qobject_cast<HbWidget *>(widget); |
191 mIndicators = qobject_cast<HbWidget *>(widget); |
149 CX_DEBUG_ASSERT(mIndicators); |
192 CX_ASSERT_ALWAYS(mIndicators); |
|
193 |
|
194 QGraphicsLayout *layout = mIndicators->layout(); |
|
195 QGraphicsLayoutItem *graphicsLayoutItem = NULL; |
|
196 QGraphicsItem *graphicsItem = NULL; |
|
197 QString key = ""; |
|
198 int currentSettingValue = -1; |
|
199 bool isSettingOff = false; |
|
200 // Go through the items in the layout to check whether they should be |
|
201 // shown or not in the indicator pane. Start from the last towards |
|
202 // the first, so that removing items from between works correctly. |
|
203 for (int i = layout->count() - 1; i >= 0; i--) { |
|
204 graphicsLayoutItem = layout->itemAt(i); |
|
205 isSettingOff = false; |
|
206 if (graphicsLayoutItem) { |
|
207 graphicsItem = graphicsLayoutItem->graphicsItem(); |
|
208 currentSettingValue = -1; |
|
209 if (graphicsItem == videoaudiomuteIndicatorIcon) { |
|
210 key = CxeSettingIds::VIDEO_MUTE_SETTING; |
|
211 mEngine->settings().get(key, currentSettingValue); |
|
212 // video mute implementation does not use |
|
213 // enum for on/off values but instead |
|
214 // 0 for off and 1 for on. |
|
215 if (currentSettingValue == 0) { |
|
216 isSettingOff = true; |
|
217 } |
|
218 } else if (graphicsItem == videoStabilityIndicatorIcon) { |
|
219 // remove video stability indicator. |
|
220 isSettingOff = true; |
|
221 } |
|
222 if (isSettingOff) { |
|
223 layout->removeAt(i); |
|
224 } |
|
225 } |
|
226 } |
|
227 |
150 // Create background graphics for indicator container |
228 // Create background graphics for indicator container |
151 createWidgetBackgroundGraphic(mIndicators, TRANSPARENT_BACKGROUND_GRAPHIC); |
229 createWidgetBackgroundGraphic(mIndicators, TRANSPARENT_BACKGROUND_GRAPHIC); |
152 |
230 |
153 CX_DEBUG_EXIT_FUNCTION(); |
231 mIndicators->setVisible(true); |
154 } |
232 |
155 |
233 CX_DEBUG_EXIT_FUNCTION(); |
|
234 } |
|
235 |
|
236 /*! |
|
237 * Loads widgets that are not part of the default section in layouts xml. |
|
238 * Widgets are created at the time they are first loaded. |
|
239 */ |
156 void CxuiVideoPrecaptureView::loadWidgets() |
240 void CxuiVideoPrecaptureView::loadWidgets() |
157 { |
241 { |
158 CX_DEBUG_ENTER_FUNCTION(); |
242 CX_DEBUG_ENTER_FUNCTION(); |
159 CX_DEBUG_ASSERT(mDocumentLoader); |
243 CX_ASSERT_ALWAYS(mDocumentLoader); |
160 |
244 |
161 if (mWidgetsLoaded) { |
245 if (mWidgetsLoaded) { |
162 CX_DEBUG(("Widgets already loaded")); |
246 CX_DEBUG(("Widgets already loaded")); |
163 CX_DEBUG_EXIT_FUNCTION(); |
247 CX_DEBUG_EXIT_FUNCTION(); |
164 return; |
248 return; |
170 // load the "secondary" widgets |
254 // load the "secondary" widgets |
171 bool ok = false; |
255 bool ok = false; |
172 |
256 |
173 // load widgets section (creates the widgets) |
257 // load widgets section (creates the widgets) |
174 mDocumentLoader->load(VIDEO_1ST_XML, VIDEO_PRE_CAPTURE_WIDGETS_SECTION, &ok); |
258 mDocumentLoader->load(VIDEO_1ST_XML, VIDEO_PRE_CAPTURE_WIDGETS_SECTION, &ok); |
175 Q_ASSERT_X(ok, "camerax ui", "error in xml file parsing"); |
259 CX_ASSERT_ALWAYS(ok); |
176 if (CxuiServiceProvider::isCameraEmbedded()) { |
260 if (CxuiServiceProvider::isCameraEmbedded()) { |
177 mDocumentLoader->load(VIDEO_1ST_XML, VIDEO_PRE_CAPTURE_EMBEDDED_SECTION, &ok); |
261 mDocumentLoader->load(VIDEO_1ST_XML, VIDEO_PRE_CAPTURE_EMBEDDED_SECTION, &ok); |
178 } else { |
262 } else { |
179 mDocumentLoader->load(VIDEO_1ST_XML, VIDEO_PRE_CAPTURE_STANDALONE_SECTION, &ok); |
263 mDocumentLoader->load(VIDEO_1ST_XML, VIDEO_PRE_CAPTURE_STANDALONE_SECTION, &ok); |
180 } |
264 } |
181 Q_ASSERT_X(ok, "camerax ui", "error in xml file parsing"); |
265 CX_ASSERT_ALWAYS(ok); |
182 // get needed pointers to some of the widgets |
266 // get needed pointers to some of the widgets |
183 widget = mDocumentLoader->findWidget(VIDEO_PRE_CAPTURE_ZOOM_SLIDER); |
267 widget = mDocumentLoader->findWidget(VIDEO_PRE_CAPTURE_ZOOM_SLIDER); |
184 mSlider = qobject_cast<CxuiZoomSlider *> (widget); |
268 mSlider = qobject_cast<CxuiZoomSlider *> (widget); |
185 CX_DEBUG_ASSERT(mSlider); |
269 CX_ASSERT_ALWAYS(mSlider); |
186 |
270 |
187 //Let's add a plus and minus buttons to the slider |
271 //Let's add a plus and minus buttons to the slider |
188 addIncreaseDecreaseButtons(mSlider); |
272 mSlider->addZoomButtons(); |
189 createWidgetBackgroundGraphic(mSlider, TRANSPARENT_BACKGROUND_GRAPHIC); |
273 createWidgetBackgroundGraphic(mSlider, TRANSPARENT_BACKGROUND_GRAPHIC); |
190 |
274 |
191 widget = mDocumentLoader->findWidget(VIDEO_PRE_CAPTURE_TOOLBAR); |
275 widget = mDocumentLoader->findWidget(VIDEO_PRE_CAPTURE_TOOLBAR); |
192 mToolBarIdle = qobject_cast<HbToolBar *> (widget); |
276 mToolbarIdle = qobject_cast<HbToolBar *> (widget); |
193 widget = mDocumentLoader->findWidget(VIDEO_PRE_CAPTURE_TOOLBAR_REC); |
277 widget = mDocumentLoader->findWidget(VIDEO_PRE_CAPTURE_TOOLBAR_REC); |
194 mToolBarRec = qobject_cast<HbToolBar *> (widget); |
278 mToolbarRec = qobject_cast<HbToolBar *> (widget); |
195 widget = mDocumentLoader->findWidget(VIDEO_PRE_CAPTURE_TOOLBAR_PAUSED); |
279 widget = mDocumentLoader->findWidget(VIDEO_PRE_CAPTURE_TOOLBAR_PAUSED); |
196 mToolBarPaused = qobject_cast<HbToolBar *> (widget); |
280 mToolbarPaused = qobject_cast<HbToolBar *> (widget); |
197 |
281 |
198 mToolBar = mToolBarIdle; |
282 mToolbar = mToolbarIdle; |
199 |
283 |
200 CX_DEBUG_ASSERT(mToolBarIdle); |
284 CX_ASSERT_ALWAYS(mToolbarIdle); |
201 CX_DEBUG_ASSERT(mToolBarRec); |
285 CX_ASSERT_ALWAYS(mToolbarRec); |
202 CX_DEBUG_ASSERT(mToolBarPaused); |
286 CX_ASSERT_ALWAYS(mToolbarPaused); |
203 |
287 |
204 hideControls(); |
288 hideControls(); |
205 |
289 |
206 if (CxuiServiceProvider::isCameraEmbedded()) { |
290 if (CxuiServiceProvider::isCameraEmbedded()) { |
207 CX_DEBUG(("EMBEDDED: camera in embedded mode")); |
291 CX_DEBUG(("EMBEDDED: camera in embedded mode")); |
234 |
318 |
235 // Create background graphic for indicator container |
319 // Create background graphic for indicator container |
236 HbWidget *indicatorContainer; |
320 HbWidget *indicatorContainer; |
237 widget = mDocumentLoader->findWidget(VIDEO_PRE_CAPTURE_INDICATOR_CONTAINER_BOTTOM); |
321 widget = mDocumentLoader->findWidget(VIDEO_PRE_CAPTURE_INDICATOR_CONTAINER_BOTTOM); |
238 indicatorContainer = qobject_cast<HbWidget *>(widget); |
322 indicatorContainer = qobject_cast<HbWidget *>(widget); |
239 CX_DEBUG_ASSERT(indicatorContainer); |
323 CX_ASSERT_ALWAYS(indicatorContainer); |
240 createWidgetBackgroundGraphic(indicatorContainer, TRANSPARENT_BACKGROUND_GRAPHIC); |
324 createWidgetBackgroundGraphic(indicatorContainer, TRANSPARENT_BACKGROUND_GRAPHIC); |
241 |
325 |
242 widget = mDocumentLoader->findWidget(VIDEO_PRE_CAPTURE_ELAPSED_TIME_LABEL); |
326 widget = mDocumentLoader->findWidget(VIDEO_PRE_CAPTURE_ELAPSED_TIME_LABEL); |
243 mElapsedTimeText = qobject_cast<HbLabel *> (widget); |
327 mElapsedTimeText = qobject_cast<HbLabel *> (widget); |
244 CX_DEBUG_ASSERT(mElapsedTimeText); |
328 CX_ASSERT_ALWAYS(mElapsedTimeText); |
245 |
329 |
246 widget = mDocumentLoader->findWidget(VIDEO_PRE_CAPTURE_REMAINING_TIME_LABEL); |
330 widget = mDocumentLoader->findWidget(VIDEO_PRE_CAPTURE_REMAINING_TIME_LABEL); |
247 mRemainingTimeText = qobject_cast<HbLabel *> (widget); |
331 mRemainingTimeText = qobject_cast<HbLabel *> (widget); |
248 CX_DEBUG_ASSERT(mRemainingTimeText); |
332 CX_ASSERT_ALWAYS(mRemainingTimeText); |
249 |
333 |
250 widget = mDocumentLoader->findWidget(VIDEO_PRE_CAPTURE_RECORDING_ICON); |
334 widget = mDocumentLoader->findWidget(VIDEO_PRE_CAPTURE_RECORDING_ICON); |
251 mRecordingIcon = qobject_cast<HbLabel *> (widget); |
335 mRecordingIcon = qobject_cast<HbLabel *> (widget); |
252 CX_DEBUG_ASSERT(mRecordingIcon); |
336 CX_ASSERT_ALWAYS(mRecordingIcon); |
253 |
337 |
254 mWidgetsLoaded = true; |
338 mWidgetsLoaded = true; |
255 |
339 |
256 // Initializing recording indicator animation |
340 // Initializing recording indicator animation |
257 mRecordingAnimation = new QPropertyAnimation(mRecordingIcon, "opacity"); |
341 mRecordingAnimation = new QPropertyAnimation(mRecordingIcon, "opacity"); |
260 mRecordingAnimation->setEndValue(0.2); |
344 mRecordingAnimation->setEndValue(0.2); |
261 mRecordingAnimation->setDuration(CXUI_RECORD_ANIMATION_DURATION); |
345 mRecordingAnimation->setDuration(CXUI_RECORD_ANIMATION_DURATION); |
262 mRecordingAnimation->setLoopCount(-1); |
346 mRecordingAnimation->setLoopCount(-1); |
263 mRecordingAnimation->setEasingCurve(QEasingCurve::OutInQuad); |
347 mRecordingAnimation->setEasingCurve(QEasingCurve::OutInQuad); |
264 |
348 |
|
349 |
|
350 // Update toolbar scene mode icon. |
|
351 QString sceneId; |
|
352 if (mEngine->settings().get(CxeSettingIds::SCENE_ID, sceneId) == CxeError::None) { |
|
353 updateSceneIcon(sceneId); |
|
354 } |
|
355 |
265 // Initialize the video time counters. |
356 // Initialize the video time counters. |
266 updateTimeLabels(); |
357 updateTimeLabels(); |
267 |
358 |
|
359 // View is ready. Needed for startup performance automated testing. |
|
360 emit viewReady(); |
|
361 |
|
362 CX_DEBUG_EXIT_FUNCTION(); |
|
363 } |
|
364 |
|
365 /*! |
|
366 * Restore view state from activity. |
|
367 */ |
|
368 void CxuiVideoPrecaptureView::restoreActivity(const QString &activityId, const QVariant &data) |
|
369 { |
|
370 Q_UNUSED(activityId); |
|
371 Q_UNUSED(data); |
|
372 |
|
373 CX_DEBUG_ENTER_FUNCTION(); |
|
374 // no need to restore any state |
|
375 CX_DEBUG_EXIT_FUNCTION(); |
|
376 } |
|
377 |
|
378 /*! |
|
379 * Save view state to activity. |
|
380 */ |
|
381 void CxuiVideoPrecaptureView::saveActivity() |
|
382 { |
|
383 CX_DEBUG_ENTER_FUNCTION(); |
|
384 QVariantMap data; |
|
385 QVariantHash params; |
|
386 //@todo: add pre-capture icon as screenshot |
|
387 mActivityManager->removeActivity(CxuiActivityIds::VIDEO_PRECAPTURE_ACTIVITY); |
|
388 mActivityManager->addActivity(CxuiActivityIds::VIDEO_PRECAPTURE_ACTIVITY, data, params); |
|
389 CX_DEBUG_EXIT_FUNCTION(); |
|
390 } |
|
391 |
|
392 /*! |
|
393 * Clear activity from activity manager. |
|
394 */ |
|
395 void CxuiVideoPrecaptureView::clearActivity() |
|
396 { |
|
397 CX_DEBUG_ENTER_FUNCTION(); |
|
398 mActivityManager->removeActivity(CxuiActivityIds::VIDEO_PRECAPTURE_ACTIVITY); |
268 CX_DEBUG_EXIT_FUNCTION(); |
399 CX_DEBUG_EXIT_FUNCTION(); |
269 } |
400 } |
270 |
401 |
271 /*! |
402 /*! |
272 * Initialize settings grid. |
403 * Initialize settings grid. |
276 if(!mSettingsGrid) { |
407 if(!mSettingsGrid) { |
277 HbAction* action(NULL); |
408 HbAction* action(NULL); |
278 |
409 |
279 mSettingsGrid = new HbToolBarExtension; |
410 mSettingsGrid = new HbToolBarExtension; |
280 |
411 |
281 action = mSettingsGrid->addAction(HbIcon("qtg_mono_exposure.svg"), hbTrId("txt_cam_button_exposure_compensation"), this, SLOT(launchSliderSetting())); |
412 action = mSettingsGrid->addAction(HbIcon("qtg_mono_exposure"), hbTrId("txt_cam_button_exposure_compensation"), this, SLOT(launchSliderSetting())); |
282 action->setProperty(PROPERTY_KEY_SETTING_ID, CxeSettingIds::EV_COMPENSATION_VALUE); |
413 action->setProperty(PROPERTY_KEY_SETTING_ID, CxeSettingIds::EV_COMPENSATION_VALUE); |
283 action->setProperty(PROPERTY_KEY_SETTING_GRID, PROPERTY_KEY_TRUE); |
414 action->setProperty(PROPERTY_KEY_SETTING_GRID, PROPERTY_KEY_TRUE); |
284 |
415 |
285 action = mSettingsGrid->addAction(HbIcon("qtg_small_rgb.svg"), hbTrId("txt_cam_button_color_tone"), this, SLOT(launchSetting())); |
416 action = mSettingsGrid->addAction(HbIcon("qtg_small_rgb"), hbTrId("txt_cam_button_color_tone"), this, SLOT(launchSetting())); |
286 action->setProperty(PROPERTY_KEY_SETTING_ID, CxeSettingIds::COLOR_TONE); |
417 action->setProperty(PROPERTY_KEY_SETTING_ID, CxeSettingIds::COLOR_TONE); |
287 action->setProperty(PROPERTY_KEY_SETTING_GRID, PROPERTY_KEY_TRUE); |
418 action->setProperty(PROPERTY_KEY_SETTING_GRID, PROPERTY_KEY_TRUE); |
288 |
419 |
289 action = mSettingsGrid->addAction(HbIcon("qtg_mono_white_balance.svg"), hbTrId("txt_cam_button_white_balance"), this, SLOT(launchSetting())); |
420 action = mSettingsGrid->addAction(HbIcon("qtg_mono_white_balance"), hbTrId("txt_cam_button_white_balance"), this, SLOT(launchSetting())); |
290 action->setProperty(PROPERTY_KEY_SETTING_ID, CxeSettingIds::WHITE_BALANCE); |
421 action->setProperty(PROPERTY_KEY_SETTING_ID, CxeSettingIds::WHITE_BALANCE); |
291 action->setProperty(PROPERTY_KEY_SETTING_GRID, PROPERTY_KEY_TRUE); |
422 action->setProperty(PROPERTY_KEY_SETTING_GRID, PROPERTY_KEY_TRUE); |
292 |
423 |
293 connect(mKeyHandler, SIGNAL(autofocusKeyPressed()), mSettingsGrid, SLOT(close())); |
424 connect(mCaptureKeyHandler, SIGNAL(autofocusKeyPressed()), mSettingsGrid, SLOT(close())); |
294 } |
425 } |
|
426 } |
|
427 |
|
428 /** |
|
429 * Get if postcapture view should be shown or not. |
|
430 * Postcapture view may be shown for a predefined time or |
|
431 * until user dismisses it, or it may be completely disabled. |
|
432 */ |
|
433 bool CxuiVideoPrecaptureView::isPostcaptureOn() const |
|
434 { |
|
435 CX_DEBUG_ENTER_FUNCTION(); |
|
436 if (CxuiServiceProvider::isCameraEmbedded()) { |
|
437 // always show post capture in embedded mode |
|
438 CX_DEBUG_EXIT_FUNCTION(); |
|
439 return true; |
|
440 } |
|
441 |
|
442 // Read the value from settings. Ignoring reading error. |
|
443 // On error (missing settings) default to "postcapture on". |
|
444 int showPostcapture(-1); |
|
445 if(mEngine) { |
|
446 mEngine->settings().get(CxeSettingIds::VIDEO_SHOWCAPTURED, showPostcapture); |
|
447 } |
|
448 |
|
449 CX_DEBUG_EXIT_FUNCTION(); |
|
450 return showPostcapture != 0; // 0 == no postcapture |
|
451 } |
|
452 |
|
453 /*! |
|
454 * Update the scene mode icon. |
|
455 * @param sceneId The new scene id. |
|
456 */ |
|
457 void CxuiVideoPrecaptureView::updateSceneIcon(const QString& sceneId) |
|
458 { |
|
459 CX_DEBUG_ENTER_FUNCTION(); |
|
460 |
|
461 if (mEngine->mode() == Cxe::VideoMode) { |
|
462 CX_DEBUG(("CxuiPrecaptureView - scene: %s", sceneId.toAscii().constData())); |
|
463 |
|
464 // No need to update icon, if widgets are not even loaded yet. |
|
465 // We'll update the icon once the widgets are loaded. |
|
466 if (mWidgetsLoaded) { |
|
467 QString iconObjectName = VIDEO_PRE_CAPTURE_SCENE_MODE_ACTION; |
|
468 QString icon = getSettingItemIcon(CxeSettingIds::VIDEO_SCENE, sceneId); |
|
469 |
|
470 CX_DEBUG(("CxuiVideoPrecaptureView - icon: %s", icon.toAscii().constData())); |
|
471 |
|
472 if (mDocumentLoader) { |
|
473 QObject *obj = mDocumentLoader->findObject(iconObjectName); |
|
474 CX_ASSERT_ALWAYS(obj); |
|
475 qobject_cast<HbAction *>(obj)->setIcon(HbIcon(icon)); |
|
476 } |
|
477 } else { |
|
478 CX_DEBUG(("CxuiVideoPrecaptureView - widgets not loaded yet, ignored!")); |
|
479 } |
|
480 } |
|
481 CX_DEBUG_EXIT_FUNCTION(); |
|
482 } |
|
483 |
|
484 /*! |
|
485 Update the quality indicator |
|
486 */ |
|
487 void CxuiVideoPrecaptureView::updateQualityIcon() |
|
488 { |
|
489 CX_DEBUG_ENTER_FUNCTION(); |
|
490 |
|
491 if (mQualityIcon && mEngine) { |
|
492 QString icon = ""; |
|
493 int currentValue = -1; |
|
494 |
|
495 mEngine->settings().get(CxeSettingIds::VIDEO_QUALITY, currentValue); |
|
496 icon = getSettingItemIcon(CxeSettingIds::VIDEO_QUALITY, currentValue); |
|
497 |
|
498 mQualityIcon->setIcon(HbIcon(icon)); |
|
499 } |
|
500 |
|
501 CX_DEBUG_EXIT_FUNCTION(); |
295 } |
502 } |
296 |
503 |
297 void CxuiVideoPrecaptureView::handleSnapshot(CxeError::Id /*error*/) |
504 void CxuiVideoPrecaptureView::handleSnapshot(CxeError::Id /*error*/) |
298 { |
505 { |
299 CX_DEBUG_ENTER_FUNCTION(); |
506 CX_DEBUG_ENTER_FUNCTION(); |
333 } |
540 } |
334 |
541 |
335 void CxuiVideoPrecaptureView::stop() |
542 void CxuiVideoPrecaptureView::stop() |
336 { |
543 { |
337 CX_DEBUG_ENTER_FUNCTION(); |
544 CX_DEBUG_ENTER_FUNCTION(); |
338 if (isPostcaptureOn()) { |
545 |
339 CxeVideoCaptureControl::State state = mVideoCaptureControl->state(); |
546 CxeVideoCaptureControl::State state = mVideoCaptureControl->state(); |
340 if (state == CxeVideoCaptureControl::Recording || |
547 if (state == CxeVideoCaptureControl::Recording || |
341 state == CxeVideoCaptureControl::Paused) { |
548 state == CxeVideoCaptureControl::Paused) { |
342 mVideoCaptureControl->stop(); |
549 mVideoCaptureControl->stop(); |
343 // Continue in handleVideoStateChanged(). |
550 // Continue in handleVideoStateChanged(). |
344 } |
551 } |
|
552 |
|
553 CX_DEBUG_EXIT_FUNCTION(); |
|
554 } |
|
555 |
|
556 |
|
557 /*! |
|
558 * Allow showing UI controls? |
|
559 */ |
|
560 bool CxuiVideoPrecaptureView::allowShowControls() const |
|
561 { |
|
562 bool show(false); |
|
563 if (mEngine) { |
|
564 CxeVideoCaptureControl::State state(mEngine->videoCaptureControl().state()); |
|
565 |
|
566 show = (mEngine->isEngineReady() |
|
567 || state == CxeVideoCaptureControl::Recording |
|
568 || state == CxeVideoCaptureControl::Paused); |
|
569 } |
|
570 return show; |
|
571 } |
|
572 |
|
573 /*! |
|
574 * Play feedback when touching view outside of any widget? |
|
575 * If video is paused feedback is off. Otherwise on. |
|
576 */ |
|
577 bool CxuiVideoPrecaptureView::isFeedbackEnabled() const |
|
578 { |
|
579 CxeVideoCaptureControl::State state(mEngine->videoCaptureControl().state()); |
|
580 if (state == CxeVideoCaptureControl::Paused) { |
|
581 return false; |
345 } else { |
582 } else { |
346 // no postcapture |
583 return true; |
347 stopAndPrepareNewVideo(); |
584 } |
348 } |
585 } |
349 |
|
350 |
|
351 CX_DEBUG_EXIT_FUNCTION(); |
|
352 } |
|
353 |
|
354 // CxuiVideoPrecaptureView::stopAndPrepareNewVideo() |
|
355 // A version of stop that doesn't go to post-capture. When |
|
356 // not going to post-capture, we need to prepare new video |
|
357 void CxuiVideoPrecaptureView::stopAndPrepareNewVideo() |
|
358 { |
|
359 CX_DEBUG_ENTER_FUNCTION(); |
|
360 mVideoCaptureControl->stop(); |
|
361 mElapsedTimer.stop(); |
|
362 hideControls(); |
|
363 |
|
364 if (mMenu) { |
|
365 setMenu(mMenu); |
|
366 mMenu = NULL; |
|
367 } |
|
368 |
|
369 // prepare new video when old one is ready |
|
370 connect(mVideoCaptureControl, SIGNAL(videoComposed(CxeError::Id, const QString&)), |
|
371 this, SLOT(prepareNewVideo(CxeError::Id))); |
|
372 |
|
373 CX_DEBUG_EXIT_FUNCTION(); |
|
374 } |
|
375 |
|
376 |
586 |
377 // CxuiPrecaptureView::showToolbar() |
587 // CxuiPrecaptureView::showToolbar() |
378 // Shows toolbar. Calls the base class implementation if not recording |
588 // Shows toolbar. Calls the base class implementation if not recording |
379 // since toolbar is not shown during recording |
589 // since toolbar is not shown during recording |
380 void CxuiVideoPrecaptureView::showToolbar() |
590 void CxuiVideoPrecaptureView::showToolbar() |
381 { |
591 { |
382 CxeVideoCaptureControl::State state = mVideoCaptureControl->state(); |
592 CxeVideoCaptureControl::State state = mVideoCaptureControl->state(); |
383 if (state == CxeVideoCaptureControl::Recording) { |
593 if (state == CxeVideoCaptureControl::Recording) { |
384 if (mToolBar != mToolBarRec) { |
594 if (mToolbar != mToolbarRec) { |
385 mToolBar->hide(); |
595 mToolbar->hide(); |
386 mToolBar = mToolBarRec; |
596 mToolbar = mToolbarRec; |
387 } |
597 } |
388 } else if (state ==CxeVideoCaptureControl::Ready) { |
598 } else if (state ==CxeVideoCaptureControl::Ready) { |
389 if (mToolBar != mToolBarIdle) { |
599 if (mToolbar != mToolbarIdle) { |
390 mToolBar->hide(); |
600 mToolbar->hide(); |
391 mToolBar = mToolBarIdle; |
601 mToolbar = mToolbarIdle; |
392 } |
602 } |
393 } else if (state == CxeVideoCaptureControl::Paused) { |
603 } else if (state == CxeVideoCaptureControl::Paused) { |
394 if (mToolBar != mToolBarPaused) { |
604 if (mToolbar != mToolbarPaused) { |
395 mToolBar->hide(); |
605 mToolbar->hide(); |
396 mToolBar = mToolBarPaused; |
606 mToolbar = mToolbarPaused; |
397 } |
607 } |
398 } |
608 } |
399 |
609 |
400 CxuiPrecaptureView::showToolbar(); |
610 CxuiPrecaptureView::showToolbar(); |
401 } |
611 } |
569 record(); |
778 record(); |
570 } |
779 } |
571 break; |
780 break; |
572 case CxeVideoCaptureControl::Recording: |
781 case CxeVideoCaptureControl::Recording: |
573 hideControls(); |
782 hideControls(); |
|
783 emit stopStandbyTimer(); |
574 if (mDocumentLoader){ |
784 if (mDocumentLoader){ |
575 mDocumentLoader->load(VIDEO_1ST_XML, VIDEO_PRE_CAPTURE_RECORDING); |
785 mDocumentLoader->load(VIDEO_1ST_XML, VIDEO_PRE_CAPTURE_RECORDING); |
576 } |
786 } |
577 mElapsedTimer.start(CXUI_ELAPSED_TIME_TIMEOUT); |
787 mElapsedTimer.start(CXUI_ELAPSED_TIME_TIMEOUT); |
578 disableFeedback(); |
788 disableFeedback(); |
579 if (mRecordingAnimation && mRecordingIcon) { |
789 |
580 mRecordingAnimation->start(); |
790 // commented out the activation of the recording animation because |
581 } |
791 // it is causing issues when using SW rendering |
|
792 //if (mRecordingAnimation && mRecordingIcon) { |
|
793 // mRecordingAnimation->start(); |
|
794 //} |
|
795 |
582 break; |
796 break; |
583 case CxeVideoCaptureControl::Paused: |
797 case CxeVideoCaptureControl::Paused: |
584 mElapsedTimer.stop(); |
798 mElapsedTimer.stop(); |
585 |
|
586 if (mDocumentLoader){ |
799 if (mDocumentLoader){ |
587 mDocumentLoader->load(VIDEO_1ST_XML, VIDEO_PRE_CAPTURE_PAUSED); |
800 mDocumentLoader->load(VIDEO_1ST_XML, VIDEO_PRE_CAPTURE_PAUSED); |
588 } |
|
589 |
|
590 if (mRecordingAnimation && mRecordingIcon) { |
|
591 mRecordingAnimation->stop(); |
|
592 } |
801 } |
593 showControls(); |
802 showControls(); |
594 enableFeedback(); |
803 enableFeedback(); |
595 mPauseTimer.start(); |
804 mPauseTimer.start(); |
596 break; |
805 break; |
597 case CxeVideoCaptureControl::Stopping: |
806 case CxeVideoCaptureControl::Stopping: |
598 if (mDocumentLoader){ |
807 if (mDocumentLoader){ |
599 mDocumentLoader->load(VIDEO_1ST_XML, VIDEO_PRE_CAPTURE_PAUSED); |
808 mDocumentLoader->load(VIDEO_1ST_XML, VIDEO_PRE_CAPTURE_PAUSED); |
600 } |
809 } |
601 |
810 |
602 if (mRecordingAnimation && mRecordingIcon) { |
811 // commented out the stopping of the recording animation since the activation |
603 mRecordingAnimation->stop(); |
812 // is commented out also couple lines earlier |
604 } |
813 //if (mRecordingAnimation && mRecordingIcon) { |
|
814 // mRecordingAnimation->stop(); |
|
815 //} |
|
816 |
605 enableFeedback(); |
817 enableFeedback(); |
|
818 emit startStandbyTimer(); |
|
819 mElapsedTimer.stop(); |
|
820 hideControls(); |
|
821 |
|
822 if (mMenu) { |
|
823 setMenu(mMenu); |
|
824 mMenu = NULL; |
|
825 } |
606 |
826 |
607 if (isPostcaptureOn()) { |
827 if (isPostcaptureOn()) { |
608 mElapsedTimer.stop(); |
|
609 hideControls(); |
|
610 |
|
611 if (mRecordingAnimation && mRecordingIcon) { |
|
612 mRecordingAnimation->stop(); |
|
613 mRecordingIcon->setOpacity(0); |
|
614 } |
|
615 if (mMenu) { |
|
616 setMenu(mMenu); |
|
617 mMenu = NULL; |
|
618 } |
|
619 |
|
620 emit changeToPostcaptureView(); |
828 emit changeToPostcaptureView(); |
621 } |
829 } else { |
|
830 // post capture off, we need prepare new video |
|
831 // do the prepare when the previous video is ready |
|
832 connect(mVideoCaptureControl, SIGNAL(videoComposed(CxeError::Id, const QString&)), |
|
833 this, SLOT(prepareNewVideo(CxeError::Id))); |
|
834 } |
|
835 break; |
|
836 case CxeVideoCaptureControl::PlayingStartSound: |
|
837 // don't change anything |
622 break; |
838 break; |
623 default: |
839 default: |
624 // in any other state, just hide the controls |
840 // in any other state, just hide the controls |
625 setRecordingItemsVisibility(false); |
841 setRecordingItemsVisibility(false); |
626 break; |
842 break; |
627 } |
|
628 |
|
629 CX_DEBUG_EXIT_FUNCTION(); |
|
630 } |
|
631 |
|
632 void CxuiVideoPrecaptureView::updateOrientation(Qt::Orientation orientation) |
|
633 { |
|
634 CX_DEBUG_ENTER_FUNCTION(); |
|
635 |
|
636 hideControls(); |
|
637 mMainWindow->setOrientation(orientation); |
|
638 |
|
639 if (mToolBar) { |
|
640 if (orientation == Qt::Horizontal) { |
|
641 mToolBar->setOrientation(Qt::Vertical); |
|
642 } else { |
|
643 mToolBar->setOrientation(Qt::Horizontal); |
|
644 } |
|
645 } |
843 } |
646 |
844 |
647 CX_DEBUG_EXIT_FUNCTION(); |
845 CX_DEBUG_EXIT_FUNCTION(); |
648 } |
846 } |
649 |
847 |
769 // update the quality indicator on screen |
940 // update the quality indicator on screen |
770 updateQualityIcon(); |
941 updateQualityIcon(); |
771 |
942 |
772 // update video remaining time counter when video quality is changed |
943 // update video remaining time counter when video quality is changed |
773 updateTimeLabels(); |
944 updateTimeLabels(); |
774 } |
945 } else if (key == CxeSettingIds::GEOTAGGING) { |
775 } |
946 reloadIndicatorWidgets(); |
776 |
947 } else if (key == CxeSettingIds::VIDEO_MUTE_SETTING) { |
777 CX_DEBUG_EXIT_FUNCTION(); |
948 reloadIndicatorWidgets(); |
778 } |
949 } |
|
950 } |
|
951 |
|
952 CX_DEBUG_EXIT_FUNCTION(); |
|
953 } |
|
954 |
|
955 /*! |
|
956 * Handle scene mode change. |
|
957 * @param scene The new active scene mode. |
|
958 */ |
|
959 void CxuiVideoPrecaptureView::handleSceneChanged(CxeScene &scene) |
|
960 { |
|
961 CX_DEBUG_ENTER_FUNCTION(); |
|
962 // Ignore if not in video mode. |
|
963 if (mEngine->mode() == Cxe::VideoMode) { |
|
964 // Update toolbar scene mode icon. |
|
965 updateSceneIcon(scene[CxeSettingIds::SCENE_ID].toString()); |
|
966 } |
|
967 |
|
968 CX_DEBUG_EXIT_FUNCTION(); |
|
969 } |
|
970 |
|
971 |
779 |
972 |
780 /*! |
973 /*! |
781 Sets the visibility of recording icon and elapsed time text. |
974 Sets the visibility of recording icon and elapsed time text. |
782 \param visible True if widgets are to be shown, false if not. |
975 \param visible True if widgets are to be shown, false if not. |
783 */ |
976 */ |