camerauis/cameraxui/cxui/src/cxuivideoprecaptureview.cpp
changeset 42 feebad15db8c
parent 41 67457b2ffb33
child 46 c826656d6714
equal deleted inserted replaced
41:67457b2ffb33 42:feebad15db8c
    16 */
    16 */
    17 
    17 
    18 #include <e32keys.h>
    18 #include <e32keys.h>
    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 
    48 #include "OstTraceDefinitions.h"
    51 #include "OstTraceDefinitions.h"
    49 #ifdef OST_TRACE_COMPILER_IN_USE
    52 #ifdef OST_TRACE_COMPILER_IN_USE
    50 #include "cxuivideoprecaptureviewTraces.h"
    53 #include "cxuivideoprecaptureviewTraces.h"
    51 #endif
    54 #endif
    52 #include "cxuiserviceprovider.h"
       
    53 
    55 
    54 
    56 
    55 using namespace Cxe;
    57 using namespace Cxe;
    56 using namespace CxUiLayout;
    58 using namespace CxUiLayout;
    57 using namespace CxUiInternal;
    59 using namespace CxUiInternal;
    93     mElapsedTimer.stop();
    95     mElapsedTimer.stop();
    94     delete mMenu;
    96     delete mMenu;
    95     CX_DEBUG_EXIT_FUNCTION();
    97     CX_DEBUG_EXIT_FUNCTION();
    96 }
    98 }
    97 
    99 
       
   100 /*!
       
   101  * Construct-method handles initialisation tasks for this class.
       
   102  * @param mainwindow
       
   103  * @param engine
       
   104  * @param documentLoader
       
   105  * @param keyHandler
       
   106  */
    98 void CxuiVideoPrecaptureView::construct(HbMainWindow *mainwindow, CxeEngine *engine,
   107 void CxuiVideoPrecaptureView::construct(HbMainWindow *mainwindow, CxeEngine *engine,
    99                                         CxuiDocumentLoader *documentLoader,
   108                                         CxuiDocumentLoader *documentLoader,
   100                                         CxuiCaptureKeyHandler *keyHandler,
   109                                         CxuiCaptureKeyHandler *keyHandler,
   101                                         HbActivityManager *activityManager)
   110                                         HbActivityManager *activityManager)
   102 {
   111 {
   131 
   140 
   132     CX_DEBUG_EXIT_FUNCTION();
   141     CX_DEBUG_EXIT_FUNCTION();
   133 
   142 
   134 }
   143 }
   135 
   144 
       
   145 /*!
       
   146  * Loads widgets that are needed right from the start.
       
   147  */
   136 void CxuiVideoPrecaptureView::loadDefaultWidgets()
   148 void CxuiVideoPrecaptureView::loadDefaultWidgets()
   137 {
   149 {
   138     CX_DEBUG_ENTER_FUNCTION();
   150     CX_DEBUG_ENTER_FUNCTION();
   139     CX_DEBUG_ASSERT(mDocumentLoader);
   151     CX_ASSERT_ALWAYS(mDocumentLoader);
   140 
   152 
   141     // get pointers to ui components from the layout data
   153     // get pointers to ui components from the layout data
   142     QGraphicsWidget *widget = NULL;
   154     QGraphicsWidget *widget = NULL;
   143     widget = mDocumentLoader->findWidget(VIDEO_PRE_CAPTURE_VIEWFINDER);
   155     widget = mDocumentLoader->findWidget(VIDEO_PRE_CAPTURE_VIEWFINDER);
   144     mViewfinder = qobject_cast<HbTransparentWindow *> (widget);
   156     mViewfinder = qobject_cast<HbTransparentWindow *> (widget);
   145     CX_DEBUG_ASSERT(mViewfinder);
   157     CX_ASSERT_ALWAYS(mViewfinder);
   146 
   158 
       
   159     reloadIndicatorWidgets();
       
   160 
       
   161     CX_DEBUG_EXIT_FUNCTION();
       
   162 }
       
   163 
       
   164 /*!
       
   165  * Loads default indicators from docml and modifies the visibility 
       
   166  * according to current settings.
       
   167  */
       
   168 void CxuiVideoPrecaptureView::reloadIndicatorWidgets()
       
   169 {
       
   170     CX_DEBUG_ENTER_FUNCTION();
       
   171     CX_ASSERT_ALWAYS(mDocumentLoader);
       
   172 
       
   173     bool ok = false;
       
   174     mDocumentLoader->load(VIDEO_1ST_XML, VIDEO_PRE_CAPTURE_INDICATORS_SECTION, &ok);
       
   175     CX_ASSERT_ALWAYS(ok);
       
   176 
       
   177     QGraphicsWidget *widget = NULL;
   147     widget = mDocumentLoader->findWidget(VIDEO_PRE_CAPTURE_QUALITY_ICON);
   178     widget = mDocumentLoader->findWidget(VIDEO_PRE_CAPTURE_QUALITY_ICON);
   148     mQualityIcon = qobject_cast<HbLabel *> (widget);
   179     mQualityIcon = qobject_cast<HbLabel *> (widget);
   149     CX_DEBUG_ASSERT(mQualityIcon);
   180     CX_ASSERT_ALWAYS(mQualityIcon);
       
   181 
       
   182     widget = mDocumentLoader->findWidget(VIDEO_PRE_CAPTURE_VIDEOAUDIOMUTE_INDICATOR_ICON);
       
   183     HbLabel *videoaudiomuteIndicatorIcon = qobject_cast<HbLabel *>(widget);
       
   184     CX_ASSERT_ALWAYS(videoaudiomuteIndicatorIcon);
       
   185 
       
   186     widget = mDocumentLoader->findWidget(VIDEO_PRE_CAPTURE_STABILITY_INDICATOR_ICON);
       
   187     HbLabel *videoStabilityIndicatorIcon = qobject_cast<HbLabel *>(widget);
       
   188     CX_ASSERT_ALWAYS(videoStabilityIndicatorIcon);
   150 
   189 
   151     widget = mDocumentLoader->findWidget(VIDEO_PRE_CAPTURE_INDICATOR_CONTAINER_TOP);
   190     widget = mDocumentLoader->findWidget(VIDEO_PRE_CAPTURE_INDICATOR_CONTAINER_TOP);
   152     mIndicators = qobject_cast<HbWidget *>(widget);
   191     mIndicators = qobject_cast<HbWidget *>(widget);
   153     CX_DEBUG_ASSERT(mIndicators);
   192     CX_ASSERT_ALWAYS(mIndicators);
       
   193 
       
   194     QGraphicsLayout *layout = mIndicators->layout();
       
   195     QGraphicsLayoutItem *graphicsLayoutItem = NULL;
       
   196     QGraphicsItem *graphicsItem = NULL;
       
   197     QString key = "";
       
   198     int currentSettingValue = -1;
       
   199     bool isSettingOff = false;
       
   200     // Go through the items in the layout to check whether they should be
       
   201     // shown or not in the indicator pane. Start from the last towards
       
   202     // the first, so that removing items from between works correctly.
       
   203     for (int i = layout->count() - 1; i >= 0; i--) {
       
   204         graphicsLayoutItem = layout->itemAt(i);
       
   205         isSettingOff = false;
       
   206         if (graphicsLayoutItem) {
       
   207             graphicsItem = graphicsLayoutItem->graphicsItem();
       
   208             currentSettingValue = -1;
       
   209             if (graphicsItem == videoaudiomuteIndicatorIcon) {
       
   210                 key = CxeSettingIds::VIDEO_MUTE_SETTING;
       
   211                 mEngine->settings().get(key, currentSettingValue);
       
   212                 // video mute implementation does not use 
       
   213                 // enum for on/off values but instead 
       
   214                 // 0 for off and 1 for on.
       
   215                 if (currentSettingValue == 0) {
       
   216                     isSettingOff = true;
       
   217                 }
       
   218             } else if (graphicsItem == videoStabilityIndicatorIcon) {
       
   219                 // remove video stability indicator.
       
   220                 isSettingOff = true;
       
   221             }
       
   222             if (isSettingOff) {
       
   223                 layout->removeAt(i);
       
   224             }
       
   225         }
       
   226     }
       
   227 
   154     // Create background graphics for indicator container
   228     // Create background graphics for indicator container
   155     createWidgetBackgroundGraphic(mIndicators, TRANSPARENT_BACKGROUND_GRAPHIC);
   229     createWidgetBackgroundGraphic(mIndicators, TRANSPARENT_BACKGROUND_GRAPHIC);
   156 
   230 
   157     CX_DEBUG_EXIT_FUNCTION();
   231     mIndicators->setVisible(true);
   158 }
   232 
   159 
   233     CX_DEBUG_EXIT_FUNCTION();
       
   234 }
       
   235 
       
   236 /*!
       
   237  * Loads widgets that are not part of the default section in layouts xml.
       
   238  * Widgets are created at the time they are first loaded.
       
   239  */
   160 void CxuiVideoPrecaptureView::loadWidgets()
   240 void CxuiVideoPrecaptureView::loadWidgets()
   161 {
   241 {
   162     CX_DEBUG_ENTER_FUNCTION();
   242     CX_DEBUG_ENTER_FUNCTION();
   163     CX_DEBUG_ASSERT(mDocumentLoader);
   243     CX_ASSERT_ALWAYS(mDocumentLoader);
   164 
   244 
   165     if (mWidgetsLoaded) {
   245     if (mWidgetsLoaded) {
   166         CX_DEBUG(("Widgets already loaded"));
   246         CX_DEBUG(("Widgets already loaded"));
   167         CX_DEBUG_EXIT_FUNCTION();
   247         CX_DEBUG_EXIT_FUNCTION();
   168         return;
   248         return;
   174     // load the "secondary" widgets
   254     // load the "secondary" widgets
   175     bool ok = false;
   255     bool ok = false;
   176 
   256 
   177     // load widgets section (creates the widgets)
   257     // load widgets section (creates the widgets)
   178     mDocumentLoader->load(VIDEO_1ST_XML, VIDEO_PRE_CAPTURE_WIDGETS_SECTION, &ok);
   258     mDocumentLoader->load(VIDEO_1ST_XML, VIDEO_PRE_CAPTURE_WIDGETS_SECTION, &ok);
   179     Q_ASSERT_X(ok, "camerax ui", "error in xml file parsing");
   259     CX_ASSERT_ALWAYS(ok);
   180     if (CxuiServiceProvider::isCameraEmbedded()) {
   260     if (CxuiServiceProvider::isCameraEmbedded()) {
   181         mDocumentLoader->load(VIDEO_1ST_XML, VIDEO_PRE_CAPTURE_EMBEDDED_SECTION, &ok);
   261         mDocumentLoader->load(VIDEO_1ST_XML, VIDEO_PRE_CAPTURE_EMBEDDED_SECTION, &ok);
   182     } else {
   262     } else {
   183         mDocumentLoader->load(VIDEO_1ST_XML, VIDEO_PRE_CAPTURE_STANDALONE_SECTION, &ok);
   263         mDocumentLoader->load(VIDEO_1ST_XML, VIDEO_PRE_CAPTURE_STANDALONE_SECTION, &ok);
   184     }
   264     }
   185     Q_ASSERT_X(ok, "camerax ui", "error in xml file parsing");
   265     CX_ASSERT_ALWAYS(ok);
   186     // get needed pointers to some of the widgets
   266     // get needed pointers to some of the widgets
   187     widget = mDocumentLoader->findWidget(VIDEO_PRE_CAPTURE_ZOOM_SLIDER);
   267     widget = mDocumentLoader->findWidget(VIDEO_PRE_CAPTURE_ZOOM_SLIDER);
   188     mSlider = qobject_cast<CxuiZoomSlider *> (widget);
   268     mSlider = qobject_cast<CxuiZoomSlider *> (widget);
   189     CX_DEBUG_ASSERT(mSlider);
   269     CX_ASSERT_ALWAYS(mSlider);
   190 
   270 
   191     //Let's add a plus and minus buttons to the slider
   271     //Let's add a plus and minus buttons to the slider
   192     mSlider->addZoomButtons();
   272     mSlider->addZoomButtons();
   193     createWidgetBackgroundGraphic(mSlider, TRANSPARENT_BACKGROUND_GRAPHIC);
   273     createWidgetBackgroundGraphic(mSlider, TRANSPARENT_BACKGROUND_GRAPHIC);
   194 
   274 
   199     widget = mDocumentLoader->findWidget(VIDEO_PRE_CAPTURE_TOOLBAR_PAUSED);
   279     widget = mDocumentLoader->findWidget(VIDEO_PRE_CAPTURE_TOOLBAR_PAUSED);
   200     mToolbarPaused = qobject_cast<HbToolBar *> (widget);
   280     mToolbarPaused = qobject_cast<HbToolBar *> (widget);
   201 
   281 
   202     mToolbar = mToolbarIdle;
   282     mToolbar = mToolbarIdle;
   203 
   283 
   204     CX_DEBUG_ASSERT(mToolbarIdle);
   284     CX_ASSERT_ALWAYS(mToolbarIdle);
   205     CX_DEBUG_ASSERT(mToolbarRec);
   285     CX_ASSERT_ALWAYS(mToolbarRec);
   206     CX_DEBUG_ASSERT(mToolbarPaused);
   286     CX_ASSERT_ALWAYS(mToolbarPaused);
   207 
   287 
   208     hideControls();
   288     hideControls();
   209 
   289 
   210     if (CxuiServiceProvider::isCameraEmbedded()) {
   290     if (CxuiServiceProvider::isCameraEmbedded()) {
   211         CX_DEBUG(("EMBEDDED: camera in embedded mode"));
   291         CX_DEBUG(("EMBEDDED: camera in embedded mode"));
   238 
   318 
   239     // Create background graphic for indicator container
   319     // Create background graphic for indicator container
   240     HbWidget *indicatorContainer;
   320     HbWidget *indicatorContainer;
   241     widget = mDocumentLoader->findWidget(VIDEO_PRE_CAPTURE_INDICATOR_CONTAINER_BOTTOM);
   321     widget = mDocumentLoader->findWidget(VIDEO_PRE_CAPTURE_INDICATOR_CONTAINER_BOTTOM);
   242     indicatorContainer = qobject_cast<HbWidget *>(widget);
   322     indicatorContainer = qobject_cast<HbWidget *>(widget);
   243     CX_DEBUG_ASSERT(indicatorContainer);
   323     CX_ASSERT_ALWAYS(indicatorContainer);
   244     createWidgetBackgroundGraphic(indicatorContainer, TRANSPARENT_BACKGROUND_GRAPHIC);
   324     createWidgetBackgroundGraphic(indicatorContainer, TRANSPARENT_BACKGROUND_GRAPHIC);
   245 
   325 
   246     widget = mDocumentLoader->findWidget(VIDEO_PRE_CAPTURE_ELAPSED_TIME_LABEL);
   326     widget = mDocumentLoader->findWidget(VIDEO_PRE_CAPTURE_ELAPSED_TIME_LABEL);
   247     mElapsedTimeText = qobject_cast<HbLabel *> (widget);
   327     mElapsedTimeText = qobject_cast<HbLabel *> (widget);
   248     CX_DEBUG_ASSERT(mElapsedTimeText);
   328     CX_ASSERT_ALWAYS(mElapsedTimeText);
   249 
   329 
   250     widget = mDocumentLoader->findWidget(VIDEO_PRE_CAPTURE_REMAINING_TIME_LABEL);
   330     widget = mDocumentLoader->findWidget(VIDEO_PRE_CAPTURE_REMAINING_TIME_LABEL);
   251     mRemainingTimeText = qobject_cast<HbLabel *> (widget);
   331     mRemainingTimeText = qobject_cast<HbLabel *> (widget);
   252     CX_DEBUG_ASSERT(mRemainingTimeText);
   332     CX_ASSERT_ALWAYS(mRemainingTimeText);
   253 
   333 
   254     widget = mDocumentLoader->findWidget(VIDEO_PRE_CAPTURE_RECORDING_ICON);
   334     widget = mDocumentLoader->findWidget(VIDEO_PRE_CAPTURE_RECORDING_ICON);
   255     mRecordingIcon = qobject_cast<HbLabel *> (widget);
   335     mRecordingIcon = qobject_cast<HbLabel *> (widget);
   256     CX_DEBUG_ASSERT(mRecordingIcon);
   336     CX_ASSERT_ALWAYS(mRecordingIcon);
   257 
   337 
   258     mWidgetsLoaded = true;
   338     mWidgetsLoaded = true;
   259 
   339 
   260     // Initializing recording indicator animation
   340     // Initializing recording indicator animation
   261     mRecordingAnimation = new QPropertyAnimation(mRecordingIcon, "opacity");
   341     mRecordingAnimation = new QPropertyAnimation(mRecordingIcon, "opacity");
   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         }
   554 
   634 
   555 
   635 
   556 void CxuiVideoPrecaptureView::goToStill()
   636 void CxuiVideoPrecaptureView::goToStill()
   557 {
   637 {
   558     CX_DEBUG_ENTER_FUNCTION();
   638     CX_DEBUG_ENTER_FUNCTION();
   559     OstTrace0( camerax_performance, DUP1_CXUIVIDEOPRECAPTUREVIEW_GOTOSTILL, "msg: e_CX_GO_TO_STILL_MODE 1" );
   639     OstTrace0( camerax_performance, CXUIVIDEOPRECAPTUREVIEW_GOTOSTILL, "msg: e_CX_GO_TO_STILL_MODE 1" );
   560 
   640 
   561     hideControls();
   641     hideControls();
   562     mEngine->initMode(ImageMode);
   642     mEngine->initMode(ImageMode);
   563     emit changeToPrecaptureView();
   643     emit changeToPrecaptureView();
   564 
   644 
   565     OstTrace0( camerax_performance, DUP2_CXUIVIDEOPRECAPTUREVIEW_GOTOSTILL, "msg: e_CX_GO_TO_STILL_MODE 0" );
       
   566     CX_DEBUG_EXIT_FUNCTION();
   645     CX_DEBUG_EXIT_FUNCTION();
   567 }
   646 }
   568 
   647 
   569 /*!
   648 /*!
   570 * Update the remaining and elapsed time labels.
   649 * Update the remaining and elapsed time labels.
   644 
   723 
   645 bool CxuiVideoPrecaptureView::getElapsedTime()
   724 bool CxuiVideoPrecaptureView::getElapsedTime()
   646 {
   725 {
   647     CX_DEBUG_ENTER_FUNCTION();
   726     CX_DEBUG_ENTER_FUNCTION();
   648 
   727 
   649     TBool status = mVideoCaptureControl->elapsedTime(mTimeElapsed);
   728     bool status = mVideoCaptureControl->elapsedTime(mTimeElapsed);
   650     CX_DEBUG(("Elapsed time: %d", mTimeElapsed));
   729     CX_DEBUG(("Elapsed time: %d", mTimeElapsed));
   651     CX_DEBUG(("status: %d", status));
   730     CX_DEBUG(("status: %d", status));
   652 
   731 
   653     CX_DEBUG_EXIT_FUNCTION();
   732     CX_DEBUG_EXIT_FUNCTION();
   654     return status;
   733     return status;
   861             // update the quality indicator on screen
   940             // update the quality indicator on screen
   862             updateQualityIcon();
   941             updateQualityIcon();
   863 
   942 
   864             // update video remaining time counter when video quality is changed
   943             // update video remaining time counter when video quality is changed
   865             updateTimeLabels();
   944             updateTimeLabels();
       
   945         } else if (key == CxeSettingIds::GEOTAGGING) {
       
   946             reloadIndicatorWidgets();
       
   947         } else if (key == CxeSettingIds::VIDEO_MUTE_SETTING) {
       
   948             reloadIndicatorWidgets();
   866         }
   949         }
   867     }
   950     }
   868 
   951 
   869     CX_DEBUG_EXIT_FUNCTION();
   952     CX_DEBUG_EXIT_FUNCTION();
   870 }
   953 }