camerauis/cameraxui/cxui/src/cxuivideoprecaptureview.cpp
changeset 48 42ba2d16bf40
parent 37 64817133cd1d
child 56 01e205c615b9
equal deleted inserted replaced
37:64817133cd1d 48:42ba2d16bf40
    13 *
    13 *
    14 * Description:
    14 * Description:
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 #include <e32keys.h>
    18 
    19 
    19 
    20 #include <QApplication>
    20 #include <QApplication>
       
    21 #include <QGraphicsLayout>
    21 
    22 
    22 #include <hbmainwindow.h>
    23 #include <hbmainwindow.h>
    23 #include <hbaction.h>
    24 #include <hbaction.h>
    24 #include <hbtoolbar.h>
    25 #include <hbtoolbar.h>
    25 #include <hbtoolbarextension.h>
    26 #include <hbtoolbarextension.h>
    43 #include "cxuienums.h"
    44 #include "cxuienums.h"
    44 #include "cxutils.h"
    45 #include "cxutils.h"
    45 #include "cxuizoomslider.h"
    46 #include "cxuizoomslider.h"
    46 #include "cxuicapturekeyhandler.h"
    47 #include "cxuicapturekeyhandler.h"
    47 #include "cxuidocumentloader.h"
    48 #include "cxuidocumentloader.h"
       
    49 #include "cxuiserviceprovider.h"
       
    50 
       
    51 #ifdef Q_OS_SYMBIAN
    48 #include "OstTraceDefinitions.h"
    52 #include "OstTraceDefinitions.h"
       
    53 
    49 #ifdef OST_TRACE_COMPILER_IN_USE
    54 #ifdef OST_TRACE_COMPILER_IN_USE
    50 #include "cxuivideoprecaptureviewTraces.h"
    55 #include "cxuivideoprecaptureviewTraces.h"
    51 #endif
    56 #endif
    52 #include "cxuiserviceprovider.h"
    57 
    53 
    58 #include <e32keys.h>
       
    59 #endif  //Q_OS_SYMBIAN
    54 
    60 
    55 using namespace Cxe;
    61 using namespace Cxe;
    56 using namespace CxUiLayout;
    62 using namespace CxUiLayout;
    57 using namespace CxUiInternal;
    63 using namespace CxUiInternal;
    58 
    64 
    62     static const int CXUI_RECORD_ANIMATION_DURATION = 3000; // milliseconds
    68     static const int CXUI_RECORD_ANIMATION_DURATION = 3000; // milliseconds
    63     static const int CXUI_PAUSE_TIMEOUT = 60*1000;   // 60 seconds
    69     static const int CXUI_PAUSE_TIMEOUT = 60*1000;   // 60 seconds
    64 
    70 
    65     //!@todo Localization?
    71     //!@todo Localization?
    66     static const char* VIDEO_TIME_FORMAT = "%02d:%02d";
    72     static const char* VIDEO_TIME_FORMAT = "%02d:%02d";
       
    73     const int POSTCAPTURE_ON = -1;
    67 }
    74 }
    68 
    75 
    69 
    76 
    70 CxuiVideoPrecaptureView::CxuiVideoPrecaptureView(QGraphicsItem *parent) :
    77 CxuiVideoPrecaptureView::CxuiVideoPrecaptureView(QGraphicsItem *parent) :
    71     CxuiPrecaptureView(parent),
    78     CxuiPrecaptureView(parent),
    72     mElapsedTimer(this),
    79     mElapsedTimer(this),
    73     mTimeElapsed(0),
    80     mTimeElapsed(0),
    74     mTimeRemaining(0),
    81     mTimeRemaining(0),
    75     mElapsedTimeText(NULL),
    82     mVideoTimeText(NULL),
    76     mRemainingTimeText(NULL),
       
    77     mRecordingIcon(NULL),
    83     mRecordingIcon(NULL),
    78     mGoToStillAction(NULL),
    84     mGoToStillAction(NULL),
    79     mToolbarIdle(NULL),
    85     mToolbarIdle(NULL),
    80     mToolbarRec(NULL),
    86     mToolbarRec(NULL),
    81     mToolbarPaused(NULL),
    87     mToolbarPaused(NULL),
    93     mElapsedTimer.stop();
    99     mElapsedTimer.stop();
    94     delete mMenu;
   100     delete mMenu;
    95     CX_DEBUG_EXIT_FUNCTION();
   101     CX_DEBUG_EXIT_FUNCTION();
    96 }
   102 }
    97 
   103 
       
   104 /*!
       
   105  * Construct-method handles initialisation tasks for this class.
       
   106  * @param mainwindow
       
   107  * @param engine
       
   108  * @param documentLoader
       
   109  * @param keyHandler
       
   110  */
    98 void CxuiVideoPrecaptureView::construct(HbMainWindow *mainwindow, CxeEngine *engine,
   111 void CxuiVideoPrecaptureView::construct(HbMainWindow *mainwindow, CxeEngine *engine,
    99                                         CxuiDocumentLoader *documentLoader,
   112                                         CxuiDocumentLoader *documentLoader,
   100                                         CxuiCaptureKeyHandler *keyHandler,
   113                                         CxuiCaptureKeyHandler *keyHandler,
   101                                         HbActivityManager *activityManager)
   114                                         HbActivityManager *activityManager)
   102 {
   115 {
   106     mCaptureKeyHandler = keyHandler;
   119     mCaptureKeyHandler = keyHandler;
   107 
   120 
   108     mVideoCaptureControl = &(engine->videoCaptureControl());
   121     mVideoCaptureControl = &(engine->videoCaptureControl());
   109 
   122 
   110     connect(&mElapsedTimer, SIGNAL(timeout()), this, SLOT(updateTimeLabels()));
   123     connect(&mElapsedTimer, SIGNAL(timeout()), this, SLOT(updateTimeLabels()));
   111     connect(mVideoCaptureControl, SIGNAL(snapshotReady(CxeError::Id, const QImage&, const QString&)),
       
   112             this, SLOT(handleSnapshot(CxeError::Id)));
       
   113     connect(mVideoCaptureControl, SIGNAL(stateChanged(CxeVideoCaptureControl::State, CxeError::Id)),
   124     connect(mVideoCaptureControl, SIGNAL(stateChanged(CxeVideoCaptureControl::State, CxeError::Id)),
   114             this, SLOT(handleVideoStateChanged(CxeVideoCaptureControl::State,CxeError::Id)));
   125             this, SLOT(handleVideoStateChanged(CxeVideoCaptureControl::State,CxeError::Id)));
   115     connect(&(mEngine->settings()), SIGNAL(sceneChanged(CxeScene&)),
       
   116             this, SLOT(handleSceneChanged(CxeScene&)));
       
   117     connect(mVideoCaptureControl, SIGNAL(remainingTimeChanged()),
   126     connect(mVideoCaptureControl, SIGNAL(remainingTimeChanged()),
   118             this, SLOT(updateTimeLabels()));
   127             this, SLOT(updateTimeLabels()));
       
   128 
       
   129     mEngine->settings().listenForSetting(CxeSettingIds::VIDEO_SCENE, this, SLOT(handleSceneChanged(const QVariant&)));
   119 
   130 
   120     mPauseTimer.setSingleShot(true);
   131     mPauseTimer.setSingleShot(true);
   121     connect(&mPauseTimer, SIGNAL(timeout()), this, SLOT(stop()));
   132     connect(&mPauseTimer, SIGNAL(timeout()), this, SLOT(stop()));
   122     mPauseTimer.setInterval(CXUI_PAUSE_TIMEOUT);
   133     mPauseTimer.setInterval(CXUI_PAUSE_TIMEOUT);
   123 
   134 
   131 
   142 
   132     CX_DEBUG_EXIT_FUNCTION();
   143     CX_DEBUG_EXIT_FUNCTION();
   133 
   144 
   134 }
   145 }
   135 
   146 
       
   147 /*!
       
   148  * Loads widgets that are needed right from the start.
       
   149  */
   136 void CxuiVideoPrecaptureView::loadDefaultWidgets()
   150 void CxuiVideoPrecaptureView::loadDefaultWidgets()
   137 {
   151 {
   138     CX_DEBUG_ENTER_FUNCTION();
   152     CX_DEBUG_ENTER_FUNCTION();
   139     CX_DEBUG_ASSERT(mDocumentLoader);
   153     CX_ASSERT_ALWAYS(mDocumentLoader);
   140 
   154 
   141     // get pointers to ui components from the layout data
   155     // get pointers to ui components from the layout data
   142     QGraphicsWidget *widget = NULL;
   156     QGraphicsWidget *widget = NULL;
   143     widget = mDocumentLoader->findWidget(VIDEO_PRE_CAPTURE_VIEWFINDER);
   157     widget = mDocumentLoader->findWidget(VIDEO_PRE_CAPTURE_VIEWFINDER);
   144     mViewfinder = qobject_cast<HbTransparentWindow *> (widget);
   158     mViewfinder = qobject_cast<HbTransparentWindow *> (widget);
   145     CX_DEBUG_ASSERT(mViewfinder);
   159     CX_ASSERT_ALWAYS(mViewfinder);
   146 
   160 
       
   161     reloadIndicatorWidgets();
       
   162 
       
   163     CX_DEBUG_EXIT_FUNCTION();
       
   164 }
       
   165 
       
   166 /*!
       
   167  * Loads default indicators from docml and modifies the visibility
       
   168  * according to current settings.
       
   169  */
       
   170 void CxuiVideoPrecaptureView::reloadIndicatorWidgets()
       
   171 {
       
   172     CX_DEBUG_ENTER_FUNCTION();
       
   173     CX_ASSERT_ALWAYS(mDocumentLoader);
       
   174 
       
   175     bool ok = false;
       
   176     mDocumentLoader->load(VIDEO_1ST_XML, VIDEO_PRE_CAPTURE_INDICATORS_SECTION, &ok);
       
   177     CX_ASSERT_ALWAYS(ok);
       
   178 
       
   179     QGraphicsWidget *widget = NULL;
   147     widget = mDocumentLoader->findWidget(VIDEO_PRE_CAPTURE_QUALITY_ICON);
   180     widget = mDocumentLoader->findWidget(VIDEO_PRE_CAPTURE_QUALITY_ICON);
   148     mQualityIcon = qobject_cast<HbLabel *> (widget);
   181     mQualityIcon = qobject_cast<HbLabel *> (widget);
   149     CX_DEBUG_ASSERT(mQualityIcon);
   182     CX_ASSERT_ALWAYS(mQualityIcon);
       
   183 
       
   184     widget = mDocumentLoader->findWidget(VIDEO_PRE_CAPTURE_VIDEOAUDIOMUTE_INDICATOR_ICON);
       
   185     HbLabel *videoaudiomuteIndicatorIcon = qobject_cast<HbLabel *>(widget);
       
   186     CX_ASSERT_ALWAYS(videoaudiomuteIndicatorIcon);
       
   187 
       
   188     widget = mDocumentLoader->findWidget(VIDEO_PRE_CAPTURE_STABILITY_INDICATOR_ICON);
       
   189     HbLabel *videoStabilityIndicatorIcon = qobject_cast<HbLabel *>(widget);
       
   190     CX_ASSERT_ALWAYS(videoStabilityIndicatorIcon);
   150 
   191 
   151     widget = mDocumentLoader->findWidget(VIDEO_PRE_CAPTURE_INDICATOR_CONTAINER_TOP);
   192     widget = mDocumentLoader->findWidget(VIDEO_PRE_CAPTURE_INDICATOR_CONTAINER_TOP);
   152     mIndicators = qobject_cast<HbWidget *>(widget);
   193     mIndicators = qobject_cast<HbWidget *>(widget);
   153     CX_DEBUG_ASSERT(mIndicators);
   194     CX_ASSERT_ALWAYS(mIndicators);
       
   195 
       
   196     QGraphicsLayout *layout = mIndicators->layout();
       
   197     QGraphicsLayoutItem *graphicsLayoutItem = NULL;
       
   198     QGraphicsItem *graphicsItem = NULL;
       
   199     QString key = "";
       
   200     int currentSettingValue = -1;
       
   201     bool isSettingOff = false;
       
   202     // Go through the items in the layout to check whether they should be
       
   203     // shown or not in the indicator pane. Start from the last towards
       
   204     // the first, so that removing items from between works correctly.
       
   205     for (int i = layout->count() - 1; i >= 0; i--) {
       
   206         graphicsLayoutItem = layout->itemAt(i);
       
   207         isSettingOff = false;
       
   208         if (graphicsLayoutItem) {
       
   209             graphicsItem = graphicsLayoutItem->graphicsItem();
       
   210             currentSettingValue = -1;
       
   211             if (graphicsItem == videoaudiomuteIndicatorIcon) {
       
   212                 key = CxeSettingIds::VIDEO_MUTE_SETTING;
       
   213                 currentSettingValue = mEngine->settings().get(key, currentSettingValue);
       
   214                 // video mute implementation does not use
       
   215                 // enum for on/off values but instead
       
   216                 // 0 for off and 1 for on.
       
   217                 if (currentSettingValue == 0) {
       
   218                     isSettingOff = true;
       
   219                 }
       
   220             } else if (graphicsItem == videoStabilityIndicatorIcon) {
       
   221                 // remove video stability indicator.
       
   222                 isSettingOff = true;
       
   223             }
       
   224             if (isSettingOff) {
       
   225                 layout->removeAt(i);
       
   226             }
       
   227         }
       
   228     }
       
   229 
   154     // Create background graphics for indicator container
   230     // Create background graphics for indicator container
   155     createWidgetBackgroundGraphic(mIndicators, TRANSPARENT_BACKGROUND_GRAPHIC);
   231     createWidgetBackgroundGraphic(mIndicators, TRANSPARENT_BACKGROUND_GRAPHIC);
   156 
   232 
   157     CX_DEBUG_EXIT_FUNCTION();
   233     mIndicators->setVisible(true);
   158 }
   234 
   159 
   235     CX_DEBUG_EXIT_FUNCTION();
       
   236 }
       
   237 
       
   238 /*!
       
   239  * Loads widgets that are not part of the default section in layouts xml.
       
   240  * Widgets are created at the time they are first loaded.
       
   241  */
   160 void CxuiVideoPrecaptureView::loadWidgets()
   242 void CxuiVideoPrecaptureView::loadWidgets()
   161 {
   243 {
   162     CX_DEBUG_ENTER_FUNCTION();
   244     CX_DEBUG_ENTER_FUNCTION();
   163     CX_DEBUG_ASSERT(mDocumentLoader);
   245     CX_ASSERT_ALWAYS(mDocumentLoader);
   164 
   246 
   165     if (mWidgetsLoaded) {
   247     if (mWidgetsLoaded) {
   166         CX_DEBUG(("Widgets already loaded"));
   248         CX_DEBUG(("Widgets already loaded"));
   167         CX_DEBUG_EXIT_FUNCTION();
   249         CX_DEBUG_EXIT_FUNCTION();
   168         return;
   250         return;
   174     // load the "secondary" widgets
   256     // load the "secondary" widgets
   175     bool ok = false;
   257     bool ok = false;
   176 
   258 
   177     // load widgets section (creates the widgets)
   259     // load widgets section (creates the widgets)
   178     mDocumentLoader->load(VIDEO_1ST_XML, VIDEO_PRE_CAPTURE_WIDGETS_SECTION, &ok);
   260     mDocumentLoader->load(VIDEO_1ST_XML, VIDEO_PRE_CAPTURE_WIDGETS_SECTION, &ok);
   179     Q_ASSERT_X(ok, "camerax ui", "error in xml file parsing");
   261     CX_ASSERT_ALWAYS(ok);
   180     if (CxuiServiceProvider::isCameraEmbedded()) {
   262     if (CxuiServiceProvider::isCameraEmbedded()) {
   181         mDocumentLoader->load(VIDEO_1ST_XML, VIDEO_PRE_CAPTURE_EMBEDDED_SECTION, &ok);
   263         mDocumentLoader->load(VIDEO_1ST_XML, VIDEO_PRE_CAPTURE_EMBEDDED_SECTION, &ok);
   182     } else {
   264     } else {
   183         mDocumentLoader->load(VIDEO_1ST_XML, VIDEO_PRE_CAPTURE_STANDALONE_SECTION, &ok);
   265         mDocumentLoader->load(VIDEO_1ST_XML, VIDEO_PRE_CAPTURE_STANDALONE_SECTION, &ok);
   184     }
   266     }
   185     Q_ASSERT_X(ok, "camerax ui", "error in xml file parsing");
   267     CX_ASSERT_ALWAYS(ok);
   186     // get needed pointers to some of the widgets
   268     // get needed pointers to some of the widgets
   187     widget = mDocumentLoader->findWidget(VIDEO_PRE_CAPTURE_ZOOM_SLIDER);
   269     widget = mDocumentLoader->findWidget(VIDEO_PRE_CAPTURE_ZOOM_SLIDER);
   188     mSlider = qobject_cast<CxuiZoomSlider *> (widget);
   270     mSlider = qobject_cast<CxuiZoomSlider *> (widget);
   189     CX_DEBUG_ASSERT(mSlider);
   271     CX_ASSERT_ALWAYS(mSlider);
   190 
   272 
   191     //Let's add a plus and minus buttons to the slider
   273     //Let's add a plus and minus buttons to the slider
   192     mSlider->addZoomButtons();
   274     mSlider->addZoomButtons();
   193     createWidgetBackgroundGraphic(mSlider, TRANSPARENT_BACKGROUND_GRAPHIC);
   275     createWidgetBackgroundGraphic(mSlider, TRANSPARENT_BACKGROUND_GRAPHIC);
   194 
   276 
   199     widget = mDocumentLoader->findWidget(VIDEO_PRE_CAPTURE_TOOLBAR_PAUSED);
   281     widget = mDocumentLoader->findWidget(VIDEO_PRE_CAPTURE_TOOLBAR_PAUSED);
   200     mToolbarPaused = qobject_cast<HbToolBar *> (widget);
   282     mToolbarPaused = qobject_cast<HbToolBar *> (widget);
   201 
   283 
   202     mToolbar = mToolbarIdle;
   284     mToolbar = mToolbarIdle;
   203 
   285 
   204     CX_DEBUG_ASSERT(mToolbarIdle);
   286     CX_ASSERT_ALWAYS(mToolbarIdle);
   205     CX_DEBUG_ASSERT(mToolbarRec);
   287     CX_ASSERT_ALWAYS(mToolbarRec);
   206     CX_DEBUG_ASSERT(mToolbarPaused);
   288     CX_ASSERT_ALWAYS(mToolbarPaused);
   207 
   289 
   208     hideControls();
   290     hideControls();
   209 
   291 
   210     if (CxuiServiceProvider::isCameraEmbedded()) {
   292     if (CxuiServiceProvider::isCameraEmbedded()) {
   211         CX_DEBUG(("EMBEDDED: camera in embedded mode"));
   293         CX_DEBUG(("EMBEDDED: camera in embedded mode"));
   238 
   320 
   239     // Create background graphic for indicator container
   321     // Create background graphic for indicator container
   240     HbWidget *indicatorContainer;
   322     HbWidget *indicatorContainer;
   241     widget = mDocumentLoader->findWidget(VIDEO_PRE_CAPTURE_INDICATOR_CONTAINER_BOTTOM);
   323     widget = mDocumentLoader->findWidget(VIDEO_PRE_CAPTURE_INDICATOR_CONTAINER_BOTTOM);
   242     indicatorContainer = qobject_cast<HbWidget *>(widget);
   324     indicatorContainer = qobject_cast<HbWidget *>(widget);
   243     CX_DEBUG_ASSERT(indicatorContainer);
   325     CX_ASSERT_ALWAYS(indicatorContainer);
   244     createWidgetBackgroundGraphic(indicatorContainer, TRANSPARENT_BACKGROUND_GRAPHIC);
   326     createWidgetBackgroundGraphic(indicatorContainer, TRANSPARENT_BACKGROUND_GRAPHIC);
   245 
   327 
   246     widget = mDocumentLoader->findWidget(VIDEO_PRE_CAPTURE_ELAPSED_TIME_LABEL);
   328     widget = mDocumentLoader->findWidget(VIDEO_PRE_CAPTURE_VIDEO_TIME_LABEL);
   247     mElapsedTimeText = qobject_cast<HbLabel *> (widget);
   329     mVideoTimeText = qobject_cast<HbLabel *> (widget);
   248     CX_DEBUG_ASSERT(mElapsedTimeText);
   330     CX_ASSERT_ALWAYS(mVideoTimeText);
   249 
       
   250     widget = mDocumentLoader->findWidget(VIDEO_PRE_CAPTURE_REMAINING_TIME_LABEL);
       
   251     mRemainingTimeText = qobject_cast<HbLabel *> (widget);
       
   252     CX_DEBUG_ASSERT(mRemainingTimeText);
       
   253 
   331 
   254     widget = mDocumentLoader->findWidget(VIDEO_PRE_CAPTURE_RECORDING_ICON);
   332     widget = mDocumentLoader->findWidget(VIDEO_PRE_CAPTURE_RECORDING_ICON);
   255     mRecordingIcon = qobject_cast<HbLabel *> (widget);
   333     mRecordingIcon = qobject_cast<HbLabel *> (widget);
   256     CX_DEBUG_ASSERT(mRecordingIcon);
   334     CX_ASSERT_ALWAYS(mRecordingIcon);
   257 
   335 
   258     mWidgetsLoaded = true;
   336     mWidgetsLoaded = true;
   259 
   337 
   260     // Initializing recording indicator animation
   338     // Initializing recording indicator animation
   261     mRecordingAnimation = new QPropertyAnimation(mRecordingIcon, "opacity");
   339     mRecordingAnimation = new QPropertyAnimation(mRecordingIcon, "opacity");
   266     mRecordingAnimation->setLoopCount(-1);
   344     mRecordingAnimation->setLoopCount(-1);
   267     mRecordingAnimation->setEasingCurve(QEasingCurve::OutInQuad);
   345     mRecordingAnimation->setEasingCurve(QEasingCurve::OutInQuad);
   268 
   346 
   269 
   347 
   270     // Update toolbar scene mode icon.
   348     // Update toolbar scene mode icon.
   271     QString sceneId;
   349     try {
   272     if (mEngine->settings().get(CxeSettingIds::SCENE_ID, sceneId) == CxeError::None) {
   350         updateSceneIcon(mEngine->settings().get<QString>(CxeSettingIds::VIDEO_SCENE));
   273         updateSceneIcon(sceneId);
   351     } catch (CxeException &e) {
       
   352         // ignore error
   274     }
   353     }
   275 
   354 
   276     // Initialize the video time counters.
   355     // Initialize the video time counters.
   277     updateTimeLabels();
   356     updateTimeLabels();
   278 
   357 
   343 
   422 
   344         connect(mCaptureKeyHandler, SIGNAL(autofocusKeyPressed()), mSettingsGrid, SLOT(close()));
   423         connect(mCaptureKeyHandler, SIGNAL(autofocusKeyPressed()), mSettingsGrid, SLOT(close()));
   345     }
   424     }
   346 }
   425 }
   347 
   426 
       
   427 
   348 /**
   428 /**
   349 * Get if postcapture view should be shown or not.
   429 * Get if postcapture view should be shown or not.
   350 * Postcapture view may be shown for a predefined time or
   430 * Postcapture view may be shown for a predefined time or
   351 * until user dismisses it, or it may be completely disabled.
   431 * until user dismisses it, or it may be completely disabled.
   352 */
   432 */
   359         return true;
   439         return true;
   360     }
   440     }
   361 
   441 
   362     // Read the value from settings. Ignoring reading error.
   442     // Read the value from settings. Ignoring reading error.
   363     // On error (missing settings) default to "postcapture on".
   443     // On error (missing settings) default to "postcapture on".
   364     int showPostcapture(-1);
   444     int showPostcapture(POSTCAPTURE_ON);
   365     if(mEngine) {
   445     if(mEngine) {
   366         mEngine->settings().get(CxeSettingIds::VIDEO_SHOWCAPTURED, showPostcapture);
   446         showPostcapture = mEngine->settings().get<int>(CxeSettingIds::VIDEO_SHOWCAPTURED, POSTCAPTURE_ON);
   367     }
   447     }
   368 
   448 
   369     CX_DEBUG_EXIT_FUNCTION();
   449     CX_DEBUG_EXIT_FUNCTION();
   370     return showPostcapture != 0; // 0 == no postcapture
   450     return showPostcapture != 0; // 0 == no postcapture
   371 }
   451 }
   389 
   469 
   390             CX_DEBUG(("CxuiVideoPrecaptureView - icon: %s", icon.toAscii().constData()));
   470             CX_DEBUG(("CxuiVideoPrecaptureView - icon: %s", icon.toAscii().constData()));
   391 
   471 
   392             if (mDocumentLoader) {
   472             if (mDocumentLoader) {
   393                 QObject *obj = mDocumentLoader->findObject(iconObjectName);
   473                 QObject *obj = mDocumentLoader->findObject(iconObjectName);
   394                 CX_DEBUG_ASSERT(obj);
   474                 CX_ASSERT_ALWAYS(obj);
   395                 qobject_cast<HbAction *>(obj)->setIcon(HbIcon(icon));
   475                 qobject_cast<HbAction *>(obj)->setIcon(HbIcon(icon));
   396             }
   476             }
   397         } else {
   477         } else {
   398             CX_DEBUG(("CxuiVideoPrecaptureView - widgets not loaded yet, ignored!"));
   478             CX_DEBUG(("CxuiVideoPrecaptureView - widgets not loaded yet, ignored!"));
   399         }
   479         }
   408 {
   488 {
   409     CX_DEBUG_ENTER_FUNCTION();
   489     CX_DEBUG_ENTER_FUNCTION();
   410 
   490 
   411     if (mQualityIcon && mEngine) {
   491     if (mQualityIcon && mEngine) {
   412         QString icon = "";
   492         QString icon = "";
   413         int currentValue = -1;
   493 
   414 
   494         int currentValue = mEngine->settings().get<int>(CxeSettingIds::VIDEO_QUALITY, -1);
   415         mEngine->settings().get(CxeSettingIds::VIDEO_QUALITY, currentValue);
       
   416         icon = getSettingItemIcon(CxeSettingIds::VIDEO_QUALITY, currentValue);
   495         icon = getSettingItemIcon(CxeSettingIds::VIDEO_QUALITY, currentValue);
   417 
   496 
   418         mQualityIcon->setIcon(HbIcon(icon));
   497         mQualityIcon->setIcon(HbIcon(icon));
   419     }
   498     }
   420 
       
   421     CX_DEBUG_EXIT_FUNCTION();
       
   422 }
       
   423 
       
   424 void CxuiVideoPrecaptureView::handleSnapshot(CxeError::Id /*error*/)
       
   425 {
       
   426     CX_DEBUG_ENTER_FUNCTION();
       
   427 
   499 
   428     CX_DEBUG_EXIT_FUNCTION();
   500     CX_DEBUG_EXIT_FUNCTION();
   429 }
   501 }
   430 
   502 
   431 void CxuiVideoPrecaptureView::record()
   503 void CxuiVideoPrecaptureView::record()
   434 
   506 
   435     int time(0);
   507     int time(0);
   436     mVideoCaptureControl->remainingTime(time);
   508     mVideoCaptureControl->remainingTime(time);
   437 
   509 
   438     if (time) {
   510     if (time) {
   439         mMenu = takeMenu();
   511         if (!mMenu){ // Only take out menu, if we have not already done it
       
   512             mMenu = takeMenu();
       
   513         }
   440         mVideoCaptureControl->record();
   514         mVideoCaptureControl->record();
   441     } else {
   515     } else {
   442         emit errorEncountered(CxeError::DiskFull);
   516         emit errorEncountered(CxeError::DiskFull);
   443     }
   517     }
   444 
   518 
   554 
   628 
   555 
   629 
   556 void CxuiVideoPrecaptureView::goToStill()
   630 void CxuiVideoPrecaptureView::goToStill()
   557 {
   631 {
   558     CX_DEBUG_ENTER_FUNCTION();
   632     CX_DEBUG_ENTER_FUNCTION();
   559     OstTrace0( camerax_performance, DUP1_CXUIVIDEOPRECAPTUREVIEW_GOTOSTILL, "msg: e_CX_GO_TO_STILL_MODE 1" );
   633     OstTrace0( camerax_performance, CXUIVIDEOPRECAPTUREVIEW_GOTOSTILL, "msg: e_CX_GO_TO_STILL_MODE 1" );
   560 
   634 
   561     hideControls();
   635     hideControls();
   562     mEngine->initMode(ImageMode);
   636     mEngine->initMode(ImageMode);
   563     emit changeToPrecaptureView();
   637     emit changeToPrecaptureView();
   564 
   638 
   565     OstTrace0( camerax_performance, DUP2_CXUIVIDEOPRECAPTUREVIEW_GOTOSTILL, "msg: e_CX_GO_TO_STILL_MODE 0" );
       
   566     CX_DEBUG_EXIT_FUNCTION();
   639     CX_DEBUG_EXIT_FUNCTION();
   567 }
   640 }
   568 
   641 
   569 /*!
   642 /*!
   570 * Update the remaining and elapsed time labels.
   643 * Update the remaining and elapsed time labels.
   571 */
   644 */
   572 void CxuiVideoPrecaptureView::updateTimeLabels()
   645 void CxuiVideoPrecaptureView::updateTimeLabels()
   573 {
   646 {
   574     CX_DEBUG_IN_FUNCTION();
   647     CX_DEBUG_IN_FUNCTION();
   575 
   648 
   576     if (!mRemainingTimeText || !mElapsedTimeText) {
   649     if (!mVideoTimeText) {
   577         // Section not loaded yet. Skip update until created.
   650         // Section not loaded yet. Skip update until created.
   578         CX_DEBUG(("CxuiVideoPrecaptureView: video time labels not loaded yet!"));
   651         CX_DEBUG(("CxuiVideoPrecaptureView: video time labels not loaded yet!"));
   579         CX_DEBUG_EXIT_FUNCTION();
   652         CX_DEBUG_EXIT_FUNCTION();
   580         return;
   653         return;
   581     }
   654     }
   604             mTimeRemaining = 0;
   677             mTimeRemaining = 0;
   605             mTimeElapsed = 0;
   678             mTimeElapsed = 0;
   606             break;
   679             break;
   607     }
   680     }
   608 
   681 
   609     setVideoTime(mRemainingTimeText, mTimeRemaining);
   682     setVideoTime(mVideoTimeText, mTimeElapsed, mTimeRemaining);
   610     setVideoTime(mElapsedTimeText, mTimeElapsed);
       
   611 
   683 
   612     CX_DEBUG_EXIT_FUNCTION();
   684     CX_DEBUG_EXIT_FUNCTION();
   613 }
   685 }
   614 
   686 
   615 /*!
   687 /*!
   628 }
   700 }
   629 
   701 
   630 /*!
   702 /*!
   631 * Helper method for formatting video time to requested label.
   703 * Helper method for formatting video time to requested label.
   632 * @param label Text label to show the time.
   704 * @param label Text label to show the time.
   633 * @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.
   634 */
   706 * @param remainingTime Remaining time in seconds to be formatted to the label text.
   635 void CxuiVideoPrecaptureView::setVideoTime(HbLabel* label, int time)
   707 */
       
   708 void CxuiVideoPrecaptureView::setVideoTime(HbLabel* label,
       
   709                                            int elapsedTime,
       
   710                                            int remainingTime)
   636 {
   711 {
   637     // Convert time (seconds) into mm:ss
   712     // Convert time (seconds) into mm:ss
   638     // HbExtendedLocale wraps minutes at 60 so we can't use that.
   713     // HbExtendedLocale wraps minutes at 60 so we can't use that.
   639     // 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".
   640     QString timeString;
   715     QString elapsed, remaining;
   641     timeString.sprintf(VIDEO_TIME_FORMAT, time/60, time%60);
   716     elapsed.sprintf(VIDEO_TIME_FORMAT, elapsedTime/60, elapsedTime%60);
   642     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));
   643 }
   720 }
   644 
   721 
   645 bool CxuiVideoPrecaptureView::getElapsedTime()
   722 bool CxuiVideoPrecaptureView::getElapsedTime()
   646 {
   723 {
   647     CX_DEBUG_ENTER_FUNCTION();
   724     CX_DEBUG_ENTER_FUNCTION();
   648 
   725 
   649     TBool status = mVideoCaptureControl->elapsedTime(mTimeElapsed);
   726     bool status = mVideoCaptureControl->elapsedTime(mTimeElapsed);
   650     CX_DEBUG(("Elapsed time: %d", mTimeElapsed));
   727     CX_DEBUG(("Elapsed time: %d", mTimeElapsed));
   651     CX_DEBUG(("status: %d", status));
   728     CX_DEBUG(("status: %d", status));
   652 
   729 
   653     CX_DEBUG_EXIT_FUNCTION();
   730     CX_DEBUG_EXIT_FUNCTION();
   654     return status;
   731     return status;
   703         hideControls();
   780         hideControls();
   704         emit stopStandbyTimer();
   781         emit stopStandbyTimer();
   705         if (mDocumentLoader){
   782         if (mDocumentLoader){
   706             mDocumentLoader->load(VIDEO_1ST_XML, VIDEO_PRE_CAPTURE_RECORDING);
   783             mDocumentLoader->load(VIDEO_1ST_XML, VIDEO_PRE_CAPTURE_RECORDING);
   707         }
   784         }
       
   785 
   708         mElapsedTimer.start(CXUI_ELAPSED_TIME_TIMEOUT);
   786         mElapsedTimer.start(CXUI_ELAPSED_TIME_TIMEOUT);
   709         disableFeedback();
   787         disableFeedback();
   710 
   788 
   711         // commented out the activation of the recording animation because
   789         // commented out the activation of the recording animation because
   712         // it is causing issues when using SW rendering
   790         // it is causing issues when using SW rendering
   756         break;
   834         break;
   757     case CxeVideoCaptureControl::PlayingStartSound:
   835     case CxeVideoCaptureControl::PlayingStartSound:
   758         // don't change anything
   836         // don't change anything
   759         break;
   837         break;
   760     default:
   838     default:
   761         // in any other state, just hide the controls
   839         // don't change anything
   762         setRecordingItemsVisibility(false);
       
   763         break;
   840         break;
   764     }
   841     }
   765 
   842 
   766     CX_DEBUG_EXIT_FUNCTION();
   843     CX_DEBUG_EXIT_FUNCTION();
   767 }
   844 }
   861             // update the quality indicator on screen
   938             // update the quality indicator on screen
   862             updateQualityIcon();
   939             updateQualityIcon();
   863 
   940 
   864             // update video remaining time counter when video quality is changed
   941             // update video remaining time counter when video quality is changed
   865             updateTimeLabels();
   942             updateTimeLabels();
       
   943         } else if (key == CxeSettingIds::GEOTAGGING) {
       
   944             reloadIndicatorWidgets();
       
   945         } else if (key == CxeSettingIds::VIDEO_MUTE_SETTING) {
       
   946             reloadIndicatorWidgets();
   866         }
   947         }
   867     }
   948     }
   868 
   949 
   869     CX_DEBUG_EXIT_FUNCTION();
   950     CX_DEBUG_EXIT_FUNCTION();
   870 }
   951 }
   871 
   952 
   872 /*!
   953 /*!
   873 * Handle scene mode change.
   954 * Handle scene mode change.
   874 * @param scene The new active scene mode.
   955 * @param scene The new active scene mode.
   875 */
   956 */
   876 void CxuiVideoPrecaptureView::handleSceneChanged(CxeScene &scene)
   957 void CxuiVideoPrecaptureView::handleSceneChanged(const QVariant &scene)
   877 {
   958 {
   878     CX_DEBUG_ENTER_FUNCTION();
   959     CX_DEBUG_ENTER_FUNCTION();
   879     // Ignore if not in video mode.
   960     // Ignore if not in video mode.
   880     if (mEngine->mode() == Cxe::VideoMode) {
   961     if (mEngine->mode() == Cxe::VideoMode) {
   881         // Update toolbar scene mode icon.
   962         // Update toolbar scene mode icon.
   882         updateSceneIcon(scene[CxeSettingIds::SCENE_ID].toString());
   963         updateSceneIcon(scene.toString());
   883     }
   964     }
   884 
   965 
   885     CX_DEBUG_EXIT_FUNCTION();
   966     CX_DEBUG_EXIT_FUNCTION();
   886 }
       
   887 
       
   888 
       
   889 
       
   890 /*!
       
   891     Sets the visibility of recording icon and elapsed time text.
       
   892     \param visible True if widgets are to be shown, false if not.
       
   893 */
       
   894 void CxuiVideoPrecaptureView::setRecordingItemsVisibility(bool visible) {
       
   895 
       
   896     if (mRecordingIcon) {
       
   897         mRecordingIcon->setVisible(visible);
       
   898         mRecordingIcon->setOpacity(1.0f);
       
   899     }
       
   900 
       
   901     if (mElapsedTimeText) {
       
   902         mElapsedTimeText->setVisible(visible);
       
   903     }
       
   904 }
   967 }
   905 
   968 
   906 /*!
   969 /*!
   907  * Overridden eventFilter() to restart the pause timer.
   970  * Overridden eventFilter() to restart the pause timer.
   908  */
   971  */