camerauis/cameraxui/cxui/src/cxuivideoprecaptureview.cpp
changeset 28 3075d9b614e6
parent 19 d9aefe59d544
child 38 0f0b4c1d7744
child 43 0e652f8f1fbd
equal deleted inserted replaced
19:d9aefe59d544 28:3075d9b614e6
     1 /*
     1 /*
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    27 #include <hblabel.h>
    27 #include <hblabel.h>
    28 #include <hbslider.h>
    28 #include <hbslider.h>
    29 #include <hbmenu.h>
    29 #include <hbmenu.h>
    30 #include <hbdialog.h>
    30 #include <hbdialog.h>
    31 #include <hbnotificationdialog.h>
    31 #include <hbnotificationdialog.h>
    32 #include <hbfeedbackplayer.h>
       
    33 #include <hbfeedbacksettings.h>
    32 #include <hbfeedbacksettings.h>
    34 #include <hbfeedbacknamespace.h>
    33 #include <hbfeedbacknamespace.h>
    35 
    34 
    36 #include "cxuivideoprecaptureview.h"
    35 #include "cxuivideoprecaptureview.h"
    37 #include "cxeengine.h"
    36 #include "cxeengine.h"
    40 #include "cxecameradevicecontrol.h"
    39 #include "cxecameradevicecontrol.h"
    41 #include "cxenamespace.h"
    40 #include "cxenamespace.h"
    42 #include "cxesettings.h"
    41 #include "cxesettings.h"
    43 #include "cxuienums.h"
    42 #include "cxuienums.h"
    44 #include "cxutils.h"
    43 #include "cxutils.h"
       
    44 #include "cxuizoomslider.h"
    45 #include "cxuicapturekeyhandler.h"
    45 #include "cxuicapturekeyhandler.h"
    46 #include "cxuidocumentloader.h"
    46 #include "cxuidocumentloader.h"
    47 #include "OstTraceDefinitions.h"
    47 #include "OstTraceDefinitions.h"
    48 #ifdef OST_TRACE_COMPILER_IN_USE
    48 #ifdef OST_TRACE_COMPILER_IN_USE
    49 #include "cxuivideoprecaptureviewTraces.h"
    49 #include "cxuivideoprecaptureviewTraces.h"
    57 
    57 
    58 namespace
    58 namespace
    59 {
    59 {
    60     static const int CXUI_ELAPSED_TIME_TIMEOUT = 1000; // 1 second
    60     static const int CXUI_ELAPSED_TIME_TIMEOUT = 1000; // 1 second
    61     static const int CXUI_RECORD_ANIMATION_DURATION = 3000; // milliseconds
    61     static const int CXUI_RECORD_ANIMATION_DURATION = 3000; // milliseconds
       
    62     static const int CXUI_PAUSE_TIMEOUT = 60*1000;   // 60 seconds
    62 
    63 
    63     //!@todo Localization?
    64     //!@todo Localization?
    64     static const char* VIDEO_TIME_FORMAT = "%02d:%02d";
    65     static const char* VIDEO_TIME_FORMAT = "%02d:%02d";
    65 }
    66 }
    66 
    67 
    75     mRecordingIcon(NULL),
    76     mRecordingIcon(NULL),
    76     mGoToStillAction(NULL),
    77     mGoToStillAction(NULL),
    77     mToolBarIdle(NULL),
    78     mToolBarIdle(NULL),
    78     mToolBarRec(NULL),
    79     mToolBarRec(NULL),
    79     mToolBarPaused(NULL),
    80     mToolBarPaused(NULL),
    80     mToggleLightAction(NULL),
       
    81     mVideoScenePopup(NULL),
    81     mVideoScenePopup(NULL),
    82     mVideoCaptureControl(NULL),
    82     mVideoCaptureControl(NULL),
    83     mMenu(NULL),
    83     mMenu(NULL),
    84     mCapturePending(false)
    84     mCapturePending(false)
    85 {
    85 {
   108     connect(&mElapsedTimer, SIGNAL(timeout()), this, SLOT(updateTimeLabels()));
   108     connect(&mElapsedTimer, SIGNAL(timeout()), this, SLOT(updateTimeLabels()));
   109     connect(mVideoCaptureControl, SIGNAL(snapshotReady(CxeError::Id, const QPixmap&, const QString&)),
   109     connect(mVideoCaptureControl, SIGNAL(snapshotReady(CxeError::Id, const QPixmap&, const QString&)),
   110             this, SLOT(handleSnapshot(CxeError::Id)));
   110             this, SLOT(handleSnapshot(CxeError::Id)));
   111     connect(mVideoCaptureControl, SIGNAL(stateChanged(CxeVideoCaptureControl::State, CxeError::Id)),
   111     connect(mVideoCaptureControl, SIGNAL(stateChanged(CxeVideoCaptureControl::State, CxeError::Id)),
   112             this, SLOT(handleVideoStateChanged(CxeVideoCaptureControl::State,CxeError::Id)));
   112             this, SLOT(handleVideoStateChanged(CxeVideoCaptureControl::State,CxeError::Id)));
       
   113     connect(mVideoCaptureControl, SIGNAL(remainingTimeChanged()),
       
   114             this, SLOT(updateTimeLabels()));
       
   115 
       
   116     mPauseTimer.setSingleShot(true);
       
   117     connect(&mPauseTimer, SIGNAL(timeout()), this, SLOT(stop()));
       
   118     mPauseTimer.setInterval(CXUI_PAUSE_TIMEOUT);
   113 
   119 
   114     HbAction *quitAction = new HbAction(Hb::QuitNaviAction, this);
   120     HbAction *quitAction = new HbAction(Hb::QuitNaviAction, this);
   115     setNavigationAction(quitAction);
   121     setNavigationAction(quitAction);
   116     connect(quitAction, SIGNAL(triggered()), this, SLOT(handleQuitClicked()));
   122     connect(quitAction, SIGNAL(triggered()), this, SLOT(handleQuitClicked()));
   117 
   123 
   136 
   142 
   137     widget = mDocumentLoader->findWidget(VIDEO_PRE_CAPTURE_QUALITY_ICON);
   143     widget = mDocumentLoader->findWidget(VIDEO_PRE_CAPTURE_QUALITY_ICON);
   138     mQualityIcon = qobject_cast<HbLabel *> (widget);
   144     mQualityIcon = qobject_cast<HbLabel *> (widget);
   139     CX_DEBUG_ASSERT(mQualityIcon);
   145     CX_DEBUG_ASSERT(mQualityIcon);
   140 
   146 
   141     // Create background graphics for indicator containers
       
   142     HbWidget *indicatorContainer;
       
   143     widget = mDocumentLoader->findWidget(VIDEO_PRE_CAPTURE_INDICATOR_CONTAINER_TOP);
   147     widget = mDocumentLoader->findWidget(VIDEO_PRE_CAPTURE_INDICATOR_CONTAINER_TOP);
   144     indicatorContainer = qobject_cast<HbWidget *>(widget);
   148     mIndicators = qobject_cast<HbWidget *>(widget);
   145     CX_DEBUG_ASSERT(indicatorContainer);
   149     CX_DEBUG_ASSERT(mIndicators);
   146     createWidgetBackgroundGraphic(indicatorContainer, TRANSPARENT_BACKGROUND_GRAPHIC);
   150     // Create background graphics for indicator container
   147     indicatorContainer->show();
   151     createWidgetBackgroundGraphic(mIndicators, TRANSPARENT_BACKGROUND_GRAPHIC);
   148 
   152 
   149     CX_DEBUG_EXIT_FUNCTION();
   153     CX_DEBUG_EXIT_FUNCTION();
   150 }
   154 }
   151 
   155 
   152 void CxuiVideoPrecaptureView::loadWidgets()
   156 void CxuiVideoPrecaptureView::loadWidgets()
   175         mDocumentLoader->load(VIDEO_1ST_XML, VIDEO_PRE_CAPTURE_STANDALONE_SECTION, &ok);
   179         mDocumentLoader->load(VIDEO_1ST_XML, VIDEO_PRE_CAPTURE_STANDALONE_SECTION, &ok);
   176     }
   180     }
   177     Q_ASSERT_X(ok, "camerax ui", "error in xml file parsing");
   181     Q_ASSERT_X(ok, "camerax ui", "error in xml file parsing");
   178     // get needed pointers to some of the widgets
   182     // get needed pointers to some of the widgets
   179     widget = mDocumentLoader->findWidget(VIDEO_PRE_CAPTURE_ZOOM_SLIDER);
   183     widget = mDocumentLoader->findWidget(VIDEO_PRE_CAPTURE_ZOOM_SLIDER);
   180     mSlider = qobject_cast<HbSlider *> (widget);
   184     mSlider = qobject_cast<CxuiZoomSlider *> (widget);
   181     CX_DEBUG_ASSERT(mSlider);
   185     CX_DEBUG_ASSERT(mSlider);
   182 
   186 
   183     //Let's add a plus and minus buttons to the slider
   187     //Let's add a plus and minus buttons to the slider
   184     addIncreaseDecreaseButtons(mSlider);
   188     addIncreaseDecreaseButtons(mSlider);
   185     createWidgetBackgroundGraphic(mSlider, TRANSPARENT_BACKGROUND_GRAPHIC);
   189     createWidgetBackgroundGraphic(mSlider, TRANSPARENT_BACKGROUND_GRAPHIC);
   195 
   199 
   196     CX_DEBUG_ASSERT(mToolBarIdle);
   200     CX_DEBUG_ASSERT(mToolBarIdle);
   197     CX_DEBUG_ASSERT(mToolBarRec);
   201     CX_DEBUG_ASSERT(mToolBarRec);
   198     CX_DEBUG_ASSERT(mToolBarPaused);
   202     CX_DEBUG_ASSERT(mToolBarPaused);
   199 
   203 
   200     QObject* object = mDocumentLoader->findObject(VIDEO_PRE_CAPTURE_TOGGLE_LIGHT_ACTION);
       
   201     mToggleLightAction = qobject_cast<HbAction *>(object);
       
   202     CX_DEBUG_ASSERT(mToggleLightAction);
       
   203 
       
   204     hideControls();
   204     hideControls();
   205 
   205 
   206     if (CxuiServiceProvider::isCameraEmbedded()) {
   206     if (CxuiServiceProvider::isCameraEmbedded()) {
   207         CX_DEBUG(("EMBEDDED: camera in embedded mode"));
   207         CX_DEBUG(("EMBEDDED: camera in embedded mode"));
   208 
   208 
   225             }
   225             }
   226         }
   226         }
   227         if (!CxuiServiceProvider::instance()->allowCameraSwitching()) {
   227         if (!CxuiServiceProvider::instance()->allowCameraSwitching()) {
   228             CX_DEBUG(("EMBEDDED: don't allow camera switching"));
   228             CX_DEBUG(("EMBEDDED: don't allow camera switching"));
   229 
   229 
   230             HbAction *goto_2nd_cam = qobject_cast<HbAction*> (mDocumentLoader->findObject(VIDEO_PRE_CAPTURE_GOTO_2ND_CAMERA_ACTION));
   230         }
   231             if (goto_2nd_cam) {
   231 
   232                 CX_DEBUG(("EMBEDDED: setting camera switch to disabled"));
   232     }
   233                 goto_2nd_cam->setEnabled(false);
   233 
   234 
   234 
   235             }
   235     // Create background graphic for indicator container
   236         }
       
   237 
       
   238     }
       
   239 
       
   240 
       
   241     // Create background graphics for indicator containers
       
   242     HbWidget *indicatorContainer;
   236     HbWidget *indicatorContainer;
   243 
       
   244 
       
   245     widget = mDocumentLoader->findWidget(VIDEO_PRE_CAPTURE_INDICATOR_CONTAINER_BOTTOM);
   237     widget = mDocumentLoader->findWidget(VIDEO_PRE_CAPTURE_INDICATOR_CONTAINER_BOTTOM);
   246     indicatorContainer = qobject_cast<HbWidget *>(widget);
   238     indicatorContainer = qobject_cast<HbWidget *>(widget);
   247     CX_DEBUG_ASSERT(indicatorContainer);
   239     CX_DEBUG_ASSERT(indicatorContainer);
   248     createWidgetBackgroundGraphic(indicatorContainer, TRANSPARENT_BACKGROUND_GRAPHIC);
   240     createWidgetBackgroundGraphic(indicatorContainer, TRANSPARENT_BACKGROUND_GRAPHIC);
   249 
   241 
   261 
   253 
   262     mWidgetsLoaded = true;
   254     mWidgetsLoaded = true;
   263 
   255 
   264     // Initializing recording indicator animation
   256     // Initializing recording indicator animation
   265     mRecordingAnimation = new QPropertyAnimation(mRecordingIcon, "opacity");
   257     mRecordingAnimation = new QPropertyAnimation(mRecordingIcon, "opacity");
   266     mRecordingAnimation->setStartValue(0.0);
   258     mRecordingAnimation->setStartValue(0.2);
   267     mRecordingAnimation->setKeyValueAt(0.5, 1.0);
   259     mRecordingAnimation->setKeyValueAt(0.5, 1.0);
   268     mRecordingAnimation->setEndValue(0.0);
   260     mRecordingAnimation->setEndValue(0.2);
   269     mRecordingAnimation->setDuration(CXUI_RECORD_ANIMATION_DURATION);
   261     mRecordingAnimation->setDuration(CXUI_RECORD_ANIMATION_DURATION);
   270     mRecordingAnimation->setLoopCount(-1);
   262     mRecordingAnimation->setLoopCount(-1);
   271     mRecordingAnimation->setEasingCurve(QEasingCurve::InCubic);
   263     mRecordingAnimation->setEasingCurve(QEasingCurve::OutInQuad);
   272 
   264 
   273     // Initialize the video time counters.
   265     // Initialize the video time counters.
   274     updateTimeLabels();
   266     updateTimeLabels();
   275 
   267 
   276     CX_DEBUG_EXIT_FUNCTION();
   268     CX_DEBUG_EXIT_FUNCTION();
   311 
   303 
   312 void CxuiVideoPrecaptureView::record()
   304 void CxuiVideoPrecaptureView::record()
   313 {
   305 {
   314     CX_DEBUG_ENTER_FUNCTION();
   306     CX_DEBUG_ENTER_FUNCTION();
   315 
   307 
   316     mMenu = takeMenu();
   308     int time(0);
   317     hideControls();
   309     mVideoCaptureControl->remainingTime(time);
   318     mVideoCaptureControl->record();
   310 
   319     //mRecordingAnimation->start();
   311     if (time) {
       
   312         mMenu = takeMenu();
       
   313         mVideoCaptureControl->record();
       
   314     } else {
       
   315         launchDiskFullNotification();
       
   316     }
       
   317 
   320     CX_DEBUG_EXIT_FUNCTION();
   318     CX_DEBUG_EXIT_FUNCTION();
   321 }
   319 }
   322 
   320 
   323 void CxuiVideoPrecaptureView::pause()
   321 void CxuiVideoPrecaptureView::pause()
   324 {
   322 {
   325     CX_DEBUG_ENTER_FUNCTION();
   323     CX_DEBUG_ENTER_FUNCTION();
   326 
   324 
   327     CxeVideoCaptureControl::State state = mVideoCaptureControl->state();
   325     CxeVideoCaptureControl::State state = mVideoCaptureControl->state();
   328     if (state == CxeVideoCaptureControl::Recording) {
   326     if (state == CxeVideoCaptureControl::Recording) {
   329         if (mRecordingAnimation && mRecordingIcon) {
   327         mVideoCaptureControl->pause();
   330             mVideoCaptureControl->pause();
       
   331             mRecordingAnimation->stop();
       
   332             }
       
   333 
       
   334         // force update of toolbar
       
   335         showToolbar();
       
   336     } else if (state == CxeVideoCaptureControl::Paused) {
   328     } else if (state == CxeVideoCaptureControl::Paused) {
   337         mVideoCaptureControl->record();
   329         mVideoCaptureControl->record();
   338         //mRecordingAnimation->start();
       
   339     }
   330     }
   340 
   331 
   341     CX_DEBUG_EXIT_FUNCTION();
   332     CX_DEBUG_EXIT_FUNCTION();
   342 }
   333 }
   343 
   334 
   411 
   402 
   412 void CxuiVideoPrecaptureView::disableFeedback()
   403 void CxuiVideoPrecaptureView::disableFeedback()
   413 {
   404 {
   414     CX_DEBUG_ENTER_FUNCTION();
   405     CX_DEBUG_ENTER_FUNCTION();
   415 
   406 
   416     HbFeedbackPlayer* feedback = HbFeedbackPlayer::instance();
   407     HbFeedbackSettings settings;
   417     if (feedback) {
   408     settings.disableFeedback();
   418         feedback->settings().disableFeedback();
   409 
   419     }
   410 
   420     CX_DEBUG_EXIT_FUNCTION();
   411     CX_DEBUG_EXIT_FUNCTION();
   421 }
   412 }
   422 
   413 
   423 void CxuiVideoPrecaptureView::enableFeedback()
   414 void CxuiVideoPrecaptureView::enableFeedback()
   424 {
   415 {
   425     CX_DEBUG_ENTER_FUNCTION();
   416     CX_DEBUG_ENTER_FUNCTION();
   426 
   417 
   427     HbFeedbackPlayer* feedback = HbFeedbackPlayer::instance();
   418     HbFeedbackSettings settings;
   428     if (feedback) {
   419     settings.enableFeedback();
   429         feedback->settings().disableFeedback();
   420 
   430     }
       
   431 
   421 
   432     CX_DEBUG_EXIT_FUNCTION();
   422     CX_DEBUG_EXIT_FUNCTION();
   433 }
   423 }
   434 
   424 
   435 
   425 
   461     }
   451     }
   462 
   452 
   463     CxeVideoCaptureControl::State state = mVideoCaptureControl->state();
   453     CxeVideoCaptureControl::State state = mVideoCaptureControl->state();
   464     switch (state) {
   454     switch (state) {
   465         case CxeVideoCaptureControl::Ready:
   455         case CxeVideoCaptureControl::Ready:
   466             // Update remaining time label
       
   467             getRemainingTime();
   456             getRemainingTime();
   468             setVideoTime(mRemainingTimeText, mTimeRemaining);
       
   469             // Update elapsed time label
       
   470             // Not recording => elapsed time is zero
   457             // Not recording => elapsed time is zero
   471             mTimeElapsed = 0;
   458             mTimeElapsed = 0;
   472             setVideoTime(mElapsedTimeText, mTimeElapsed);
       
   473 
       
   474             // Adjust labels' visibility
       
   475             mRemainingTimeText->show();
       
   476             mElapsedTimeText->show();
       
   477             break;
   459             break;
   478 
   460 
   479         case CxeVideoCaptureControl::Recording:
   461         case CxeVideoCaptureControl::Recording:
   480         case CxeVideoCaptureControl::Paused:
   462         case CxeVideoCaptureControl::Paused:
   481             // Update remaining time label
       
   482             getRemainingTime();
   463             getRemainingTime();
   483             setVideoTime(mRemainingTimeText, mTimeRemaining);
       
   484             // Update elapsed time label
       
   485             getElapsedTime();
   464             getElapsedTime();
   486             setVideoTime(mElapsedTimeText, mTimeElapsed);
       
   487 
       
   488             // Adjust labels' visibility
       
   489             mRemainingTimeText->show();
       
   490             mElapsedTimeText->show();
       
   491             break;
   465             break;
   492 
   466 
   493         case CxeVideoCaptureControl::Idle:
   467         case CxeVideoCaptureControl::Idle:
   494         case CxeVideoCaptureControl::Initialized:
   468         case CxeVideoCaptureControl::Initialized:
   495         case CxeVideoCaptureControl::Preparing:
   469         case CxeVideoCaptureControl::Preparing:
   496         default:
   470         default:
   497             // Minimize processing during initialization phase.
   471             // Minimize processing during initialization phase.
   498             // Calculating remaining time involves checking disk space,
   472             // Calculating remaining time involves checking disk space, avoiding that.
   499             // which
   473             // which
   500             mTimeRemaining = 0;
   474             mTimeRemaining = 0;
   501             setVideoTime(mRemainingTimeText, mTimeRemaining);
       
   502             mTimeElapsed = 0;
   475             mTimeElapsed = 0;
   503             setVideoTime(mElapsedTimeText, mTimeElapsed);
       
   504 
       
   505             // Adjust labels' visibility
       
   506             mRemainingTimeText->hide();
       
   507             mElapsedTimeText->hide();
       
   508             break;
   476             break;
   509     }
   477     }
   510 
   478 
   511     CX_DEBUG_EXIT_FUNCTION();
   479     setVideoTime(mRemainingTimeText, mTimeRemaining);
       
   480     setVideoTime(mElapsedTimeText, mTimeElapsed);
       
   481 
       
   482     CX_DEBUG_EXIT_FUNCTION();
       
   483 }
       
   484 
       
   485 /*!
       
   486   Overridded version of hideControls() that doesn't hide the controls when video recording
       
   487   is paused.
       
   488  */
       
   489 void CxuiVideoPrecaptureView::hideControls()
       
   490 {
       
   491     if (mVideoCaptureControl && mVideoCaptureControl->state() == CxeVideoCaptureControl::Paused) {
       
   492         // never hide controls in paused state
       
   493         return;
       
   494     }
       
   495 
       
   496     CxuiPrecaptureView::hideControls();
       
   497 
   512 }
   498 }
   513 
   499 
   514 /*!
   500 /*!
   515 * Helper method for formatting video time to requested label.
   501 * Helper method for formatting video time to requested label.
   516 * @param label Text label to show the time.
   502 * @param label Text label to show the time.
   557     if (event->type() == QEvent::Show) {
   543     if (event->type() == QEvent::Show) {
   558         event->accept();
   544         event->accept();
   559     }
   545     }
   560 }
   546 }
   561 
   547 
       
   548 /*!
       
   549 * Slot to handle video capture control state change.
       
   550 * Update visible items and stop / start timers.
       
   551 */
   562 void CxuiVideoPrecaptureView::handleVideoStateChanged(CxeVideoCaptureControl::State newState,
   552 void CxuiVideoPrecaptureView::handleVideoStateChanged(CxeVideoCaptureControl::State newState,
   563         CxeError::Id error)
   553         CxeError::Id error)
   564 {
   554 {
   565     CX_DEBUG_ENTER_FUNCTION();
   555     CX_DEBUG_ENTER_FUNCTION();
   566     Q_UNUSED(error);
   556     Q_UNUSED(error);
   567 
   557 
   568     updateTimeLabels();
   558     updateTimeLabels();
   569 
   559 
       
   560     mPauseTimer.stop();
       
   561 
   570     switch (newState) {
   562     switch (newState) {
   571     case CxeVideoCaptureControl::Ready:
   563     case CxeVideoCaptureControl::Ready:
   572         setRecordingItemsVisibility(false);
   564         if (mDocumentLoader){
       
   565             mDocumentLoader->load(VIDEO_1ST_XML, VIDEO_PRE_CAPTURE_IDLE);
       
   566         }
   573         if (mCapturePending) {
   567         if (mCapturePending) {
   574             mCapturePending = false;
   568             mCapturePending = false;
   575             record();
   569             record();
   576         }
   570         }
   577         break;
   571         break;
   578     case CxeVideoCaptureControl::Recording:
   572     case CxeVideoCaptureControl::Recording:
   579         setRecordingItemsVisibility(true);
   573         hideControls();
       
   574         if (mDocumentLoader){
       
   575             mDocumentLoader->load(VIDEO_1ST_XML, VIDEO_PRE_CAPTURE_RECORDING);
       
   576         }
   580         mElapsedTimer.start(CXUI_ELAPSED_TIME_TIMEOUT);
   577         mElapsedTimer.start(CXUI_ELAPSED_TIME_TIMEOUT);
   581         disableFeedback();
   578         disableFeedback();
       
   579         if (mRecordingAnimation && mRecordingIcon) {
       
   580             mRecordingAnimation->start();
       
   581         }
   582         break;
   582         break;
   583     case CxeVideoCaptureControl::Paused:
   583     case CxeVideoCaptureControl::Paused:
   584         mElapsedTimer.stop();
   584         mElapsedTimer.stop();
   585         if (mRecordingIcon) {
   585 
   586             mRecordingIcon->hide();
   586         if (mDocumentLoader){
   587         }
   587             mDocumentLoader->load(VIDEO_1ST_XML, VIDEO_PRE_CAPTURE_PAUSED);
   588         if (mElapsedTimeText) {
   588         }
   589             mElapsedTimeText->show();
   589 
   590         }
   590         if (mRecordingAnimation && mRecordingIcon) {
       
   591             mRecordingAnimation->stop();
       
   592         }
       
   593         showControls();
   591         enableFeedback();
   594         enableFeedback();
       
   595         mPauseTimer.start();
   592         break;
   596         break;
   593     case CxeVideoCaptureControl::Stopping:
   597     case CxeVideoCaptureControl::Stopping:
   594         setRecordingItemsVisibility(false);
   598         if (mDocumentLoader){
       
   599             mDocumentLoader->load(VIDEO_1ST_XML, VIDEO_PRE_CAPTURE_PAUSED);
       
   600         }
       
   601 
       
   602         if (mRecordingAnimation && mRecordingIcon) {
       
   603             mRecordingAnimation->stop();
       
   604         }
   595         enableFeedback();
   605         enableFeedback();
   596 
   606 
   597         if (isPostcaptureOn()) {
   607         if (isPostcaptureOn()) {
   598             mElapsedTimer.stop();
   608             mElapsedTimer.stop();
   599             hideControls();
   609             hideControls();
   642     CX_DEBUG_ENTER_FUNCTION();
   652     CX_DEBUG_ENTER_FUNCTION();
   643     CxeVideoCaptureControl::State state = mVideoCaptureControl->state();
   653     CxeVideoCaptureControl::State state = mVideoCaptureControl->state();
   644 
   654 
   645     switch (state) {
   655     switch (state) {
   646         case CxeVideoCaptureControl::Ready:
   656         case CxeVideoCaptureControl::Ready:
   647         case CxeVideoCaptureControl::Paused:
       
   648             record();
   657             record();
   649             break;
   658             break;
   650         case CxeVideoCaptureControl::Recording:
   659         case CxeVideoCaptureControl::Recording:
       
   660         case CxeVideoCaptureControl::Paused:
   651             stop();
   661             stop();
   652             break;
   662             break;
   653         case CxeVideoCaptureControl::Idle:
   663         case CxeVideoCaptureControl::Idle:
   654         case CxeVideoCaptureControl::Initialized:
   664         case CxeVideoCaptureControl::Initialized:
   655         case CxeVideoCaptureControl::Preparing:
   665         case CxeVideoCaptureControl::Preparing:
   683 void CxuiVideoPrecaptureView::handleQuitClicked()
   693 void CxuiVideoPrecaptureView::handleQuitClicked()
   684 {
   694 {
   685     CX_DEBUG_ENTER_FUNCTION();
   695     CX_DEBUG_ENTER_FUNCTION();
   686 
   696 
   687     CxeVideoCaptureControl::State state = mVideoCaptureControl->state();
   697     CxeVideoCaptureControl::State state = mVideoCaptureControl->state();
   688     if (state == CxeVideoCaptureControl::Recording){
   698     if (state == CxeVideoCaptureControl::Recording ||
       
   699         state == CxeVideoCaptureControl::Paused) {
   689         // Disable going to post-capture when video capture control goes to stopping state.
   700         // Disable going to post-capture when video capture control goes to stopping state.
   690         disconnect(mVideoCaptureControl, SIGNAL(stateChanged(CxeVideoCaptureControl::State, CxeError::Id)),
   701         disconnect(mVideoCaptureControl, SIGNAL(stateChanged(CxeVideoCaptureControl::State, CxeError::Id)),
   691                    this, SLOT(handleVideoStateChanged(CxeVideoCaptureControl::State,CxeError::Id)));
   702                    this, SLOT(handleVideoStateChanged(CxeVideoCaptureControl::State,CxeError::Id)));
   692         mVideoCaptureControl->stop();
   703         mVideoCaptureControl->stop();
   693         mElapsedTimer.stop();
   704         mElapsedTimer.stop();
   699 }
   710 }
   700 
   711 
   701 void CxuiVideoPrecaptureView::handleFocusLost()
   712 void CxuiVideoPrecaptureView::handleFocusLost()
   702 {
   713 {
   703     CX_DEBUG_IN_FUNCTION();
   714     CX_DEBUG_IN_FUNCTION();
       
   715     // Release camera. Stopping possibly ongoing recording is handled by engine.
       
   716     releaseCamera();
       
   717 }
       
   718 
       
   719 void CxuiVideoPrecaptureView::handleBatteryEmpty()
       
   720 {
       
   721     CX_DEBUG_ENTER_FUNCTION();
   704 
   722 
   705     CxeVideoCaptureControl::State state = mVideoCaptureControl->state();
   723     CxeVideoCaptureControl::State state = mVideoCaptureControl->state();
   706     if (state == CxeVideoCaptureControl::Recording){
   724     if (state == CxeVideoCaptureControl::Recording){
   707         stop(); // delete recording icon
   725         stop(); // delete recording icon
   708     } else {
       
   709         releaseCamera();
       
   710     }
       
   711 
       
   712 }
       
   713 
       
   714 void CxuiVideoPrecaptureView::handleBatteryEmpty()
       
   715 {
       
   716     CX_DEBUG_ENTER_FUNCTION();
       
   717 
       
   718     CxeVideoCaptureControl::State state = mVideoCaptureControl->state();
       
   719     if (state == CxeVideoCaptureControl::Recording){
       
   720         stop(); // delete recording icon
       
   721     }
   726     }
   722     CX_DEBUG_EXIT_FUNCTION();
   727     CX_DEBUG_EXIT_FUNCTION();
   723 }
   728 }
   724 
   729 
   725 
   730 
   726 void CxuiVideoPrecaptureView::launchVideoScenePopup()
   731 void CxuiVideoPrecaptureView::launchVideoScenePopup()
   727 {
   732 {
   728     CX_DEBUG_ENTER_FUNCTION();
   733     CX_DEBUG_ENTER_FUNCTION();
   729 
   734     hideControls();
   730     if (mVideoScenePopup) {
   735     emit showScenesView();
   731         CX_DEBUG(("mVideoScenePopup already exists, showing..."));
       
   732         mVideoScenePopup->show();
       
   733     } else {
       
   734         CX_DEBUG(("Loading popup DocML"));
       
   735         CxuiDocumentLoader* documentLoader = new CxuiDocumentLoader(mEngine);
       
   736         bool ok = false;
       
   737 
       
   738         // Use document loader to create popup
       
   739         documentLoader->load(SCENEMODE_VIDEO_SETTING_XML, &ok);
       
   740 
       
   741         CX_DEBUG(("load ok=%d", ok));
       
   742 
       
   743         mVideoScenePopup = qobject_cast<HbDialog*>(documentLoader->findWidget("video_scenemode_popup"));
       
   744         CX_DEBUG_ASSERT(mVideoScenePopup);
       
   745         mVideoScenePopup->setTimeout(HbDialog::NoTimeout);
       
   746         mVideoScenePopup->setBackgroundFaded(false);
       
   747 
       
   748         delete documentLoader;
       
   749         documentLoader = NULL;
       
   750     }
       
   751 
       
   752     connect(mKeyHandler, SIGNAL(autofocusKeyPressed()), mVideoScenePopup, SLOT(close()));
       
   753 
       
   754     CX_DEBUG_EXIT_FUNCTION();
   736     CX_DEBUG_EXIT_FUNCTION();
   755 }
   737 }
   756 
   738 
   757 
   739 
   758 /*!
   740 /*!
   809     if (mElapsedTimeText) {
   791     if (mElapsedTimeText) {
   810         mElapsedTimeText->setVisible(visible);
   792         mElapsedTimeText->setVisible(visible);
   811     }
   793     }
   812 }
   794 }
   813 
   795 
       
   796 /*!
       
   797  * Overridden eventFilter() to restart the pause timer.
       
   798  */
       
   799 bool CxuiVideoPrecaptureView::eventFilter(QObject *object, QEvent *event)
       
   800 {
       
   801 
       
   802     if (mVideoCaptureControl && mVideoCaptureControl->state() == CxeVideoCaptureControl::Paused) {
       
   803         // restart the timer if the screen is touched and we are in paused state
       
   804         switch (event->type())
       
   805         {
       
   806         case QEvent::GraphicsSceneMouseRelease:
       
   807             mPauseTimer.start();
       
   808             break;
       
   809         case QEvent::GraphicsSceneMousePress:
       
   810             mPauseTimer.stop();
       
   811             break;
       
   812         default:
       
   813             break;
       
   814         }
       
   815     }
       
   816     return CxuiPrecaptureView::eventFilter(object, event);
       
   817 }
       
   818 
   814 
   819 
   815 
   820 
   816 //end of file
   821 //end of file