camerauis/cameraxui/cxui/src/cxuistillprecaptureview.cpp
changeset 48 42ba2d16bf40
parent 37 64817133cd1d
child 56 01e205c615b9
equal deleted inserted replaced
37:64817133cd1d 48:42ba2d16bf40
    12 * Contributors:
    12 * Contributors:
    13 *
    13 *
    14 * Description:
    14 * Description:
    15 *
    15 *
    16 */
    16 */
       
    17 #include <QVariant>
       
    18 #include <QMetaType>
       
    19 #include <QGraphicsLayout>
       
    20 
    17 #include <hbpushbutton.h>
    21 #include <hbpushbutton.h>
    18 #include <hblabel.h>
    22 #include <hblabel.h>
    19 #include <hbtoolbar.h>
    23 #include <hbtoolbar.h>
    20 #include <hbaction.h>
    24 #include <hbaction.h>
    21 #include <hbmainwindow.h>
    25 #include <hbmainwindow.h>
    22 #include <hbtransparentwindow.h>
    26 #include <hbtransparentwindow.h>
    23 #include <QVariant>
       
    24 #include <QMetaType>
       
    25 #include <hbslider.h>
    27 #include <hbslider.h>
    26 #include <hblistwidget.h>
    28 #include <hblistwidget.h>
    27 #include <hbdialog.h>
    29 #include <hbdialog.h>
    28 #include <hblistwidgetitem.h>
    30 #include <hblistwidgetitem.h>
    29 #include <hbtoolbarextension.h>
    31 #include <hbtoolbarextension.h>
    44 #include "cxenamespace.h" // CxeSettingIds
    46 #include "cxenamespace.h" // CxeSettingIds
    45 #include "cxuienums.h"
    47 #include "cxuienums.h"
    46 #include "cxesettings.h"
    48 #include "cxesettings.h"
    47 #include "cxefeaturemanager.h" // mEngine->featureManager()
    49 #include "cxefeaturemanager.h" // mEngine->featureManager()
    48 #include "cxuidocumentloader.h"
    50 #include "cxuidocumentloader.h"
       
    51 
       
    52 #ifdef Q_OS_SYMBIAN
    49 #include "OstTraceDefinitions.h"
    53 #include "OstTraceDefinitions.h"
       
    54 
    50 #ifdef OST_TRACE_COMPILER_IN_USE
    55 #ifdef OST_TRACE_COMPILER_IN_USE
    51 #include "cxuistillprecaptureviewTraces.h"
    56 #include "cxuistillprecaptureviewTraces.h"
    52 #endif
    57 #endif
       
    58 
       
    59 #endif //Q_OS_SYMBIAN
       
    60 
    53 #include "cxuistillprecaptureview.h"
    61 #include "cxuistillprecaptureview.h"
    54 #include "cxuiserviceprovider.h"
    62 #include "cxuiserviceprovider.h"
    55 #include "cxuisettingdialog.h"
    63 #include "cxuisettingdialog.h"
    56 #include "cxuisettingradiobuttonlist.h"
    64 #include "cxuisettingradiobuttonlist.h"
    57 #include "cxuizoomslider.h"
    65 #include "cxuizoomslider.h"
   108             this, SLOT(handleSnapshot(CxeError::Id)));
   116             this, SLOT(handleSnapshot(CxeError::Id)));
   109     connect(&mEngine->stillCaptureControl(), SIGNAL(stateChanged(CxeStillCaptureControl::State, CxeError::Id)),
   117     connect(&mEngine->stillCaptureControl(), SIGNAL(stateChanged(CxeStillCaptureControl::State, CxeError::Id)),
   110             this, SLOT(handleStillCaptureStateChanged(CxeStillCaptureControl::State, CxeError::Id)));
   118             this, SLOT(handleStillCaptureStateChanged(CxeStillCaptureControl::State, CxeError::Id)));
   111     connect(&mEngine->viewfinderControl(), SIGNAL(stateChanged(CxeViewfinderControl::State, CxeError::Id)),
   119     connect(&mEngine->viewfinderControl(), SIGNAL(stateChanged(CxeViewfinderControl::State, CxeError::Id)),
   112             this, SLOT(handleViewfinderStateChanged(CxeViewfinderControl::State, CxeError::Id)));
   120             this, SLOT(handleViewfinderStateChanged(CxeViewfinderControl::State, CxeError::Id)));
   113     connect(&(mEngine->settings()), SIGNAL(sceneChanged(CxeScene&)),
       
   114             this, SLOT(handleSceneChanged(CxeScene&)));
       
   115     connect(&mEngine->stillCaptureControl(), SIGNAL(availableImagesChanged()),
   121     connect(&mEngine->stillCaptureControl(), SIGNAL(availableImagesChanged()),
   116             this, SLOT(updateImagesLeftLabel()));
   122             this, SLOT(updateImagesLeftLabel()));
   117 
   123 
       
   124     mEngine->settings().listenForSetting(CxeSettingIds::IMAGE_SCENE_DATA, this, SLOT(handleSceneChanged(const QVariant&)));
       
   125 
   118     loadDefaultWidgets();
   126     loadDefaultWidgets();
   119     hideControls();
   127     hideControls();
   120 
       
   121     mSelfTimer = new CxuiSelfTimer(mEngine->settings());
       
   122     connect(mSelfTimer, SIGNAL(timerFinished()), this, SLOT(focusAndCapture()));
       
   123 
       
   124     int value = Cxe::GeoTaggingDisclaimerDisabled;
       
   125     mEngine->settings().get(CxeSettingIds::GEOTAGGING_DISCLAIMER, value);
       
   126     if(value == Cxe::GeoTaggingDisclaimerEnabled) {
       
   127         launchGeoTaggingDisclaimerDialog();
       
   128     }
       
   129 
   128 
   130     OstTrace0( camerax_performance, DUP1_CXUISTILLPRECAPTUREVIEW_CONSTRUCT, "msg: e_CX_STILLPRECAPVIEW_CONSTRUCT 0" );
   129     OstTrace0( camerax_performance, DUP1_CXUISTILLPRECAPTUREVIEW_CONSTRUCT, "msg: e_CX_STILLPRECAPVIEW_CONSTRUCT 0" );
   131     CX_DEBUG_EXIT_FUNCTION();
   130     CX_DEBUG_EXIT_FUNCTION();
   132 }
   131 }
   133 
   132 
   135  * Loads default widgets in layouts xml.
   134  * Loads default widgets in layouts xml.
   136  */
   135  */
   137 void CxuiStillPrecaptureView::loadDefaultWidgets()
   136 void CxuiStillPrecaptureView::loadDefaultWidgets()
   138 {
   137 {
   139     CX_DEBUG_ENTER_FUNCTION();
   138     CX_DEBUG_ENTER_FUNCTION();
   140     CX_DEBUG_ASSERT(mDocumentLoader);
   139     CX_ASSERT_ALWAYS(mDocumentLoader);
   141 
   140 
   142     // get pointer to the viewfinder
   141     // get pointer to the viewfinder
   143     QGraphicsWidget *widget = NULL;
   142     QGraphicsWidget *widget = NULL;
   144     widget = mDocumentLoader->findWidget(STILL_PRE_CAPTURE_VIEWFINDER);
   143     widget = mDocumentLoader->findWidget(STILL_PRE_CAPTURE_VIEWFINDER);
   145     mViewfinder = qobject_cast<HbTransparentWindow *>(widget);
   144     mViewfinder = qobject_cast<HbTransparentWindow *>(widget);
   146     CX_DEBUG_ASSERT(mViewfinder);
   145     CX_ASSERT_ALWAYS(mViewfinder);
   147 
   146 
       
   147     reloadIndicatorWidgets();
       
   148     CX_DEBUG_EXIT_FUNCTION();
       
   149 }
       
   150 
       
   151 /*!
       
   152  * Loads default indicators from docml and modifies the visibility
       
   153  * according to current settings.
       
   154  */
       
   155 void CxuiStillPrecaptureView::reloadIndicatorWidgets()
       
   156 {
       
   157     CX_DEBUG_ENTER_FUNCTION();
       
   158     CX_ASSERT_ALWAYS(mDocumentLoader);
       
   159 
       
   160     bool ok = false;
       
   161     mDocumentLoader->load(STILL_1ST_XML, STILL_PRE_CAPTURE_INDICATORS_SECTION, &ok);
       
   162     CX_ASSERT_ALWAYS(ok);
       
   163 
       
   164     QGraphicsWidget *widget = NULL;
   148     widget = mDocumentLoader->findWidget(STILL_PRE_CAPTURE_QUALITY_ICON);
   165     widget = mDocumentLoader->findWidget(STILL_PRE_CAPTURE_QUALITY_ICON);
   149     mQualityIcon = qobject_cast<HbLabel *>(widget);
   166     mQualityIcon = qobject_cast<HbLabel *>(widget);
   150     CX_DEBUG_ASSERT(mQualityIcon);
   167     CX_ASSERT_ALWAYS(mQualityIcon);
       
   168 
       
   169     widget = mDocumentLoader->findWidget(STILL_PRE_CAPTURE_FLASHBLINK_INDICATOR_ICON);
       
   170     HbLabel *flashBlinkingIcon = qobject_cast<HbLabel *>(widget);
       
   171     CX_ASSERT_ALWAYS(flashBlinkingIcon);
   151 
   172 
   152     widget = mDocumentLoader->findWidget(STILL_PRE_CAPTURE_GEOTAGGING_INDICATOR_ICON);
   173     widget = mDocumentLoader->findWidget(STILL_PRE_CAPTURE_GEOTAGGING_INDICATOR_ICON);
   153     mGeoTaggingIndicatorIcon = qobject_cast<HbLabel *>(widget);
   174     mGeoTaggingIndicatorIcon = qobject_cast<HbLabel *>(widget);
   154     CX_DEBUG_ASSERT(mGeoTaggingIndicatorIcon);
   175     CX_ASSERT_ALWAYS(mGeoTaggingIndicatorIcon);
   155 
   176 
   156     widget = mDocumentLoader->findWidget(STILL_PRE_CAPTURE_FACE_TRACKING_ICON);
   177     widget = mDocumentLoader->findWidget(STILL_PRE_CAPTURE_FACE_TRACKING_ICON);
   157     mFaceTrackingIcon = qobject_cast<HbLabel *>(widget);
   178     mFaceTrackingIcon = qobject_cast<HbLabel *>(widget);
   158     CX_DEBUG_ASSERT(mFaceTrackingIcon);
   179     CX_ASSERT_ALWAYS(mFaceTrackingIcon);
   159 
   180 
   160     widget = mDocumentLoader->findWidget(STILL_PRE_CAPTURE_INDICATOR_CONTAINER);
   181     widget = mDocumentLoader->findWidget(STILL_PRE_CAPTURE_INDICATOR_CONTAINER);
   161     mIndicators = qobject_cast<HbWidget *>(widget);
   182     mIndicators = qobject_cast<HbWidget *>(widget);
   162     CX_DEBUG_ASSERT(mIndicators);
   183     CX_ASSERT_ALWAYS(mIndicators);
       
   184 
       
   185     QGraphicsLayout *layout = mIndicators->layout();
       
   186     QGraphicsLayoutItem *graphicsLayoutItem = NULL;
       
   187     QGraphicsItem *graphicsItem = NULL;
       
   188     QString key = "";
       
   189     int currentSettingValue = -1;
       
   190     bool isSettingOff = false;
       
   191     // Go through the items in the layout to check whether they should be
       
   192     // shown or not in the indicator pane. Start from the last towards
       
   193     // the first, so that removing items from between works correctly.
       
   194     for (int i = layout->count() - 1; i >= 0; i--) {
       
   195         graphicsLayoutItem = layout->itemAt(i);
       
   196         isSettingOff = false;
       
   197         if (graphicsLayoutItem) {
       
   198             graphicsItem = graphicsLayoutItem->graphicsItem();
       
   199             currentSettingValue = -1;
       
   200             if (graphicsItem == mGeoTaggingIndicatorIcon) {
       
   201                 key = CxeSettingIds::GEOTAGGING;
       
   202                 currentSettingValue = mEngine->settings().get(key, currentSettingValue);
       
   203                 if (currentSettingValue == Cxe::GeoTaggingOff) {
       
   204                     isSettingOff = true;
       
   205                 }
       
   206             } else if (graphicsItem == mFaceTrackingIcon) {
       
   207                 key = CxeSettingIds::FACE_TRACKING;
       
   208                 currentSettingValue = mEngine->settings().get(key, currentSettingValue);
       
   209                 // facetracking implementation does not use
       
   210                 // enum for on/off values but instead
       
   211                 // 0 for off and 1 for on.
       
   212                 if (currentSettingValue == 0) {
       
   213                     isSettingOff = true;
       
   214                 }
       
   215             } else if (graphicsItem == flashBlinkingIcon) {
       
   216                 //remove flash indicator
       
   217                 isSettingOff = true;
       
   218             }
       
   219             if (isSettingOff) {
       
   220                 layout->removeAt(i);
       
   221             }
       
   222         }
       
   223     }
       
   224 
   163     // create background for indicator container
   225     // create background for indicator container
   164     createWidgetBackgroundGraphic(mIndicators, TRANSPARENT_BACKGROUND_GRAPHIC);
   226     createWidgetBackgroundGraphic(mIndicators, TRANSPARENT_BACKGROUND_GRAPHIC);
       
   227 
       
   228     mIndicators->setVisible(true);
   165 
   229 
   166     CX_DEBUG_EXIT_FUNCTION();
   230     CX_DEBUG_EXIT_FUNCTION();
   167 }
   231 }
   168 
   232 
   169 /*!
   233 /*!
   171  * Widgets are created at the time they are first loaded.
   235  * Widgets are created at the time they are first loaded.
   172  */
   236  */
   173 void CxuiStillPrecaptureView::loadWidgets()
   237 void CxuiStillPrecaptureView::loadWidgets()
   174 {
   238 {
   175     CX_DEBUG_ENTER_FUNCTION();
   239     CX_DEBUG_ENTER_FUNCTION();
   176     CX_DEBUG_ASSERT(mDocumentLoader);
   240     CX_ASSERT_ALWAYS(mDocumentLoader);
   177 
   241 
   178     if( mWidgetsLoaded ) {
   242     if (mWidgetsLoaded) {
   179         CX_DEBUG(("Widgets already loaded"));
   243         CX_DEBUG(("Widgets already loaded"));
   180         CX_DEBUG_EXIT_FUNCTION();
   244         CX_DEBUG_EXIT_FUNCTION();
   181         return;
   245         return;
   182     }
   246     }
   183 
   247 
   185 
   249 
   186     bool ok = false;
   250     bool ok = false;
   187 
   251 
   188     OstTrace0( camerax_performance, DUP4_CXUISTILLPRECAPTUREVIEW_LOADWIDGETS, "msg: e_CX_DOCUMENTLOADER_LOAD 1" );
   252     OstTrace0( camerax_performance, DUP4_CXUISTILLPRECAPTUREVIEW_LOADWIDGETS, "msg: e_CX_DOCUMENTLOADER_LOAD 1" );
   189     mDocumentLoader->load(STILL_1ST_XML, STILL_PRE_CAPTURE_WIDGETS_SECTION, &ok);
   253     mDocumentLoader->load(STILL_1ST_XML, STILL_PRE_CAPTURE_WIDGETS_SECTION, &ok);
   190     Q_ASSERT_X(ok, "camerax ui", "error in xml file parsing");
   254     CX_ASSERT_ALWAYS(ok);
   191     if (CxuiServiceProvider::isCameraEmbedded()) {
   255     if (CxuiServiceProvider::isCameraEmbedded()) {
   192         mDocumentLoader->load(STILL_1ST_XML, STILL_PRE_CAPTURE_EMBEDDED_SECTION, &ok);
   256         mDocumentLoader->load(STILL_1ST_XML, STILL_PRE_CAPTURE_EMBEDDED_SECTION, &ok);
   193     } else {
   257     } else {
   194         mDocumentLoader->load(STILL_1ST_XML, STILL_PRE_CAPTURE_STANDALONE_SECTION, &ok);
   258         mDocumentLoader->load(STILL_1ST_XML, STILL_PRE_CAPTURE_STANDALONE_SECTION, &ok);
   195     }
   259     }
   196     OstTrace0( camerax_performance, DUP5_CXUISTILLPRECAPTUREVIEW_LOADWIDGETS, "msg: e_CX_DOCUMENTLOADER_LOAD 0" );
   260     OstTrace0( camerax_performance, DUP5_CXUISTILLPRECAPTUREVIEW_LOADWIDGETS, "msg: e_CX_DOCUMENTLOADER_LOAD 0" );
   197     Q_ASSERT_X(ok, "camerax ui", "error in xml file parsing");
   261     CX_ASSERT_ALWAYS(ok);
   198 
   262 
   199     // get pointers to ui components from the layout data
   263     // get pointers to ui components from the layout data
   200     QGraphicsWidget *widget = NULL;
   264     QGraphicsWidget *widget = NULL;
   201     QObject *object = NULL;
   265     QObject *object = NULL;
   202 
   266 
   203     widget = mDocumentLoader->findWidget(STILL_PRE_CAPTURE_ZOOM_SLIDER);
   267     widget = mDocumentLoader->findWidget(STILL_PRE_CAPTURE_ZOOM_SLIDER);
   204     mSlider = qobject_cast<CxuiZoomSlider *>(widget);
   268     mSlider = qobject_cast<CxuiZoomSlider *>(widget);
   205     CX_DEBUG_ASSERT(mSlider);
   269     CX_ASSERT_ALWAYS(mSlider);
   206     mSlider->addZoomButtons();
   270     mSlider->addZoomButtons();
   207     createWidgetBackgroundGraphic(mSlider, TRANSPARENT_BACKGROUND_GRAPHIC);
   271     createWidgetBackgroundGraphic(mSlider, TRANSPARENT_BACKGROUND_GRAPHIC);
   208 
       
   209     if (mSelfTimer) {
       
   210         // let selftimer class get needed selftimer related widgets
       
   211         // from the documentloader
       
   212         mSelfTimer->loadSelftimerWidgets(mDocumentLoader);
       
   213     }
       
   214 
   272 
   215     // create background for selftimer containers
   273     // create background for selftimer containers
   216     HbWidget *container = NULL;
   274     HbWidget *container = NULL;
   217     widget = mDocumentLoader->findWidget(STILL_PRE_CAPTURE_SELFTIMER_CONTAINER);
   275     widget = mDocumentLoader->findWidget(STILL_PRE_CAPTURE_SELFTIMER_CONTAINER);
   218     container = qobject_cast<HbWidget *>(widget);
   276     container = qobject_cast<HbWidget *>(widget);
   219     CX_DEBUG_ASSERT(container);
   277     CX_ASSERT_ALWAYS(container);
   220     createWidgetBackgroundGraphic(container, TRANSPARENT_BACKGROUND_GRAPHIC);
   278     createWidgetBackgroundGraphic(container, TRANSPARENT_BACKGROUND_GRAPHIC);
   221 
   279 
   222     // connect selftimer start button to hide controls
   280     // connect selftimer start button to hide controls
   223     widget = mDocumentLoader->findWidget(STILL_PRE_CAPTURE_SELFTIMER_START_BUTTON);
   281     widget = mDocumentLoader->findWidget(STILL_PRE_CAPTURE_SELFTIMER_START_BUTTON);
   224     HbPushButton *startButton = qobject_cast<HbPushButton *>(widget);
   282     HbPushButton *startButton = qobject_cast<HbPushButton *>(widget);
   225     CX_DEBUG_ASSERT(startButton);
   283     CX_ASSERT_ALWAYS(startButton);
   226     connect(startButton, SIGNAL(released()), this, SLOT(hideControls()));
   284     connect(startButton, SIGNAL(released()), this, SLOT(hideControls()));
   227 
   285 
   228     widget = mDocumentLoader->findWidget(STILL_PRE_CAPTURE_TOOLBAR);
   286     widget = mDocumentLoader->findWidget(STILL_PRE_CAPTURE_TOOLBAR);
   229     mToolbar = qobject_cast<HbToolBar *>(widget);
   287     mToolbar = qobject_cast<HbToolBar *>(widget);
   230     CX_DEBUG_ASSERT(mToolbar);
   288     CX_ASSERT_ALWAYS(mToolbar);
   231 
   289 
   232     object = mDocumentLoader->findObject(STILL_PRE_CAPTURE_FLASH_ACTION);
   290     object = mDocumentLoader->findObject(STILL_PRE_CAPTURE_FLASH_ACTION);
   233     mFlashSetting = qobject_cast<HbAction *>(object);
   291     mFlashSetting = qobject_cast<HbAction *>(object);
   234     CX_DEBUG_ASSERT(mFlashSetting);
   292     CX_ASSERT_ALWAYS(mFlashSetting);
   235 
   293 
   236     widget = mDocumentLoader->findWidget(STILL_PRE_CAPTURE_IMAGES_LEFT_LABEL);
   294     widget = mDocumentLoader->findWidget(STILL_PRE_CAPTURE_IMAGES_LEFT_LABEL);
   237     mImagesLeft = qobject_cast<HbLabel *>(widget);
   295     mImagesLeft = qobject_cast<HbLabel *>(widget);
   238     CX_DEBUG_ASSERT(mImagesLeft);
   296     CX_ASSERT_ALWAYS(mImagesLeft);
   239 
   297 
   240     widget = mDocumentLoader->findWidget(STILL_PRE_CAPTURE_IMAGES_LEFT_CONTAINER);
   298     widget = mDocumentLoader->findWidget(STILL_PRE_CAPTURE_IMAGES_LEFT_CONTAINER);
   241     mImagesLeftContainer = qobject_cast<HbWidget *>(widget);
   299     mImagesLeftContainer = qobject_cast<HbWidget *>(widget);
   242     CX_DEBUG_ASSERT(mImagesLeftContainer);
   300     CX_ASSERT_ALWAYS(mImagesLeftContainer);
   243     createWidgetBackgroundGraphic(mImagesLeftContainer, TRANSPARENT_BACKGROUND_GRAPHIC);
   301     createWidgetBackgroundGraphic(mImagesLeftContainer, TRANSPARENT_BACKGROUND_GRAPHIC);
   244     updateImagesLeftLabel();
   302     updateImagesLeftLabel();
       
   303 
       
   304     // Create self timer.
       
   305     // Let selftimer class get needed selftimer related widgets from the documentloader
       
   306     mSelfTimer = new CxuiSelfTimer(mEngine->settings());
       
   307     CX_ASSERT_ALWAYS(mSelfTimer);
       
   308     connect(mSelfTimer, SIGNAL(timerFinished()), this, SLOT(focusAndCapture()));
       
   309     mSelfTimer->loadSelftimerWidgets(mDocumentLoader);
   245 
   310 
   246     if (CxuiServiceProvider::isCameraEmbedded()) {
   311     if (CxuiServiceProvider::isCameraEmbedded()) {
   247         CX_DEBUG(("EMBEDDED: camera in embedded mode"));
   312         CX_DEBUG(("EMBEDDED: camera in embedded mode"));
   248 
   313 
   249         if (!CxuiServiceProvider::instance()->allowQualityChange()) {
   314         if (!CxuiServiceProvider::instance()->allowQualityChange()) {
   272 
   337 
   273     // Setting widgets loaded here so updating icons works.
   338     // Setting widgets loaded here so updating icons works.
   274     mWidgetsLoaded = true;
   339     mWidgetsLoaded = true;
   275 
   340 
   276     // Update toolbar flash mode icon
   341     // Update toolbar flash mode icon
   277     int flash;
   342     int flash = mEngine->settings().get<int>(CxeSettingIds::FLASH_MODE);
   278     if (mEngine->settings().get(CxeSettingIds::FLASH_MODE, flash) == CxeError::None) {
   343     handleSettingValueChanged(CxeSettingIds::FLASH_MODE, flash);
   279         handleSettingValueChanged(CxeSettingIds::FLASH_MODE, flash);
       
   280     }
       
   281 
   344 
   282     // Update toolbar scene mode icon
   345     // Update toolbar scene mode icon
   283     QString sceneId;
   346     updateSceneIcon(mEngine->settings().get<QString>(CxeSettingIds::IMAGE_SCENE));
   284     if (mEngine->settings().get(CxeSettingIds::SCENE_ID, sceneId) == CxeError::None) {
       
   285         updateSceneIcon(sceneId);
       
   286     }
       
   287 
   347 
   288     hideControls();
   348     hideControls();
       
   349 
       
   350     // Check if we need to show the geotagging disclaimer for first time use.
       
   351     Cxe::GeoTaggingDisclaimer value = mEngine->settings().get<Cxe::GeoTaggingDisclaimer>(CxeSettingIds::GEOTAGGING_DISCLAIMER, Cxe::GeoTaggingDisclaimerDisabled);
       
   352     if (value == Cxe::GeoTaggingDisclaimerEnabled) {
       
   353         launchGeoTaggingDisclaimerDialog();
       
   354     }
   289 
   355 
   290     // View is ready. Needed for startup performance automated testing.
   356     // View is ready. Needed for startup performance automated testing.
   291     emit viewReady();
   357     emit viewReady();
   292 
   358 
   293     OstTrace0( camerax_performance, DUP1_CXUISTILLPRECAPTUREVIEW_LOADWIDGETS, "msg: e_CX_STILLPRECAPTUREVIEW_LOADWIDGETS 0" );
   359     OstTrace0( camerax_performance, DUP1_CXUISTILLPRECAPTUREVIEW_LOADWIDGETS, "msg: e_CX_STILLPRECAPTUREVIEW_LOADWIDGETS 0" );
   390 
   456 
   391     // Read the value from settings. Ignoring reading error.
   457     // Read the value from settings. Ignoring reading error.
   392     // On error (missing settings) default to "postcapture on".
   458     // On error (missing settings) default to "postcapture on".
   393     int showPostcapture(-1);
   459     int showPostcapture(-1);
   394     if(mEngine) {
   460     if(mEngine) {
   395         mEngine->settings().get(CxeSettingIds::STILL_SHOWCAPTURED, showPostcapture);
   461         showPostcapture = mEngine->settings().get<int>(CxeSettingIds::STILL_SHOWCAPTURED, -1);
   396     }
   462     }
   397 
   463 
   398     CX_DEBUG_EXIT_FUNCTION();
   464     CX_DEBUG_EXIT_FUNCTION();
   399     return showPostcapture != 0; // 0 == no postcapture
   465     return showPostcapture != 0; // 0 == no postcapture
   400 }
   466 }
   419 
   485 
   420             CX_DEBUG(("CxuiStillPrecaptureView - icon: %s", icon.toAscii().constData()));
   486             CX_DEBUG(("CxuiStillPrecaptureView - icon: %s", icon.toAscii().constData()));
   421 
   487 
   422             if (mDocumentLoader) {
   488             if (mDocumentLoader) {
   423                 QObject *obj = mDocumentLoader->findObject(iconObjectName);
   489                 QObject *obj = mDocumentLoader->findObject(iconObjectName);
   424                 CX_DEBUG_ASSERT(obj);
   490                 CX_ASSERT_ALWAYS(obj);
   425                 qobject_cast<HbAction *>(obj)->setIcon(HbIcon(icon));
   491                 qobject_cast<HbAction *>(obj)->setIcon(HbIcon(icon));
   426             }
   492             }
   427         } else {
   493         } else {
   428             CX_DEBUG(("CxuiStillPrecaptureView - widgets not loaded yet, ignored!"));
   494             CX_DEBUG(("CxuiStillPrecaptureView - widgets not loaded yet, ignored!"));
   429         }
   495         }
   438 {
   504 {
   439     CX_DEBUG_ENTER_FUNCTION();
   505     CX_DEBUG_ENTER_FUNCTION();
   440 
   506 
   441     if (mQualityIcon && mEngine) {
   507     if (mQualityIcon && mEngine) {
   442         QString icon = "";
   508         QString icon = "";
   443         int currentValue = -1;
   509         int currentValue = mEngine->settings().get<int>(CxeSettingIds::IMAGE_QUALITY, -1);
   444 
       
   445         mEngine->settings().get(CxeSettingIds::IMAGE_QUALITY, currentValue);
       
   446         icon = getSettingItemIcon(CxeSettingIds::IMAGE_QUALITY, currentValue);
   510         icon = getSettingItemIcon(CxeSettingIds::IMAGE_QUALITY, currentValue);
   447 
   511 
   448         mQualityIcon->setIcon(HbIcon(icon));
   512         mQualityIcon->setIcon(HbIcon(icon));
   449     }
   513     }
   450 
   514 
   489  */
   553  */
   490 void CxuiStillPrecaptureView::focusAndCapture()
   554 void CxuiStillPrecaptureView::focusAndCapture()
   491 {
   555 {
   492     CX_DEBUG_ENTER_FUNCTION();
   556     CX_DEBUG_ENTER_FUNCTION();
   493 
   557 
   494     if (!mEngine->autoFocusControl().supported()) {
   558     if (!mEngine->autoFocusControl().supported() ||
       
   559          mEngine->autoFocusControl().isFixedFocusMode(mEngine->autoFocusControl().mode())) {
   495         // autofocus is not supported, so start capturing straight away
   560         // autofocus is not supported, so start capturing straight away
   496         capture();
   561         capture();
   497     } else {
   562     } else {
       
   563         setCapturePending();
   498         // start focusing
   564         // start focusing
   499         // Auto-focus can only work if viewfinder is running
   565         // Auto-focus can only work if viewfinder is running
   500         if (mEngine->viewfinderControl().state() == CxeViewfinderControl::Running) {
   566         if (mEngine->viewfinderControl().state() == CxeViewfinderControl::Running) {
   501             mEngine->autoFocusControl().start(false);
   567             mEngine->autoFocusControl().start(false);
   502         }
   568         }
   503         setCapturePending();
       
   504     }
   569     }
   505 
   570 
   506     CX_DEBUG_EXIT_FUNCTION();
   571     CX_DEBUG_EXIT_FUNCTION();
   507 }
   572 }
   508 
   573 
   795 
   860 
   796 /*
   861 /*
   797     Slot for handling scene mode change
   862     Slot for handling scene mode change
   798     \param scene QVariantMap containing settings related to the new scene mode
   863     \param scene QVariantMap containing settings related to the new scene mode
   799  */
   864  */
   800 void CxuiStillPrecaptureView::handleSceneChanged(CxeScene &scene)
   865 void CxuiStillPrecaptureView::handleSceneChanged(const QVariant &newSceneData)
   801 {
   866 {
   802     CX_DEBUG_ENTER_FUNCTION();
   867     CX_DEBUG_ENTER_FUNCTION();
   803     if (mEngine->mode() == Cxe::ImageMode) {
   868     if (mEngine->mode() == Cxe::ImageMode) {
   804 
   869 
       
   870         CxeScene scene = newSceneData.toMap();
   805         // update toolbar scene mode icon
   871         // update toolbar scene mode icon
   806         updateSceneIcon(scene[CxeSettingIds::SCENE_ID].toString());
   872         updateSceneIcon(scene[CxeSettingIds::SCENE_ID].toString());
   807 
   873 
   808         // for now, we are only interested in flashmode change
   874         // for now, we are only interested in flashmode change
   809         if (scene.contains(CxeSettingIds::FLASH_MODE)) {
   875         if (scene.contains(CxeSettingIds::FLASH_MODE)) {
   810             CX_DEBUG(("updating flash to: %d", scene[CxeSettingIds::FLASH_MODE].value<int>()));
   876             CX_DEBUG(("updating flash to: %d", scene[CxeSettingIds::FLASH_MODE].value<int>()));
   811             handleSettingValueChanged(CxeSettingIds::FLASH_MODE, scene[CxeSettingIds::FLASH_MODE]);
   877             handleSettingValueChanged(CxeSettingIds::FLASH_MODE, scene[CxeSettingIds::FLASH_MODE]);
   812         } else {
   878         } else {
   813             // No flash mode specified within the scene.
   879             // No flash mode specified within the scene.
   814             // Check from setting model what is it currently.
   880             // Check from setting model what is it currently.
   815             int flashMode(Cxe::FlashAuto);
   881             Cxe::FlashMode flashMode = mEngine->settings().get<Cxe::FlashMode>(CxeSettingIds::FLASH_MODE, Cxe::FlashAuto);
   816             mEngine->settings().get(CxeSettingIds::FLASH_MODE, flashMode);
       
   817             handleSettingValueChanged(CxeSettingIds::FLASH_MODE, QVariant(flashMode));
   882             handleSettingValueChanged(CxeSettingIds::FLASH_MODE, QVariant(flashMode));
   818         }
   883         }
       
   884 
   819     }
   885     }
   820 
   886 
   821     CX_DEBUG_EXIT_FUNCTION();
   887     CX_DEBUG_EXIT_FUNCTION();
   822 }
   888 }
   823 
   889 
   858             // update the quality indicator on screen
   924             // update the quality indicator on screen
   859             updateQualityIcon();
   925             updateQualityIcon();
   860             // update images left when quality values are changed
   926             // update images left when quality values are changed
   861             updateImagesLeftLabel();
   927             updateImagesLeftLabel();
   862         } else if (key == CxeSettingIds::FACE_TRACKING) {
   928         } else if (key == CxeSettingIds::FACE_TRACKING) {
       
   929             reloadIndicatorWidgets();
   863             updateFaceTrackingIcon();
   930             updateFaceTrackingIcon();
       
   931         } else if (key == CxeSettingIds::GEOTAGGING) {
       
   932             reloadIndicatorWidgets();
   864         }
   933         }
   865 
   934 
   866         // update toolbar flash icon
   935         // update toolbar flash icon
   867         if (mFlashSetting && key == CxeSettingIds::FLASH_MODE) {
   936         if (mFlashSetting && key == CxeSettingIds::FLASH_MODE) {
   868             CX_DEBUG((("flash mode: %d"), newValue.toInt()));
   937             CX_DEBUG((("flash mode: %d"), newValue.toInt()));
   912         QString settingsKey = action->property(PROPERTY_KEY_SETTING_ID).toString();
   981         QString settingsKey = action->property(PROPERTY_KEY_SETTING_ID).toString();
   913         CX_DEBUG(("settingsKey=%s", settingsKey.toAscii().constData()));
   982         CX_DEBUG(("settingsKey=%s", settingsKey.toAscii().constData()));
   914         launchSettingsDialog(action);
   983         launchSettingsDialog(action);
   915         // special case to get value changed event to the selftimer class
   984         // special case to get value changed event to the selftimer class
   916         if (settingsKey == CxeSettingIds::SELF_TIMER) {
   985         if (settingsKey == CxeSettingIds::SELF_TIMER) {
   917             // if selftimer is active remember the previously selected value
   986             // selftimer is not found in settings so set the value now
   918             if (mSelfTimer->isEnabled()) {
   987             mSettingsDialogList->setOriginalSelectedItemByValue(mSelfTimer->getTimeout());
   919                 mSettingsDialogList->setOriginalSelectedItemByValue(mSelfTimer->getTimeout());
       
   920             }
       
   921             connect(mSettingsDialogList, SIGNAL(valueSelected(int)),
   988             connect(mSettingsDialogList, SIGNAL(valueSelected(int)),
   922                     mSelfTimer, SLOT(changeTimeOut(int)));
   989                     mSelfTimer, SLOT(changeTimeOut(int)));
   923         }
   990         }
   924     }
   991     }
   925 
   992 
   956 {
  1023 {
   957     CX_DEBUG_ENTER_FUNCTION();
  1024     CX_DEBUG_ENTER_FUNCTION();
   958     if (mFaceTrackingIcon && mEngine) {
  1025     if (mFaceTrackingIcon && mEngine) {
   959         QString key = "";
  1026         QString key = "";
   960         QString icon = "";
  1027         QString icon = "";
   961         int currentValue = -1;
       
   962 
  1028 
   963         key = CxeSettingIds::FACE_TRACKING;
  1029         key = CxeSettingIds::FACE_TRACKING;
   964 
  1030 
   965         mEngine->settings().get(key, currentValue);
  1031         int currentValue = mEngine->settings().get<int>(key, -1);
   966         icon = getSettingItemIcon(key, currentValue);
  1032         icon = getSettingItemIcon(key, currentValue);
   967 
  1033 
   968         mFaceTrackingIcon->setIcon(HbIcon(icon));
  1034         mFaceTrackingIcon->setIcon(HbIcon(icon));
   969     }
  1035     }
   970 
  1036