camerauis/cameraxui/cxui/src/cxuivideoprecaptureview.cpp
changeset 24 2094593137f5
parent 21 fa6d9f75d6a6
child 29 699651f2666f
equal deleted inserted replaced
21:fa6d9f75d6a6 24:2094593137f5
    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"
    58 
    57 
    59 namespace
    58 namespace
    60 {
    59 {
    61     static const int CXUI_ELAPSED_TIME_TIMEOUT = 1000; // 1 second
    60     static const int CXUI_ELAPSED_TIME_TIMEOUT = 1000; // 1 second
    62     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
    63 
    63 
    64     //!@todo Localization?
    64     //!@todo Localization?
    65     static const char* VIDEO_TIME_FORMAT = "%02d:%02d";
    65     static const char* VIDEO_TIME_FORMAT = "%02d:%02d";
    66 }
    66 }
    67 
    67 
   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()),
   113     connect(mVideoCaptureControl, SIGNAL(remainingTimeChanged()),
   114             this, SLOT(updateTimeLabels()));
   114             this, SLOT(updateTimeLabels()));
   115 
   115 
       
   116     mPauseTimer.setSingleShot(true);
       
   117     connect(&mPauseTimer, SIGNAL(timeout()), this, SLOT(stop()));
       
   118     mPauseTimer.setInterval(CXUI_PAUSE_TIMEOUT);
       
   119 
   116     HbAction *quitAction = new HbAction(Hb::QuitNaviAction, this);
   120     HbAction *quitAction = new HbAction(Hb::QuitNaviAction, this);
   117     setNavigationAction(quitAction);
   121     setNavigationAction(quitAction);
   118     connect(quitAction, SIGNAL(triggered()), this, SLOT(handleQuitClicked()));
   122     connect(quitAction, SIGNAL(triggered()), this, SLOT(handleQuitClicked()));
   119 
   123 
   120     loadDefaultWidgets();
   124     loadDefaultWidgets();
   249 
   253 
   250     mWidgetsLoaded = true;
   254     mWidgetsLoaded = true;
   251 
   255 
   252     // Initializing recording indicator animation
   256     // Initializing recording indicator animation
   253     mRecordingAnimation = new QPropertyAnimation(mRecordingIcon, "opacity");
   257     mRecordingAnimation = new QPropertyAnimation(mRecordingIcon, "opacity");
   254     mRecordingAnimation->setStartValue(0.0);
   258     mRecordingAnimation->setStartValue(0.2);
   255     mRecordingAnimation->setKeyValueAt(0.5, 1.0);
   259     mRecordingAnimation->setKeyValueAt(0.5, 1.0);
   256     mRecordingAnimation->setEndValue(0.0);
   260     mRecordingAnimation->setEndValue(0.2);
   257     mRecordingAnimation->setDuration(CXUI_RECORD_ANIMATION_DURATION);
   261     mRecordingAnimation->setDuration(CXUI_RECORD_ANIMATION_DURATION);
   258     mRecordingAnimation->setLoopCount(-1);
   262     mRecordingAnimation->setLoopCount(-1);
   259     mRecordingAnimation->setEasingCurve(QEasingCurve::InCubic);
   263     mRecordingAnimation->setEasingCurve(QEasingCurve::OutInQuad);
   260 
   264 
   261     // Initialize the video time counters.
   265     // Initialize the video time counters.
   262     updateTimeLabels();
   266     updateTimeLabels();
   263 
   267 
   264     CX_DEBUG_EXIT_FUNCTION();
   268     CX_DEBUG_EXIT_FUNCTION();
   304     int time(0);
   308     int time(0);
   305     mVideoCaptureControl->remainingTime(time);
   309     mVideoCaptureControl->remainingTime(time);
   306 
   310 
   307     if (time) {
   311     if (time) {
   308         mMenu = takeMenu();
   312         mMenu = takeMenu();
   309         hideControls();
       
   310         mVideoCaptureControl->record();
   313         mVideoCaptureControl->record();
   311     } else {
   314     } else {
   312         launchDiskFullNotification();
   315         launchDiskFullNotification();
   313     }
   316     }
   314 
   317 
   319 {
   322 {
   320     CX_DEBUG_ENTER_FUNCTION();
   323     CX_DEBUG_ENTER_FUNCTION();
   321 
   324 
   322     CxeVideoCaptureControl::State state = mVideoCaptureControl->state();
   325     CxeVideoCaptureControl::State state = mVideoCaptureControl->state();
   323     if (state == CxeVideoCaptureControl::Recording) {
   326     if (state == CxeVideoCaptureControl::Recording) {
   324         if (mRecordingAnimation && mRecordingIcon) {
   327         mVideoCaptureControl->pause();
   325             mVideoCaptureControl->pause();
       
   326             mRecordingAnimation->stop();
       
   327             }
       
   328 
       
   329         // force update of toolbar
       
   330         showToolbar();
       
   331     } else if (state == CxeVideoCaptureControl::Paused) {
   328     } else if (state == CxeVideoCaptureControl::Paused) {
   332         mVideoCaptureControl->record();
   329         mVideoCaptureControl->record();
   333         //mRecordingAnimation->start();
       
   334     }
   330     }
   335 
   331 
   336     CX_DEBUG_EXIT_FUNCTION();
   332     CX_DEBUG_EXIT_FUNCTION();
   337 }
   333 }
   338 
   334 
   406 
   402 
   407 void CxuiVideoPrecaptureView::disableFeedback()
   403 void CxuiVideoPrecaptureView::disableFeedback()
   408 {
   404 {
   409     CX_DEBUG_ENTER_FUNCTION();
   405     CX_DEBUG_ENTER_FUNCTION();
   410 
   406 
   411     HbFeedbackPlayer* feedback = HbFeedbackPlayer::instance();
   407     HbFeedbackSettings settings;
   412     if (feedback) {
   408     settings.disableFeedback();
   413         feedback->settings().disableFeedback();
   409 
   414     }
   410 
   415     CX_DEBUG_EXIT_FUNCTION();
   411     CX_DEBUG_EXIT_FUNCTION();
   416 }
   412 }
   417 
   413 
   418 void CxuiVideoPrecaptureView::enableFeedback()
   414 void CxuiVideoPrecaptureView::enableFeedback()
   419 {
   415 {
   420     CX_DEBUG_ENTER_FUNCTION();
   416     CX_DEBUG_ENTER_FUNCTION();
   421 
   417 
   422     HbFeedbackPlayer* feedback = HbFeedbackPlayer::instance();
   418     HbFeedbackSettings settings;
   423     if (feedback) {
   419     settings.enableFeedback();
   424         feedback->settings().disableFeedback();
   420 
   425     }
       
   426 
   421 
   427     CX_DEBUG_EXIT_FUNCTION();
   422     CX_DEBUG_EXIT_FUNCTION();
   428 }
   423 }
   429 
   424 
   430 
   425 
   486 
   481 
   487     CX_DEBUG_EXIT_FUNCTION();
   482     CX_DEBUG_EXIT_FUNCTION();
   488 }
   483 }
   489 
   484 
   490 /*!
   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 
       
   498 }
       
   499 
       
   500 /*!
   491 * Helper method for formatting video time to requested label.
   501 * Helper method for formatting video time to requested label.
   492 * @param label Text label to show the time.
   502 * @param label Text label to show the time.
   493 * @param time Time in seconds to be formatted to the label text.
   503 * @param time Time in seconds to be formatted to the label text.
   494 */
   504 */
   495 void CxuiVideoPrecaptureView::setVideoTime(HbLabel* label, int time)
   505 void CxuiVideoPrecaptureView::setVideoTime(HbLabel* label, int time)
   545     CX_DEBUG_ENTER_FUNCTION();
   555     CX_DEBUG_ENTER_FUNCTION();
   546     Q_UNUSED(error);
   556     Q_UNUSED(error);
   547 
   557 
   548     updateTimeLabels();
   558     updateTimeLabels();
   549 
   559 
       
   560     mPauseTimer.stop();
       
   561 
   550     switch (newState) {
   562     switch (newState) {
   551     case CxeVideoCaptureControl::Ready:
   563     case CxeVideoCaptureControl::Ready:
   552         if (mDocumentLoader){
   564         if (mDocumentLoader){
   553             mDocumentLoader->load(VIDEO_1ST_XML, VIDEO_PRE_CAPTURE_IDLE);
   565             mDocumentLoader->load(VIDEO_1ST_XML, VIDEO_PRE_CAPTURE_IDLE);
   554         }
   566         }
   556             mCapturePending = false;
   568             mCapturePending = false;
   557             record();
   569             record();
   558         }
   570         }
   559         break;
   571         break;
   560     case CxeVideoCaptureControl::Recording:
   572     case CxeVideoCaptureControl::Recording:
       
   573         hideControls();
   561         if (mDocumentLoader){
   574         if (mDocumentLoader){
   562             mDocumentLoader->load(VIDEO_1ST_XML, VIDEO_PRE_CAPTURE_RECORDING);
   575             mDocumentLoader->load(VIDEO_1ST_XML, VIDEO_PRE_CAPTURE_RECORDING);
   563         }
   576         }
   564         mElapsedTimer.start(CXUI_ELAPSED_TIME_TIMEOUT);
   577         mElapsedTimer.start(CXUI_ELAPSED_TIME_TIMEOUT);
   565         disableFeedback();
   578         disableFeedback();
       
   579         if (mRecordingAnimation && mRecordingIcon) {
       
   580             mRecordingAnimation->start();
       
   581         }
   566         break;
   582         break;
   567     case CxeVideoCaptureControl::Paused:
   583     case CxeVideoCaptureControl::Paused:
   568         mElapsedTimer.stop();
   584         mElapsedTimer.stop();
   569 
   585 
   570         if (mDocumentLoader){
   586         if (mDocumentLoader){
   571             mDocumentLoader->load(VIDEO_1ST_XML, VIDEO_PRE_CAPTURE_PAUSED);
   587             mDocumentLoader->load(VIDEO_1ST_XML, VIDEO_PRE_CAPTURE_PAUSED);
   572         }
   588         }
   573 
   589 
       
   590         if (mRecordingAnimation && mRecordingIcon) {
       
   591             mRecordingAnimation->stop();
       
   592         }
       
   593         showControls();
   574         enableFeedback();
   594         enableFeedback();
       
   595         mPauseTimer.start();
   575         break;
   596         break;
   576     case CxeVideoCaptureControl::Stopping:
   597     case CxeVideoCaptureControl::Stopping:
   577         if (mDocumentLoader){
   598         if (mDocumentLoader){
   578             mDocumentLoader->load(VIDEO_1ST_XML, VIDEO_PRE_CAPTURE_PAUSED);
   599             mDocumentLoader->load(VIDEO_1ST_XML, VIDEO_PRE_CAPTURE_PAUSED);
   579         }
   600         }
   580 
   601 
       
   602         if (mRecordingAnimation && mRecordingIcon) {
       
   603             mRecordingAnimation->stop();
       
   604         }
   581         enableFeedback();
   605         enableFeedback();
   582 
   606 
   583         if (isPostcaptureOn()) {
   607         if (isPostcaptureOn()) {
   584             mElapsedTimer.stop();
   608             mElapsedTimer.stop();
   585             hideControls();
   609             hideControls();
   628     CX_DEBUG_ENTER_FUNCTION();
   652     CX_DEBUG_ENTER_FUNCTION();
   629     CxeVideoCaptureControl::State state = mVideoCaptureControl->state();
   653     CxeVideoCaptureControl::State state = mVideoCaptureControl->state();
   630 
   654 
   631     switch (state) {
   655     switch (state) {
   632         case CxeVideoCaptureControl::Ready:
   656         case CxeVideoCaptureControl::Ready:
   633         case CxeVideoCaptureControl::Paused:
       
   634             record();
   657             record();
   635             break;
   658             break;
   636         case CxeVideoCaptureControl::Recording:
   659         case CxeVideoCaptureControl::Recording:
       
   660         case CxeVideoCaptureControl::Paused:
   637             stop();
   661             stop();
   638             break;
   662             break;
   639         case CxeVideoCaptureControl::Idle:
   663         case CxeVideoCaptureControl::Idle:
   640         case CxeVideoCaptureControl::Initialized:
   664         case CxeVideoCaptureControl::Initialized:
   641         case CxeVideoCaptureControl::Preparing:
   665         case CxeVideoCaptureControl::Preparing:
   669 void CxuiVideoPrecaptureView::handleQuitClicked()
   693 void CxuiVideoPrecaptureView::handleQuitClicked()
   670 {
   694 {
   671     CX_DEBUG_ENTER_FUNCTION();
   695     CX_DEBUG_ENTER_FUNCTION();
   672 
   696 
   673     CxeVideoCaptureControl::State state = mVideoCaptureControl->state();
   697     CxeVideoCaptureControl::State state = mVideoCaptureControl->state();
   674     if (state == CxeVideoCaptureControl::Recording){
   698     if (state == CxeVideoCaptureControl::Recording ||
       
   699         state == CxeVideoCaptureControl::Paused) {
   675         // 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.
   676         disconnect(mVideoCaptureControl, SIGNAL(stateChanged(CxeVideoCaptureControl::State, CxeError::Id)),
   701         disconnect(mVideoCaptureControl, SIGNAL(stateChanged(CxeVideoCaptureControl::State, CxeError::Id)),
   677                    this, SLOT(handleVideoStateChanged(CxeVideoCaptureControl::State,CxeError::Id)));
   702                    this, SLOT(handleVideoStateChanged(CxeVideoCaptureControl::State,CxeError::Id)));
   678         mVideoCaptureControl->stop();
   703         mVideoCaptureControl->stop();
   679         mElapsedTimer.stop();
   704         mElapsedTimer.stop();
   766     if (mElapsedTimeText) {
   791     if (mElapsedTimeText) {
   767         mElapsedTimeText->setVisible(visible);
   792         mElapsedTimeText->setVisible(visible);
   768     }
   793     }
   769 }
   794 }
   770 
   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 
   771 
   819 
   772 
   820 
   773 //end of file
   821 //end of file