46 #include "cxuizoomslider.h" |
46 #include "cxuizoomslider.h" |
47 #include "cxuicapturekeyhandler.h" |
47 #include "cxuicapturekeyhandler.h" |
48 #include "cxuidocumentloader.h" |
48 #include "cxuidocumentloader.h" |
49 #include "cxuiserviceprovider.h" |
49 #include "cxuiserviceprovider.h" |
50 |
50 |
|
51 #ifdef Q_OS_SYMBIAN |
51 #include "OstTraceDefinitions.h" |
52 #include "OstTraceDefinitions.h" |
|
53 |
52 #ifdef OST_TRACE_COMPILER_IN_USE |
54 #ifdef OST_TRACE_COMPILER_IN_USE |
53 #include "cxuivideoprecaptureviewTraces.h" |
55 #include "cxuivideoprecaptureviewTraces.h" |
54 #endif |
56 #endif |
55 |
57 |
|
58 #include <e32keys.h> |
|
59 #endif //Q_OS_SYMBIAN |
56 |
60 |
57 using namespace Cxe; |
61 using namespace Cxe; |
58 using namespace CxUiLayout; |
62 using namespace CxUiLayout; |
59 using namespace CxUiInternal; |
63 using namespace CxUiInternal; |
60 |
64 |
64 static const int CXUI_RECORD_ANIMATION_DURATION = 3000; // milliseconds |
68 static const int CXUI_RECORD_ANIMATION_DURATION = 3000; // milliseconds |
65 static const int CXUI_PAUSE_TIMEOUT = 60*1000; // 60 seconds |
69 static const int CXUI_PAUSE_TIMEOUT = 60*1000; // 60 seconds |
66 |
70 |
67 //!@todo Localization? |
71 //!@todo Localization? |
68 static const char* VIDEO_TIME_FORMAT = "%02d:%02d"; |
72 static const char* VIDEO_TIME_FORMAT = "%02d:%02d"; |
|
73 const int POSTCAPTURE_ON = -1; |
69 } |
74 } |
70 |
75 |
71 |
76 |
72 CxuiVideoPrecaptureView::CxuiVideoPrecaptureView(QGraphicsItem *parent) : |
77 CxuiVideoPrecaptureView::CxuiVideoPrecaptureView(QGraphicsItem *parent) : |
73 CxuiPrecaptureView(parent), |
78 CxuiPrecaptureView(parent), |
74 mElapsedTimer(this), |
79 mElapsedTimer(this), |
75 mTimeElapsed(0), |
80 mTimeElapsed(0), |
76 mTimeRemaining(0), |
81 mTimeRemaining(0), |
77 mElapsedTimeText(NULL), |
82 mVideoTimeText(NULL), |
78 mRemainingTimeText(NULL), |
|
79 mRecordingIcon(NULL), |
83 mRecordingIcon(NULL), |
80 mGoToStillAction(NULL), |
84 mGoToStillAction(NULL), |
81 mToolbarIdle(NULL), |
85 mToolbarIdle(NULL), |
82 mToolbarRec(NULL), |
86 mToolbarRec(NULL), |
83 mToolbarPaused(NULL), |
87 mToolbarPaused(NULL), |
115 mCaptureKeyHandler = keyHandler; |
119 mCaptureKeyHandler = keyHandler; |
116 |
120 |
117 mVideoCaptureControl = &(engine->videoCaptureControl()); |
121 mVideoCaptureControl = &(engine->videoCaptureControl()); |
118 |
122 |
119 connect(&mElapsedTimer, SIGNAL(timeout()), this, SLOT(updateTimeLabels())); |
123 connect(&mElapsedTimer, SIGNAL(timeout()), this, SLOT(updateTimeLabels())); |
120 connect(mVideoCaptureControl, SIGNAL(snapshotReady(CxeError::Id, const QImage&, const QString&)), |
|
121 this, SLOT(handleSnapshot(CxeError::Id))); |
|
122 connect(mVideoCaptureControl, SIGNAL(stateChanged(CxeVideoCaptureControl::State, CxeError::Id)), |
124 connect(mVideoCaptureControl, SIGNAL(stateChanged(CxeVideoCaptureControl::State, CxeError::Id)), |
123 this, SLOT(handleVideoStateChanged(CxeVideoCaptureControl::State,CxeError::Id))); |
125 this, SLOT(handleVideoStateChanged(CxeVideoCaptureControl::State,CxeError::Id))); |
124 connect(&(mEngine->settings()), SIGNAL(sceneChanged(CxeScene&)), |
|
125 this, SLOT(handleSceneChanged(CxeScene&))); |
|
126 connect(mVideoCaptureControl, SIGNAL(remainingTimeChanged()), |
126 connect(mVideoCaptureControl, SIGNAL(remainingTimeChanged()), |
127 this, SLOT(updateTimeLabels())); |
127 this, SLOT(updateTimeLabels())); |
|
128 |
|
129 mEngine->settings().listenForSetting(CxeSettingIds::VIDEO_SCENE, this, SLOT(handleSceneChanged(const QVariant&))); |
128 |
130 |
129 mPauseTimer.setSingleShot(true); |
131 mPauseTimer.setSingleShot(true); |
130 connect(&mPauseTimer, SIGNAL(timeout()), this, SLOT(stop())); |
132 connect(&mPauseTimer, SIGNAL(timeout()), this, SLOT(stop())); |
131 mPauseTimer.setInterval(CXUI_PAUSE_TIMEOUT); |
133 mPauseTimer.setInterval(CXUI_PAUSE_TIMEOUT); |
132 |
134 |
160 |
162 |
161 CX_DEBUG_EXIT_FUNCTION(); |
163 CX_DEBUG_EXIT_FUNCTION(); |
162 } |
164 } |
163 |
165 |
164 /*! |
166 /*! |
165 * Loads default indicators from docml and modifies the visibility |
167 * Loads default indicators from docml and modifies the visibility |
166 * according to current settings. |
168 * according to current settings. |
167 */ |
169 */ |
168 void CxuiVideoPrecaptureView::reloadIndicatorWidgets() |
170 void CxuiVideoPrecaptureView::reloadIndicatorWidgets() |
169 { |
171 { |
170 CX_DEBUG_ENTER_FUNCTION(); |
172 CX_DEBUG_ENTER_FUNCTION(); |
206 if (graphicsLayoutItem) { |
208 if (graphicsLayoutItem) { |
207 graphicsItem = graphicsLayoutItem->graphicsItem(); |
209 graphicsItem = graphicsLayoutItem->graphicsItem(); |
208 currentSettingValue = -1; |
210 currentSettingValue = -1; |
209 if (graphicsItem == videoaudiomuteIndicatorIcon) { |
211 if (graphicsItem == videoaudiomuteIndicatorIcon) { |
210 key = CxeSettingIds::VIDEO_MUTE_SETTING; |
212 key = CxeSettingIds::VIDEO_MUTE_SETTING; |
211 mEngine->settings().get(key, currentSettingValue); |
213 currentSettingValue = mEngine->settings().get(key, currentSettingValue); |
212 // video mute implementation does not use |
214 // video mute implementation does not use |
213 // enum for on/off values but instead |
215 // enum for on/off values but instead |
214 // 0 for off and 1 for on. |
216 // 0 for off and 1 for on. |
215 if (currentSettingValue == 0) { |
217 if (currentSettingValue == 0) { |
216 isSettingOff = true; |
218 isSettingOff = true; |
217 } |
219 } |
218 } else if (graphicsItem == videoStabilityIndicatorIcon) { |
220 } else if (graphicsItem == videoStabilityIndicatorIcon) { |
321 widget = mDocumentLoader->findWidget(VIDEO_PRE_CAPTURE_INDICATOR_CONTAINER_BOTTOM); |
323 widget = mDocumentLoader->findWidget(VIDEO_PRE_CAPTURE_INDICATOR_CONTAINER_BOTTOM); |
322 indicatorContainer = qobject_cast<HbWidget *>(widget); |
324 indicatorContainer = qobject_cast<HbWidget *>(widget); |
323 CX_ASSERT_ALWAYS(indicatorContainer); |
325 CX_ASSERT_ALWAYS(indicatorContainer); |
324 createWidgetBackgroundGraphic(indicatorContainer, TRANSPARENT_BACKGROUND_GRAPHIC); |
326 createWidgetBackgroundGraphic(indicatorContainer, TRANSPARENT_BACKGROUND_GRAPHIC); |
325 |
327 |
326 widget = mDocumentLoader->findWidget(VIDEO_PRE_CAPTURE_ELAPSED_TIME_LABEL); |
328 widget = mDocumentLoader->findWidget(VIDEO_PRE_CAPTURE_VIDEO_TIME_LABEL); |
327 mElapsedTimeText = qobject_cast<HbLabel *> (widget); |
329 mVideoTimeText = qobject_cast<HbLabel *> (widget); |
328 CX_ASSERT_ALWAYS(mElapsedTimeText); |
330 CX_ASSERT_ALWAYS(mVideoTimeText); |
329 |
|
330 widget = mDocumentLoader->findWidget(VIDEO_PRE_CAPTURE_REMAINING_TIME_LABEL); |
|
331 mRemainingTimeText = qobject_cast<HbLabel *> (widget); |
|
332 CX_ASSERT_ALWAYS(mRemainingTimeText); |
|
333 |
331 |
334 widget = mDocumentLoader->findWidget(VIDEO_PRE_CAPTURE_RECORDING_ICON); |
332 widget = mDocumentLoader->findWidget(VIDEO_PRE_CAPTURE_RECORDING_ICON); |
335 mRecordingIcon = qobject_cast<HbLabel *> (widget); |
333 mRecordingIcon = qobject_cast<HbLabel *> (widget); |
336 CX_ASSERT_ALWAYS(mRecordingIcon); |
334 CX_ASSERT_ALWAYS(mRecordingIcon); |
337 |
335 |
346 mRecordingAnimation->setLoopCount(-1); |
344 mRecordingAnimation->setLoopCount(-1); |
347 mRecordingAnimation->setEasingCurve(QEasingCurve::OutInQuad); |
345 mRecordingAnimation->setEasingCurve(QEasingCurve::OutInQuad); |
348 |
346 |
349 |
347 |
350 // Update toolbar scene mode icon. |
348 // Update toolbar scene mode icon. |
351 QString sceneId; |
349 try { |
352 if (mEngine->settings().get(CxeSettingIds::SCENE_ID, sceneId) == CxeError::None) { |
350 updateSceneIcon(mEngine->settings().get<QString>(CxeSettingIds::VIDEO_SCENE)); |
353 updateSceneIcon(sceneId); |
351 } catch (CxeException &e) { |
|
352 // ignore error |
354 } |
353 } |
355 |
354 |
356 // Initialize the video time counters. |
355 // Initialize the video time counters. |
357 updateTimeLabels(); |
356 updateTimeLabels(); |
358 |
357 |
423 |
422 |
424 connect(mCaptureKeyHandler, SIGNAL(autofocusKeyPressed()), mSettingsGrid, SLOT(close())); |
423 connect(mCaptureKeyHandler, SIGNAL(autofocusKeyPressed()), mSettingsGrid, SLOT(close())); |
425 } |
424 } |
426 } |
425 } |
427 |
426 |
|
427 |
428 /** |
428 /** |
429 * Get if postcapture view should be shown or not. |
429 * Get if postcapture view should be shown or not. |
430 * Postcapture view may be shown for a predefined time or |
430 * Postcapture view may be shown for a predefined time or |
431 * until user dismisses it, or it may be completely disabled. |
431 * until user dismisses it, or it may be completely disabled. |
432 */ |
432 */ |
439 return true; |
439 return true; |
440 } |
440 } |
441 |
441 |
442 // Read the value from settings. Ignoring reading error. |
442 // Read the value from settings. Ignoring reading error. |
443 // On error (missing settings) default to "postcapture on". |
443 // On error (missing settings) default to "postcapture on". |
444 int showPostcapture(-1); |
444 int showPostcapture(POSTCAPTURE_ON); |
445 if(mEngine) { |
445 if(mEngine) { |
446 mEngine->settings().get(CxeSettingIds::VIDEO_SHOWCAPTURED, showPostcapture); |
446 showPostcapture = mEngine->settings().get<int>(CxeSettingIds::VIDEO_SHOWCAPTURED, POSTCAPTURE_ON); |
447 } |
447 } |
448 |
448 |
449 CX_DEBUG_EXIT_FUNCTION(); |
449 CX_DEBUG_EXIT_FUNCTION(); |
450 return showPostcapture != 0; // 0 == no postcapture |
450 return showPostcapture != 0; // 0 == no postcapture |
451 } |
451 } |
488 { |
488 { |
489 CX_DEBUG_ENTER_FUNCTION(); |
489 CX_DEBUG_ENTER_FUNCTION(); |
490 |
490 |
491 if (mQualityIcon && mEngine) { |
491 if (mQualityIcon && mEngine) { |
492 QString icon = ""; |
492 QString icon = ""; |
493 int currentValue = -1; |
493 |
494 |
494 int currentValue = mEngine->settings().get<int>(CxeSettingIds::VIDEO_QUALITY, -1); |
495 mEngine->settings().get(CxeSettingIds::VIDEO_QUALITY, currentValue); |
|
496 icon = getSettingItemIcon(CxeSettingIds::VIDEO_QUALITY, currentValue); |
495 icon = getSettingItemIcon(CxeSettingIds::VIDEO_QUALITY, currentValue); |
497 |
496 |
498 mQualityIcon->setIcon(HbIcon(icon)); |
497 mQualityIcon->setIcon(HbIcon(icon)); |
499 } |
498 } |
500 |
|
501 CX_DEBUG_EXIT_FUNCTION(); |
|
502 } |
|
503 |
|
504 void CxuiVideoPrecaptureView::handleSnapshot(CxeError::Id /*error*/) |
|
505 { |
|
506 CX_DEBUG_ENTER_FUNCTION(); |
|
507 |
499 |
508 CX_DEBUG_EXIT_FUNCTION(); |
500 CX_DEBUG_EXIT_FUNCTION(); |
509 } |
501 } |
510 |
502 |
511 void CxuiVideoPrecaptureView::record() |
503 void CxuiVideoPrecaptureView::record() |
650 */ |
644 */ |
651 void CxuiVideoPrecaptureView::updateTimeLabels() |
645 void CxuiVideoPrecaptureView::updateTimeLabels() |
652 { |
646 { |
653 CX_DEBUG_IN_FUNCTION(); |
647 CX_DEBUG_IN_FUNCTION(); |
654 |
648 |
655 if (!mRemainingTimeText || !mElapsedTimeText) { |
649 if (!mVideoTimeText) { |
656 // Section not loaded yet. Skip update until created. |
650 // Section not loaded yet. Skip update until created. |
657 CX_DEBUG(("CxuiVideoPrecaptureView: video time labels not loaded yet!")); |
651 CX_DEBUG(("CxuiVideoPrecaptureView: video time labels not loaded yet!")); |
658 CX_DEBUG_EXIT_FUNCTION(); |
652 CX_DEBUG_EXIT_FUNCTION(); |
659 return; |
653 return; |
660 } |
654 } |
707 } |
700 } |
708 |
701 |
709 /*! |
702 /*! |
710 * Helper method for formatting video time to requested label. |
703 * Helper method for formatting video time to requested label. |
711 * @param label Text label to show the time. |
704 * @param label Text label to show the time. |
712 * @param time Time in seconds to be formatted to the label text. |
705 * @param elapsedTime Elapsed time in seconds to be formatted to the label text. |
713 */ |
706 * @param remainingTime Remaining time in seconds to be formatted to the label text. |
714 void CxuiVideoPrecaptureView::setVideoTime(HbLabel* label, int time) |
707 */ |
|
708 void CxuiVideoPrecaptureView::setVideoTime(HbLabel* label, |
|
709 int elapsedTime, |
|
710 int remainingTime) |
715 { |
711 { |
716 // Convert time (seconds) into mm:ss |
712 // Convert time (seconds) into mm:ss |
717 // HbExtendedLocale wraps minutes at 60 so we can't use that. |
713 // HbExtendedLocale wraps minutes at 60 so we can't use that. |
718 // We need to show times over 1 hour, e.g. "90:00". |
714 // We need to show times over 1 hour, e.g. "90:00". |
719 QString timeString; |
715 QString elapsed, remaining; |
720 timeString.sprintf(VIDEO_TIME_FORMAT, time/60, time%60); |
716 elapsed.sprintf(VIDEO_TIME_FORMAT, elapsedTime/60, elapsedTime%60); |
721 label->setPlainText(timeString); |
717 remaining.sprintf(VIDEO_TIME_FORMAT, remainingTime/60, remainingTime%60); |
|
718 |
|
719 label->setPlainText(hbTrId("txt_cam_info_redorcding_time").arg(elapsed).arg(remaining)); |
722 } |
720 } |
723 |
721 |
724 bool CxuiVideoPrecaptureView::getElapsedTime() |
722 bool CxuiVideoPrecaptureView::getElapsedTime() |
725 { |
723 { |
726 CX_DEBUG_ENTER_FUNCTION(); |
724 CX_DEBUG_ENTER_FUNCTION(); |
782 hideControls(); |
780 hideControls(); |
783 emit stopStandbyTimer(); |
781 emit stopStandbyTimer(); |
784 if (mDocumentLoader){ |
782 if (mDocumentLoader){ |
785 mDocumentLoader->load(VIDEO_1ST_XML, VIDEO_PRE_CAPTURE_RECORDING); |
783 mDocumentLoader->load(VIDEO_1ST_XML, VIDEO_PRE_CAPTURE_RECORDING); |
786 } |
784 } |
|
785 |
787 mElapsedTimer.start(CXUI_ELAPSED_TIME_TIMEOUT); |
786 mElapsedTimer.start(CXUI_ELAPSED_TIME_TIMEOUT); |
788 disableFeedback(); |
787 disableFeedback(); |
789 |
788 |
790 // commented out the activation of the recording animation because |
789 // commented out the activation of the recording animation because |
791 // it is causing issues when using SW rendering |
790 // it is causing issues when using SW rendering |
954 |
952 |
955 /*! |
953 /*! |
956 * Handle scene mode change. |
954 * Handle scene mode change. |
957 * @param scene The new active scene mode. |
955 * @param scene The new active scene mode. |
958 */ |
956 */ |
959 void CxuiVideoPrecaptureView::handleSceneChanged(CxeScene &scene) |
957 void CxuiVideoPrecaptureView::handleSceneChanged(const QVariant &scene) |
960 { |
958 { |
961 CX_DEBUG_ENTER_FUNCTION(); |
959 CX_DEBUG_ENTER_FUNCTION(); |
962 // Ignore if not in video mode. |
960 // Ignore if not in video mode. |
963 if (mEngine->mode() == Cxe::VideoMode) { |
961 if (mEngine->mode() == Cxe::VideoMode) { |
964 // Update toolbar scene mode icon. |
962 // Update toolbar scene mode icon. |
965 updateSceneIcon(scene[CxeSettingIds::SCENE_ID].toString()); |
963 updateSceneIcon(scene.toString()); |
966 } |
964 } |
967 |
965 |
968 CX_DEBUG_EXIT_FUNCTION(); |
966 CX_DEBUG_EXIT_FUNCTION(); |
969 } |
|
970 |
|
971 |
|
972 |
|
973 /*! |
|
974 Sets the visibility of recording icon and elapsed time text. |
|
975 \param visible True if widgets are to be shown, false if not. |
|
976 */ |
|
977 void CxuiVideoPrecaptureView::setRecordingItemsVisibility(bool visible) { |
|
978 |
|
979 if (mRecordingIcon) { |
|
980 mRecordingIcon->setVisible(visible); |
|
981 mRecordingIcon->setOpacity(1.0f); |
|
982 } |
|
983 |
|
984 if (mElapsedTimeText) { |
|
985 mElapsedTimeText->setVisible(visible); |
|
986 } |
|
987 } |
967 } |
988 |
968 |
989 /*! |
969 /*! |
990 * Overridden eventFilter() to restart the pause timer. |
970 * Overridden eventFilter() to restart the pause timer. |
991 */ |
971 */ |