camerauis/cameraxui/cxui/src/cxuivideoprecaptureview.cpp
changeset 58 ddba9caa7f32
parent 55 0da2a5b56583
child 64 8ab66fc302e6
equal deleted inserted replaced
55:0da2a5b56583 58:ddba9caa7f32
    30 #include <hbmenu.h>
    30 #include <hbmenu.h>
    31 #include <hbdialog.h>
    31 #include <hbdialog.h>
    32 #include <hbnotificationdialog.h>
    32 #include <hbnotificationdialog.h>
    33 #include <hbfeedbacksettings.h>
    33 #include <hbfeedbacksettings.h>
    34 #include <hbfeedbacknamespace.h>
    34 #include <hbfeedbacknamespace.h>
    35 #include <hbactivitymanager.h>
    35 #include <afactivitystorage.h>
    36 #include <hbextendedlocale.h>
    36 #include <hbextendedlocale.h>
       
    37 #include <hbparameterlengthlimiter>
    37 
    38 
    38 #include "cxuivideoprecaptureview.h"
    39 #include "cxuivideoprecaptureview.h"
    39 #include "cxeengine.h"
    40 #include "cxeengine.h"
    40 #include "cxeviewfindercontrol.h"
    41 #include "cxeviewfindercontrol.h"
    41 #include "cxevideocapturecontrol.h"
    42 #include "cxevideocapturecontrol.h"
   107  * @param documentLoader
   108  * @param documentLoader
   108  * @param keyHandler
   109  * @param keyHandler
   109  */
   110  */
   110 void CxuiVideoPrecaptureView::construct(HbMainWindow *mainwindow, CxeEngine *engine,
   111 void CxuiVideoPrecaptureView::construct(HbMainWindow *mainwindow, CxeEngine *engine,
   111                                         CxuiDocumentLoader *documentLoader,
   112                                         CxuiDocumentLoader *documentLoader,
   112                                         CxuiCaptureKeyHandler *keyHandler,
   113                                         CxuiCaptureKeyHandler *keyHandler)
   113                                         HbActivityManager *activityManager)
   114 {
   114 {
   115     CX_DEBUG_ENTER_FUNCTION();
   115     CX_DEBUG_ENTER_FUNCTION();
   116 
   116 
   117     CxuiPrecaptureView::construct(mainwindow, engine, documentLoader, keyHandler);
   117     CxuiPrecaptureView::construct(mainwindow, engine, documentLoader, keyHandler, activityManager);
       
   118     mCaptureKeyHandler = keyHandler;
   118     mCaptureKeyHandler = keyHandler;
   119 
   119 
   120     mVideoCaptureControl = &(engine->videoCaptureControl());
   120     mVideoCaptureControl = &(engine->videoCaptureControl());
   121 
   121 
   122     connect(&mElapsedTimer, SIGNAL(timeout()), this, SLOT(updateTimeLabels()));
   122     connect(&mElapsedTimer, SIGNAL(timeout()), this, SLOT(updateTimeLabels()));
   288 
   288 
   289     hideControls();
   289     hideControls();
   290 
   290 
   291     if (CxuiServiceProvider::isCameraEmbedded()) {
   291     if (CxuiServiceProvider::isCameraEmbedded()) {
   292         CX_DEBUG(("EMBEDDED: camera in embedded mode"));
   292         CX_DEBUG(("EMBEDDED: camera in embedded mode"));
       
   293         setTitle(CxuiServiceProvider::instance()->windowTitle());
   293 
   294 
   294         if (!CxuiServiceProvider::instance()->allowQualityChange()) {
   295         if (!CxuiServiceProvider::instance()->allowQualityChange()) {
   295 
   296 
   296             CX_DEBUG(("EMBEDDED: don't allow quality change"));
   297             CX_DEBUG(("EMBEDDED: don't allow quality change"));
   297             HbAction* vq = qobject_cast<HbAction*> (mDocumentLoader->findObject(VIDEO_PRE_CAPTURE_VIDEO_QUALITY_ACTION));
   298             HbAction* vq = qobject_cast<HbAction*> (mDocumentLoader->findObject(VIDEO_PRE_CAPTURE_VIDEO_QUALITY_ACTION));
   379 void CxuiVideoPrecaptureView::saveActivity()
   380 void CxuiVideoPrecaptureView::saveActivity()
   380 {
   381 {
   381     CX_DEBUG_ENTER_FUNCTION();
   382     CX_DEBUG_ENTER_FUNCTION();
   382     QVariantMap data;
   383     QVariantMap data;
   383     QVariantHash params;
   384     QVariantHash params;
       
   385     AfActivityStorage activityStorage;
   384 
   386 
   385     HbIcon activityScreenshot("qtg_graf_taskswitcher_camcorder");
   387     HbIcon activityScreenshot("qtg_graf_taskswitcher_camcorder");
   386     QPixmap screenshot = activityScreenshot.pixmap();
   388     QPixmap screenshot = activityScreenshot.pixmap();
   387     params.insert("screenshot", screenshot);
   389     params.insert("screenshot", screenshot);
   388 
   390 
   389     mActivityManager->removeActivity(
   391     activityStorage.removeActivity(
   390             CxuiActivityIds::VIDEO_PRECAPTURE_ACTIVITY);
   392             CxuiActivityIds::VIDEO_PRECAPTURE_ACTIVITY);
   391     mActivityManager->addActivity(CxuiActivityIds::VIDEO_PRECAPTURE_ACTIVITY,
   393     activityStorage.saveActivity(CxuiActivityIds::VIDEO_PRECAPTURE_ACTIVITY,
   392                                   data, params);
   394                                   data, params);
   393     CX_DEBUG_EXIT_FUNCTION();
   395     CX_DEBUG_EXIT_FUNCTION();
   394 }
   396 }
   395 
   397 
   396 /*!
   398 /*!
   397  * Clear activity from activity manager.
   399  * Clear activity from activity storage.
   398  */
   400  */
   399 void CxuiVideoPrecaptureView::clearActivity()
   401 void CxuiVideoPrecaptureView::clearActivity()
   400 {
   402 {
   401     CX_DEBUG_ENTER_FUNCTION();
   403     CX_DEBUG_ENTER_FUNCTION();
   402     mActivityManager->removeActivity(CxuiActivityIds::VIDEO_PRECAPTURE_ACTIVITY);
   404     AfActivityStorage activityStorage;
       
   405     activityStorage.removeActivity(CxuiActivityIds::VIDEO_PRECAPTURE_ACTIVITY);
   403     CX_DEBUG_EXIT_FUNCTION();
   406     CX_DEBUG_EXIT_FUNCTION();
   404 }
   407 }
   405 
   408 
   406 /*!
   409 /*!
   407 * Initialize settings grid.
   410 * Initialize settings grid.
   536     }
   539     }
   537 
   540 
   538     CX_DEBUG_EXIT_FUNCTION();
   541     CX_DEBUG_EXIT_FUNCTION();
   539 }
   542 }
   540 
   543 
       
   544 /*!
       
   545  * Stops video recording if it is ongoing or paused.
       
   546  * \sa handleVideoStateChanged()
       
   547  */
   541 void CxuiVideoPrecaptureView::stop()
   548 void CxuiVideoPrecaptureView::stop()
   542 {
   549 {
   543     CX_DEBUG_ENTER_FUNCTION();
   550     CX_DEBUG_ENTER_FUNCTION();
   544 
   551 
   545     CxeVideoCaptureControl::State state = mVideoCaptureControl->state();
   552     CxeVideoCaptureControl::State state = mVideoCaptureControl->state();
   746     if (number.length() <= 1) {
   753     if (number.length() <= 1) {
   747         number.prepend(locale.zeroDigit());
   754         number.prepend(locale.zeroDigit());
   748     }
   755     }
   749     remaining.append(number);
   756     remaining.append(number);
   750 
   757 
   751     label->setPlainText(hbTrId("txt_cam_info_recording_time").arg(elapsed).arg(remaining));
   758     label->setPlainText(
       
   759 		HbParameterLengthLimiter("txt_cam_info_recording_time").arg(elapsed).arg(remaining));
   752 }
   760 }
   753 
   761 
   754 bool CxuiVideoPrecaptureView::getElapsedTime()
   762 bool CxuiVideoPrecaptureView::getElapsedTime()
   755 {
   763 {
   756     CX_DEBUG_ENTER_FUNCTION();
   764     CX_DEBUG_ENTER_FUNCTION();
   846         //}
   854         //}
   847 
   855 
   848         enableFeedback();
   856         enableFeedback();
   849         emit startStandbyTimer();
   857         emit startStandbyTimer();
   850         mElapsedTimer.stop();
   858         mElapsedTimer.stop();
   851         hideControls();
       
   852 
   859 
   853         if (mMenu) {
   860         if (mMenu) {
   854             setMenu(mMenu);
   861             setMenu(mMenu);
   855             mMenu = NULL;
   862             mMenu = NULL;
   856         }
   863         }
   912 
   919 
   913 void CxuiVideoPrecaptureView::handleQuitClicked()
   920 void CxuiVideoPrecaptureView::handleQuitClicked()
   914 {
   921 {
   915     CX_DEBUG_ENTER_FUNCTION();
   922     CX_DEBUG_ENTER_FUNCTION();
   916 
   923 
   917     CxeVideoCaptureControl::State state = mVideoCaptureControl->state();
   924     // Disable going to post-capture when video capture control goes to stopping state.
   918     if (state == CxeVideoCaptureControl::Recording ||
   925     disconnect(mVideoCaptureControl,
   919         state == CxeVideoCaptureControl::Paused) {
   926                SIGNAL(stateChanged(CxeVideoCaptureControl::State,
   920         // Disable going to post-capture when video capture control goes to stopping state.
   927                                    CxeError::Id)),
   921         disconnect(mVideoCaptureControl, SIGNAL(stateChanged(CxeVideoCaptureControl::State, CxeError::Id)),
   928                this,
   922                    this, SLOT(handleVideoStateChanged(CxeVideoCaptureControl::State,CxeError::Id)));
   929                SLOT(handleVideoStateChanged(CxeVideoCaptureControl::State,
   923         mVideoCaptureControl->stop();
   930                                             CxeError::Id)));
   924         mElapsedTimer.stop();
   931 
   925     }
   932     // stop video recording (if it is ongoing or paused)
       
   933     stop();
   926 
   934 
   927     QCoreApplication::exit();
   935     QCoreApplication::exit();
   928 
   936 
   929     CX_DEBUG_EXIT_FUNCTION();
   937     CX_DEBUG_EXIT_FUNCTION();
   930 }
   938 }
   977         } else if (key == CxeSettingIds::VIDEO_MUTE_SETTING) {
   985         } else if (key == CxeSettingIds::VIDEO_MUTE_SETTING) {
   978             reloadIndicatorWidgets();
   986             reloadIndicatorWidgets();
   979         }
   987         }
   980     }
   988     }
   981 
   989 
       
   990     CX_DEBUG_EXIT_FUNCTION();
       
   991 }
       
   992 
       
   993 /*!
       
   994  * Overridden version of CxuiPreCaptureView::enterStandby().
       
   995  * Handles video precapture specific standby preparations and calls
       
   996  * base class implementation. Standby is entered either via standby timer
       
   997  * or when application goes to background.
       
   998  * \sa CxuiView::enterStandby()
       
   999  * \sa CxuiPrecaptureView::enterStandby()
       
  1000  */
       
  1001 void CxuiVideoPrecaptureView::enterStandby()
       
  1002 {
       
  1003     CX_DEBUG_ENTER_FUNCTION();
       
  1004 
       
  1005     // stop video recording (if it is ongoing or paused)
       
  1006     stop();
       
  1007 
       
  1008     // call base class implemenation
       
  1009     CxuiPrecaptureView::enterStandby();
   982     CX_DEBUG_EXIT_FUNCTION();
  1010     CX_DEBUG_EXIT_FUNCTION();
   983 }
  1011 }
   984 
  1012 
   985 /*!
  1013 /*!
   986 * Handle scene mode change.
  1014 * Handle scene mode change.