camerauis/cameraxui/cxui/src/cxuistillprecaptureview.cpp
branchRCL_3
changeset 23 61bc0f252b2b
equal deleted inserted replaced
22:f54ad444594d 23:61bc0f252b2b
       
     1 /*
       
     2 * Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 #include <QVariant>
       
    18 #include <QMetaType>
       
    19 #include <QGraphicsLayout>
       
    20 
       
    21 #include <hbpushbutton.h>
       
    22 #include <hblabel.h>
       
    23 #include <hbtoolbar.h>
       
    24 #include <hbaction.h>
       
    25 #include <hbmainwindow.h>
       
    26 #include <hbtransparentwindow.h>
       
    27 #include <hbslider.h>
       
    28 #include <hblistwidget.h>
       
    29 #include <hbdialog.h>
       
    30 #include <hblistwidgetitem.h>
       
    31 #include <hbtoolbarextension.h>
       
    32 #include <hbtoolbutton.h>
       
    33 #include <hbdeviceprofile.h> // HbDeviceProfile
       
    34 #include <hbmenu.h>
       
    35 #include <hbicon.h>
       
    36 #include <hbactivitymanager.h>
       
    37 
       
    38 #include "cxuiselftimer.h"
       
    39 #include "cxeengine.h"
       
    40 #include "cxeviewfindercontrol.h"
       
    41 #include "cxecameradevicecontrol.h"
       
    42 #include "cxestillcapturecontrol.h"
       
    43 #include "cxeautofocuscontrol.h"
       
    44 #include "cxuicapturekeyhandler.h"
       
    45 #include "cxutils.h"
       
    46 #include "cxenamespace.h" // CxeSettingIds
       
    47 #include "cxuienums.h"
       
    48 #include "cxesettings.h"
       
    49 #include "cxefeaturemanager.h" // mEngine->featureManager()
       
    50 #include "cxuidocumentloader.h"
       
    51 
       
    52 #ifdef Q_OS_SYMBIAN
       
    53 #include "OstTraceDefinitions.h"
       
    54 
       
    55 #ifdef OST_TRACE_COMPILER_IN_USE
       
    56 #include "cxuistillprecaptureviewTraces.h"
       
    57 #endif
       
    58 
       
    59 #endif //Q_OS_SYMBIAN
       
    60 
       
    61 #include "cxuistillprecaptureview.h"
       
    62 #include "cxuiserviceprovider.h"
       
    63 #include "cxuisettingdialog.h"
       
    64 #include "cxuisettingradiobuttonlist.h"
       
    65 #include "cxuizoomslider.h"
       
    66 
       
    67 using namespace Cxe;
       
    68 using namespace CxUiLayout;
       
    69 using namespace CxUiInternal;
       
    70 
       
    71 const int CXUI_CAPTURE_PENDING_TIMEOUT = 5000; // 5 seconds
       
    72 const int CXUI_IMAGES_LEFT_LIMIT = 99; // images left is shown only if below this limit
       
    73 
       
    74 CxuiStillPrecaptureView::CxuiStillPrecaptureView( QGraphicsItem *parent) :
       
    75     CxuiPrecaptureView(parent),
       
    76     mSelfTimer(NULL),
       
    77     mFlashSetting(NULL),
       
    78     mStillSettingsPopup(NULL),
       
    79     mSceneModePopup(NULL),
       
    80     mCapturePending(false),
       
    81     mImagesLeft(NULL),
       
    82     mImagesLeftContainer(NULL),
       
    83     mPendingAfCanceling(false)
       
    84 {
       
    85     CX_DEBUG_IN_FUNCTION();
       
    86 }
       
    87 
       
    88 CxuiStillPrecaptureView::~CxuiStillPrecaptureView()
       
    89 {
       
    90     CX_DEBUG_IN_FUNCTION();
       
    91     delete mSelfTimer;
       
    92 }
       
    93 
       
    94 /*!
       
    95  * Construct-method handles initialisation tasks for this class. Needs to be called
       
    96  * before the instance of this class is used.
       
    97  * @param mainwindow
       
    98  * @param engine
       
    99  * @param documentLoader
       
   100  * @param keyHandler
       
   101  */
       
   102 void CxuiStillPrecaptureView::construct(HbMainWindow *mainwindow, CxeEngine *engine,
       
   103                                         CxuiDocumentLoader *documentLoader,
       
   104                                         CxuiCaptureKeyHandler *keyHandler,
       
   105                                         HbActivityManager *activityManager)
       
   106 {
       
   107     CX_DEBUG_ENTER_FUNCTION();
       
   108     OstTrace0( camerax_performance, CXUISTILLPRECAPTUREVIEW_CONSTRUCT, "msg: e_CX_STILLPRECAPVIEW_CONSTRUCT 1" );
       
   109 
       
   110     // constuct base class
       
   111     CxuiPrecaptureView::construct(mainwindow, engine, documentLoader, keyHandler, activityManager);
       
   112 
       
   113     connect(&mEngine->autoFocusControl(), SIGNAL(stateChanged(CxeAutoFocusControl::State,CxeError::Id)),
       
   114             this, SLOT(handleAutoFocusStateChanged(CxeAutoFocusControl::State,CxeError::Id)));
       
   115     connect(&mEngine->stillCaptureControl(), SIGNAL(snapshotReady(CxeError::Id, const QImage&, int)),
       
   116             this, SLOT(handleSnapshot(CxeError::Id)));
       
   117     connect(&mEngine->stillCaptureControl(), SIGNAL(stateChanged(CxeStillCaptureControl::State, CxeError::Id)),
       
   118             this, SLOT(handleStillCaptureStateChanged(CxeStillCaptureControl::State, CxeError::Id)));
       
   119     connect(&mEngine->viewfinderControl(), SIGNAL(stateChanged(CxeViewfinderControl::State, CxeError::Id)),
       
   120             this, SLOT(handleViewfinderStateChanged(CxeViewfinderControl::State, CxeError::Id)));
       
   121     connect(&mEngine->stillCaptureControl(), SIGNAL(availableImagesChanged()),
       
   122             this, SLOT(updateImagesLeftLabel()));
       
   123 
       
   124     mEngine->settings().listenForSetting(CxeSettingIds::IMAGE_SCENE_DATA, this, SLOT(handleSceneChanged(const QVariant&)));
       
   125 
       
   126     loadDefaultWidgets();
       
   127     hideControls();
       
   128 
       
   129     OstTrace0( camerax_performance, DUP1_CXUISTILLPRECAPTUREVIEW_CONSTRUCT, "msg: e_CX_STILLPRECAPVIEW_CONSTRUCT 0" );
       
   130     CX_DEBUG_EXIT_FUNCTION();
       
   131 }
       
   132 
       
   133 /*!
       
   134  * Loads default widgets in layouts xml.
       
   135  */
       
   136 void CxuiStillPrecaptureView::loadDefaultWidgets()
       
   137 {
       
   138     CX_DEBUG_ENTER_FUNCTION();
       
   139     CX_ASSERT_ALWAYS(mDocumentLoader);
       
   140 
       
   141     // get pointer to the viewfinder
       
   142     QGraphicsWidget *widget = NULL;
       
   143     widget = mDocumentLoader->findWidget(STILL_PRE_CAPTURE_VIEWFINDER);
       
   144     mViewfinder = qobject_cast<HbTransparentWindow *>(widget);
       
   145     CX_ASSERT_ALWAYS(mViewfinder);
       
   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;
       
   165     widget = mDocumentLoader->findWidget(STILL_PRE_CAPTURE_QUALITY_ICON);
       
   166     mQualityIcon = qobject_cast<HbLabel *>(widget);
       
   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);
       
   172 
       
   173     widget = mDocumentLoader->findWidget(STILL_PRE_CAPTURE_GEOTAGGING_INDICATOR_ICON);
       
   174     mGeoTaggingIndicatorIcon = qobject_cast<HbLabel *>(widget);
       
   175     CX_ASSERT_ALWAYS(mGeoTaggingIndicatorIcon);
       
   176 
       
   177     widget = mDocumentLoader->findWidget(STILL_PRE_CAPTURE_FACE_TRACKING_ICON);
       
   178     mFaceTrackingIcon = qobject_cast<HbLabel *>(widget);
       
   179     CX_ASSERT_ALWAYS(mFaceTrackingIcon);
       
   180 
       
   181     widget = mDocumentLoader->findWidget(STILL_PRE_CAPTURE_INDICATOR_CONTAINER);
       
   182     mIndicators = qobject_cast<HbWidget *>(widget);
       
   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 
       
   225     // create background for indicator container
       
   226     createWidgetBackgroundGraphic(mIndicators, TRANSPARENT_BACKGROUND_GRAPHIC);
       
   227 
       
   228     mIndicators->setVisible(true);
       
   229 
       
   230     CX_DEBUG_EXIT_FUNCTION();
       
   231 }
       
   232 
       
   233 /*!
       
   234  * Loads widgets that are not part of the default section in layouts xml.
       
   235  * Widgets are created at the time they are first loaded.
       
   236  */
       
   237 void CxuiStillPrecaptureView::loadWidgets()
       
   238 {
       
   239     CX_DEBUG_ENTER_FUNCTION();
       
   240     CX_ASSERT_ALWAYS(mDocumentLoader);
       
   241 
       
   242     if (mWidgetsLoaded) {
       
   243         CX_DEBUG(("Widgets already loaded"));
       
   244         CX_DEBUG_EXIT_FUNCTION();
       
   245         return;
       
   246     }
       
   247 
       
   248     OstTrace0( camerax_performance, CXUISTILLPRECAPTUREVIEW_LOADWIDGETS, "msg: e_CX_STILLPRECAPTUREVIEW_LOADWIDGETS 1" );
       
   249 
       
   250     bool ok = false;
       
   251 
       
   252     OstTrace0( camerax_performance, DUP4_CXUISTILLPRECAPTUREVIEW_LOADWIDGETS, "msg: e_CX_DOCUMENTLOADER_LOAD 1" );
       
   253     mDocumentLoader->load(STILL_1ST_XML, STILL_PRE_CAPTURE_WIDGETS_SECTION, &ok);
       
   254     CX_ASSERT_ALWAYS(ok);
       
   255     if (CxuiServiceProvider::isCameraEmbedded()) {
       
   256         mDocumentLoader->load(STILL_1ST_XML, STILL_PRE_CAPTURE_EMBEDDED_SECTION, &ok);
       
   257     } else {
       
   258         mDocumentLoader->load(STILL_1ST_XML, STILL_PRE_CAPTURE_STANDALONE_SECTION, &ok);
       
   259     }
       
   260     OstTrace0( camerax_performance, DUP5_CXUISTILLPRECAPTUREVIEW_LOADWIDGETS, "msg: e_CX_DOCUMENTLOADER_LOAD 0" );
       
   261     CX_ASSERT_ALWAYS(ok);
       
   262 
       
   263     // get pointers to ui components from the layout data
       
   264     QGraphicsWidget *widget = NULL;
       
   265     QObject *object = NULL;
       
   266 
       
   267     widget = mDocumentLoader->findWidget(STILL_PRE_CAPTURE_ZOOM_SLIDER);
       
   268     mSlider = qobject_cast<CxuiZoomSlider *>(widget);
       
   269     CX_ASSERT_ALWAYS(mSlider);
       
   270     mSlider->addZoomButtons();
       
   271     createWidgetBackgroundGraphic(mSlider, TRANSPARENT_BACKGROUND_GRAPHIC);
       
   272 
       
   273     // create background for selftimer containers
       
   274     HbWidget *container = NULL;
       
   275     widget = mDocumentLoader->findWidget(STILL_PRE_CAPTURE_SELFTIMER_CONTAINER);
       
   276     container = qobject_cast<HbWidget *>(widget);
       
   277     CX_ASSERT_ALWAYS(container);
       
   278     createWidgetBackgroundGraphic(container, TRANSPARENT_BACKGROUND_GRAPHIC);
       
   279 
       
   280     // connect selftimer start button to hide controls
       
   281     widget = mDocumentLoader->findWidget(STILL_PRE_CAPTURE_SELFTIMER_START_BUTTON);
       
   282     HbPushButton *startButton = qobject_cast<HbPushButton *>(widget);
       
   283     CX_ASSERT_ALWAYS(startButton);
       
   284     connect(startButton, SIGNAL(released()), this, SLOT(hideControls()));
       
   285 
       
   286     widget = mDocumentLoader->findWidget(STILL_PRE_CAPTURE_TOOLBAR);
       
   287     mToolbar = qobject_cast<HbToolBar *>(widget);
       
   288     CX_ASSERT_ALWAYS(mToolbar);
       
   289 
       
   290     object = mDocumentLoader->findObject(STILL_PRE_CAPTURE_FLASH_ACTION);
       
   291     mFlashSetting = qobject_cast<HbAction *>(object);
       
   292     CX_ASSERT_ALWAYS(mFlashSetting);
       
   293 
       
   294     widget = mDocumentLoader->findWidget(STILL_PRE_CAPTURE_IMAGES_LEFT_LABEL);
       
   295     mImagesLeft = qobject_cast<HbLabel *>(widget);
       
   296     CX_ASSERT_ALWAYS(mImagesLeft);
       
   297 
       
   298     widget = mDocumentLoader->findWidget(STILL_PRE_CAPTURE_IMAGES_LEFT_CONTAINER);
       
   299     mImagesLeftContainer = qobject_cast<HbWidget *>(widget);
       
   300     CX_ASSERT_ALWAYS(mImagesLeftContainer);
       
   301     createWidgetBackgroundGraphic(mImagesLeftContainer, TRANSPARENT_BACKGROUND_GRAPHIC);
       
   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);
       
   310 
       
   311     if (CxuiServiceProvider::isCameraEmbedded()) {
       
   312         CX_DEBUG(("EMBEDDED: camera in embedded mode"));
       
   313 
       
   314         if (!CxuiServiceProvider::instance()->allowQualityChange()) {
       
   315 
       
   316             CX_DEBUG(("EMBEDDED: don't allow quality change"));
       
   317             HbAction* iq = qobject_cast<HbAction*>(mDocumentLoader->findObject(STILL_PRE_CAPTURE_IMAGE_QUALITY_ACTION));
       
   318             if (iq) {
       
   319                 CX_DEBUG(("EMBEDDED: setting image quality setting to disabled"));
       
   320                 iq->setEnabled(false);
       
   321             }
       
   322         }
       
   323         if (!CxuiServiceProvider::instance()->allowModeSwitching()) {
       
   324             CX_DEBUG(("EMBEDDED: don't allow mode switching"));
       
   325 
       
   326             HbAction *video = qobject_cast<HbAction*>(mDocumentLoader->findObject(STILL_PRE_CAPTURE_GOTO_VIDEO_ACTION));
       
   327             if (video) {
       
   328                 CX_DEBUG(("EMBEDDED: setting mode switch to disabled"));
       
   329                 video->setEnabled(false);
       
   330             }
       
   331         }
       
   332         if (!CxuiServiceProvider::instance()->allowCameraSwitching()) {
       
   333             CX_DEBUG(("EMBEDDED: don't allow camera switching"));
       
   334         }
       
   335 
       
   336     }
       
   337 
       
   338     // Setting widgets loaded here so updating icons works.
       
   339     mWidgetsLoaded = true;
       
   340 
       
   341     // Update toolbar flash mode icon
       
   342     int flash = mEngine->settings().get<int>(CxeSettingIds::FLASH_MODE);
       
   343     handleSettingValueChanged(CxeSettingIds::FLASH_MODE, flash);
       
   344 
       
   345     // Update toolbar scene mode icon
       
   346     updateSceneIcon(mEngine->settings().get<QString>(CxeSettingIds::IMAGE_SCENE));
       
   347 
       
   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     }
       
   355 
       
   356     // View is ready. Needed for startup performance automated testing.
       
   357     emit viewReady();
       
   358 
       
   359     OstTrace0( camerax_performance, DUP1_CXUISTILLPRECAPTUREVIEW_LOADWIDGETS, "msg: e_CX_STILLPRECAPTUREVIEW_LOADWIDGETS 0" );
       
   360     CX_DEBUG_EXIT_FUNCTION();
       
   361 }
       
   362 
       
   363 /*!
       
   364  * Restore view state from activity.
       
   365  */
       
   366 void CxuiStillPrecaptureView::restoreActivity(const QString &activityId, const QVariant &data)
       
   367 {
       
   368     Q_UNUSED(activityId);
       
   369     Q_UNUSED(data);
       
   370 
       
   371     CX_DEBUG_ENTER_FUNCTION();
       
   372     // no need to restore any state
       
   373     CX_DEBUG_EXIT_FUNCTION();
       
   374 }
       
   375 
       
   376 /*!
       
   377  * Save view state to activity.
       
   378  */
       
   379 void CxuiStillPrecaptureView::saveActivity()
       
   380 {
       
   381     CX_DEBUG_ENTER_FUNCTION();
       
   382     QVariantMap data;
       
   383     QVariantHash params;
       
   384 
       
   385     HbIcon activityScreenshot("qtg_graf_taskswitcher_camera");
       
   386     QPixmap screenshot = activityScreenshot.pixmap();
       
   387     params.insert("screenshot", screenshot);
       
   388 
       
   389     mActivityManager->removeActivity(
       
   390             CxuiActivityIds::STILL_PRECAPTURE_ACTIVITY);
       
   391     mActivityManager->addActivity(CxuiActivityIds::STILL_PRECAPTURE_ACTIVITY,
       
   392                                   data, params);
       
   393     CX_DEBUG_EXIT_FUNCTION();
       
   394 }
       
   395 
       
   396 /*!
       
   397  * Clear activity from activity manager.
       
   398  */
       
   399 void CxuiStillPrecaptureView::clearActivity()
       
   400 {
       
   401     CX_DEBUG_ENTER_FUNCTION();
       
   402     mActivityManager->removeActivity(CxuiActivityIds::STILL_PRECAPTURE_ACTIVITY);
       
   403     CX_DEBUG_EXIT_FUNCTION();
       
   404 }
       
   405 
       
   406 /*!
       
   407 * Initializing settings grid
       
   408 */
       
   409 void CxuiStillPrecaptureView::initializeSettingsGrid()
       
   410 {
       
   411     if(!mSettingsGrid) {
       
   412         HbAction* action(NULL);
       
   413 
       
   414         // Initialize settings grid
       
   415         mSettingsGrid = new HbToolBarExtension;
       
   416 
       
   417         action = mSettingsGrid->addAction(HbIcon("qtg_mono_exposure"), hbTrId("txt_cam_button_exposure_compensation"), this, SLOT(launchSliderSetting()));
       
   418         action->setProperty(PROPERTY_KEY_SETTING_ID, CxeSettingIds::EV_COMPENSATION_VALUE);
       
   419         action->setProperty(PROPERTY_KEY_SETTING_GRID, PROPERTY_KEY_TRUE);
       
   420 
       
   421         action = mSettingsGrid->addAction(HbIcon("qtg_mono_iso"), hbTrId("txt_cam_button_iso"), this, SLOT(launchSetting()));
       
   422         action->setProperty(PROPERTY_KEY_SETTING_ID, CxeSettingIds::LIGHT_SENSITIVITY);
       
   423         action->setProperty(PROPERTY_KEY_SETTING_GRID, PROPERTY_KEY_TRUE);
       
   424 
       
   425         action = mSettingsGrid->addAction(HbIcon("qtg_small_rgb"), hbTrId("txt_cam_button_color_tone"), this, SLOT(launchSetting()));
       
   426         action->setProperty(PROPERTY_KEY_SETTING_ID, CxeSettingIds::COLOR_TONE);
       
   427         action->setProperty(PROPERTY_KEY_SETTING_GRID, PROPERTY_KEY_TRUE);
       
   428 
       
   429         action = mSettingsGrid->addAction(HbIcon("qtg_mono_white_balance"), hbTrId("txt_cam_button_white_balance"), this, SLOT(launchSetting()));
       
   430         action->setProperty(PROPERTY_KEY_SETTING_ID, CxeSettingIds::WHITE_BALANCE);
       
   431         action->setProperty(PROPERTY_KEY_SETTING_GRID, PROPERTY_KEY_TRUE);
       
   432 
       
   433         action = mSettingsGrid->addAction(HbIcon("qtg_mono_sharpness"), hbTrId("txt_cam_grid_sharpness"), this, SLOT(launchSliderSetting()));
       
   434         action->setProperty(PROPERTY_KEY_SETTING_ID, CxeSettingIds::SHARPNESS);
       
   435         action->setProperty(PROPERTY_KEY_SETTING_GRID, PROPERTY_KEY_TRUE);
       
   436 
       
   437         action = mSettingsGrid->addAction(HbIcon("qtg_mono_contrast"), hbTrId("txt_cam_button_contrast"), this, SLOT(launchSliderSetting()));
       
   438         action->setProperty(PROPERTY_KEY_SETTING_ID, CxeSettingIds::CONTRAST);
       
   439         action->setProperty(PROPERTY_KEY_SETTING_GRID, PROPERTY_KEY_TRUE);
       
   440 
       
   441         action = mSettingsGrid->addAction(HbIcon("qtg_mono_face_tracking"), hbTrId("txt_cam_button_face_tracking"), this, SLOT(launchSetting()));
       
   442         action->setProperty(PROPERTY_KEY_SETTING_ID, CxeSettingIds::FACE_TRACKING);
       
   443         action->setProperty(PROPERTY_KEY_SETTING_GRID, PROPERTY_KEY_TRUE);
       
   444 
       
   445         connect(mCaptureKeyHandler, SIGNAL(autofocusKeyPressed()), mSettingsGrid, SLOT(close()));
       
   446     }
       
   447 }
       
   448 
       
   449 /**
       
   450 * Get if postcapture view should be shown or not.
       
   451 * Postcapture view may be shown for a predefined time or
       
   452 * until user dismisses it, or it may be completely disabled.
       
   453 */
       
   454 bool CxuiStillPrecaptureView::isPostcaptureOn() const
       
   455 {
       
   456     CX_DEBUG_ENTER_FUNCTION();
       
   457     if (CxuiServiceProvider::isCameraEmbedded()) {
       
   458         // always show post capture in embedded mode
       
   459         CX_DEBUG_EXIT_FUNCTION();
       
   460         return true;
       
   461     }
       
   462 
       
   463     // Read the value from settings. Ignoring reading error.
       
   464     // On error (missing settings) default to "postcapture on".
       
   465     int showPostcapture(-1);
       
   466     if(mEngine) {
       
   467         showPostcapture = mEngine->settings().get<int>(CxeSettingIds::STILL_SHOWCAPTURED, -1);
       
   468     }
       
   469 
       
   470     CX_DEBUG_EXIT_FUNCTION();
       
   471     return showPostcapture != 0; // 0 == no postcapture
       
   472 }
       
   473 
       
   474 /*!
       
   475 * Update the scene mode icon.
       
   476 * @param sceneId The new scene id.
       
   477 */
       
   478 void CxuiStillPrecaptureView::updateSceneIcon(const QString& sceneId)
       
   479 {
       
   480     CX_DEBUG_ENTER_FUNCTION();
       
   481 
       
   482     if (mEngine->mode() == Cxe::ImageMode) {
       
   483         CX_DEBUG(("CxuiStillPrecaptureView - scene: %s", sceneId.toAscii().constData()));
       
   484 
       
   485         // No need to update icon, if widgets are not even loaded yet.
       
   486         // We'll update the icon once the widgets are loaded.
       
   487         if (mWidgetsLoaded) {
       
   488 
       
   489             QString iconObjectName = STILL_PRE_CAPTURE_SCENE_MODE_ACTION;
       
   490             QString icon = getSettingItemIcon(CxeSettingIds::IMAGE_SCENE, sceneId);
       
   491 
       
   492             CX_DEBUG(("CxuiStillPrecaptureView - icon: %s", icon.toAscii().constData()));
       
   493 
       
   494             if (mDocumentLoader) {
       
   495                 QObject *obj = mDocumentLoader->findObject(iconObjectName);
       
   496                 CX_ASSERT_ALWAYS(obj);
       
   497                 qobject_cast<HbAction *>(obj)->setIcon(HbIcon(icon));
       
   498             }
       
   499         } else {
       
   500             CX_DEBUG(("CxuiStillPrecaptureView - widgets not loaded yet, ignored!"));
       
   501         }
       
   502     }
       
   503     CX_DEBUG_EXIT_FUNCTION();
       
   504 }
       
   505 
       
   506 /*!
       
   507     Update the quality indicator
       
   508 */
       
   509 void CxuiStillPrecaptureView::updateQualityIcon()
       
   510 {
       
   511     CX_DEBUG_ENTER_FUNCTION();
       
   512 
       
   513     if (mQualityIcon && mEngine) {
       
   514         QString icon = "";
       
   515         int currentValue = mEngine->settings().get<int>(CxeSettingIds::IMAGE_QUALITY, -1);
       
   516         icon = getSettingItemIcon(CxeSettingIds::IMAGE_QUALITY, currentValue);
       
   517 
       
   518         mQualityIcon->setIcon(HbIcon(icon));
       
   519     }
       
   520 
       
   521     CX_DEBUG_EXIT_FUNCTION();
       
   522 }
       
   523 
       
   524 void CxuiStillPrecaptureView::handleSnapshot(CxeError::Id error)
       
   525 {
       
   526     CX_DEBUG_ENTER_FUNCTION();
       
   527 
       
   528     if (mPendingAfCanceling) {
       
   529         mPendingAfCanceling = false;
       
   530         mEngine->autoFocusControl().cancel();
       
   531     }
       
   532 
       
   533     if (error == CxeError::None) {
       
   534         // Enging may emit snapshot events even if we don't need the snapshot.
       
   535         // Check if postcapture is actually wanted and change view now if so.
       
   536         if(isPostcaptureOn()) {
       
   537             emit changeToPostcaptureView();
       
   538             if (mSlider) {
       
   539                 mSlider->hide();
       
   540             }
       
   541         }
       
   542     } else {
       
   543         emit errorEncountered(error);
       
   544     }
       
   545 
       
   546     CX_DEBUG_EXIT_FUNCTION();
       
   547 }
       
   548 
       
   549 
       
   550 /*!
       
   551      Method for starting focusing which will be followed by capture.
       
   552      Meant for selftimer purposes. If autofocusing is not supported, capture
       
   553      will start without focusing.
       
   554 
       
   555      \sa capture()
       
   556      \sa handleAutofocusKeyPressed()
       
   557      \sa handleCaptureKeyPressed()
       
   558      \sa setCapturePending()
       
   559  */
       
   560 void CxuiStillPrecaptureView::focusAndCapture()
       
   561 {
       
   562     CX_DEBUG_ENTER_FUNCTION();
       
   563 
       
   564     if (!mEngine->autoFocusControl().supported() ||
       
   565          mEngine->autoFocusControl().isFixedFocusMode(mEngine->autoFocusControl().mode())) {
       
   566         // autofocus is not supported, so start capturing straight away
       
   567         capture();
       
   568     } else {
       
   569         setCapturePending();
       
   570         // start focusing
       
   571         // Auto-focus can only work if viewfinder is running
       
   572         if (mEngine->viewfinderControl().state() == CxeViewfinderControl::Running) {
       
   573             mEngine->autoFocusControl().start(false);
       
   574         }
       
   575     }
       
   576 
       
   577     CX_DEBUG_EXIT_FUNCTION();
       
   578 }
       
   579 
       
   580 void CxuiStillPrecaptureView::capture()
       
   581 {
       
   582     CX_DEBUG_ENTER_FUNCTION();
       
   583     mCapturePending = false;
       
   584 
       
   585     if (mEngine->mode() == Cxe::ImageMode) {
       
   586         // do not start capturing, if it is already ongoing
       
   587         // the user might be repeatedly triggering capture key
       
   588         if (mEngine->stillCaptureControl().state() == CxeStillCaptureControl::Ready) {
       
   589             // If focusing in progress, cancel it now.
       
   590             // Set capture pending and continue once focusing is cancelled.
       
   591             if(mEngine->autoFocusControl().state() == CxeAutoFocusControl::InProgress) {
       
   592                 mEngine->autoFocusControl().cancel();
       
   593                 setCapturePending();
       
   594             } else {
       
   595                 // Engine uses disk space *estimate* for imagesLeft() so it
       
   596                 // should not cause significant delay / additional shutter lag.
       
   597                 if (mEngine->stillCaptureControl().imagesLeft()) {
       
   598                     mEngine->stillCaptureControl().reset();  //! @todo: Do not delete snapshots before images are really saved
       
   599                     mEngine->stillCaptureControl().capture();
       
   600                 } else {
       
   601                     // Inform that error was encountered.
       
   602                     // Error manager will show necessary message to user.
       
   603                     emit errorEncountered(CxeError::DiskFull);
       
   604                 }
       
   605             }
       
   606         } else {
       
   607             setCapturePending();
       
   608         }
       
   609     }
       
   610 
       
   611     // after capturing check what is the new amount for images left
       
   612     updateImagesLeftLabel();
       
   613     CX_DEBUG_EXIT_FUNCTION();
       
   614 }
       
   615 
       
   616 void CxuiStillPrecaptureView::setCapturePending()
       
   617 {
       
   618     CX_DEBUG_ENTER_FUNCTION();
       
   619     mCapturePending = true;
       
   620     QTimer::singleShot(CXUI_CAPTURE_PENDING_TIMEOUT, this, SLOT(resetCapturePendingFlag()));
       
   621     CX_DEBUG_EXIT_FUNCTION();
       
   622 }
       
   623 
       
   624 
       
   625 void CxuiStillPrecaptureView::goToVideo()
       
   626 {
       
   627     CX_DEBUG_ENTER_FUNCTION();
       
   628     OstTrace0( camerax_performance, DUP1_CXUISTILLPRECAPTUREVIEW_GOTOVIDEO, "msg: e_CX_GO_TO_VIDEO_MODE 1" );
       
   629 
       
   630     hideControls();
       
   631     mEngine->initMode(VideoMode);
       
   632     emit changeToPrecaptureView();
       
   633 
       
   634     CX_DEBUG_EXIT_FUNCTION();
       
   635 }
       
   636 
       
   637 /*!
       
   638     CxuiStillPrecaptureView::handleAutoFocusStateChanged
       
   639 
       
   640     \sa focusAndCapture()
       
   641     \sa capture()
       
   642     \sa handleAutofocusKeyPressed()
       
   643 */
       
   644 void CxuiStillPrecaptureView::handleAutoFocusStateChanged(CxeAutoFocusControl::State newstate, CxeError::Id error)
       
   645 {
       
   646     CX_DEBUG_ENTER_FUNCTION();
       
   647     CxeAutoFocusControl::Mode mode = mEngine->autoFocusControl().mode();
       
   648     CX_DEBUG( ("CxuiStillPrecaptureView::handleAutoFocusStateChanged <> error: %d mode: %d state %d", error, mode,
       
   649             newstate ) );
       
   650 
       
   651 
       
   652     switch (newstate) {
       
   653     case CxeAutoFocusControl::Failed:
       
   654     case CxeAutoFocusControl::Ready:
       
   655         if (mCapturePending) {
       
   656             // focus and capture were grouped together, capture straight away
       
   657             capture();
       
   658         }
       
   659         break;
       
   660     case CxeAutoFocusControl::Unknown:
       
   661         // Capture key was pressed, focus has been cancelled,
       
   662         // continue with capturing.
       
   663         if(mCapturePending) {
       
   664             CX_DEBUG(("mCapturePending is true, starting capture now"));
       
   665             capture();
       
   666         }
       
   667         break;
       
   668     default:
       
   669         break;
       
   670     }
       
   671 
       
   672     CX_DEBUG_EXIT_FUNCTION();
       
   673 }
       
   674 
       
   675 
       
   676 /*!
       
   677 * Handle capture key full press.
       
   678 */
       
   679 void CxuiStillPrecaptureView::handleCaptureKeyPressed()
       
   680 {
       
   681     CX_DEBUG_ENTER_FUNCTION();
       
   682     if (mEngine->mode() == Cxe::ImageMode) {
       
   683         OstTrace0(camerax_performance, CXUISTILLPRECAPTUREVIEW_SHOT_TO_SHOT, "msg: e_CX_SHOT_TO_SHOT 1");
       
   684         OstTrace0(camerax_performance, CXUISTILLPRECAPTUREVIEW_SHOT_TO_SNAP, "msg: e_CX_SHOT_TO_SNAPSHOT 1");
       
   685         OstTrace0(camerax_performance, CXUISTILLPRECAPTUREVIEW_SHOT_TO_SAVE, "msg: e_CX_SHOT_TO_SAVE 1");
       
   686 
       
   687         menu()->close();
       
   688 
       
   689         // close open dialogs
       
   690         closeDialogs();
       
   691 
       
   692         if (mSelfTimer && mSelfTimer->isEnabled() ) {
       
   693             if (mSelfTimer->isOngoing()) {
       
   694                 // dismiss selftimer and capture image
       
   695                 mSelfTimer->cancel();
       
   696                 capture();
       
   697             } else {
       
   698                 // start selftimer if it is enabled and not yet started
       
   699                 mSelfTimer->startTimer();
       
   700             }
       
   701         } else {
       
   702             // normal capture
       
   703             capture();
       
   704         }
       
   705     }
       
   706     CX_DEBUG_EXIT_FUNCTION();
       
   707 }
       
   708 
       
   709 /*!
       
   710 * Handle capture key half pressed (aka "autofocus key press").
       
   711 */
       
   712 void CxuiStillPrecaptureView::handleAutofocusKeyPressed()
       
   713 {
       
   714     CX_DEBUG_ENTER_FUNCTION();
       
   715     OstTrace0( camerax_performance, CXUISTILLPRECAPTUREVIEW_AUTOFOCUS, "msg: e_CX_AUTOFOCUS_LOCK 1" );
       
   716 
       
   717     // Base class handling needs to happen first to keep e.g. settings dialogs handling sane.
       
   718     CxuiPrecaptureView::handleAutofocusKeyPressed();
       
   719 
       
   720     if (!mEngine->autoFocusControl().supported()) {
       
   721         CX_DEBUG(("Autofocus not supported, ignoring key press"));
       
   722         CX_DEBUG_EXIT_FUNCTION();
       
   723         return;
       
   724     }
       
   725 
       
   726     // in case of selftimer being enabled, autofocuskey does not start focusing
       
   727     if (mSelfTimer && mSelfTimer->isEnabled()){
       
   728         CX_DEBUG(("Selftimer enabled, ignoring autofocus key press"));
       
   729         CX_DEBUG_EXIT_FUNCTION();
       
   730         return;
       
   731     }
       
   732 
       
   733     // Auto-focus can only work if viewfinder is running
       
   734     if (mEngine->viewfinderControl().state() == CxeViewfinderControl::Running) {
       
   735 
       
   736         mEngine->autoFocusControl().start();
       
   737     }
       
   738 
       
   739     CX_DEBUG_EXIT_FUNCTION();
       
   740 }
       
   741 
       
   742 void CxuiStillPrecaptureView::handleAutofocusKeyReleased()
       
   743 {
       
   744     CX_DEBUG_ENTER_FUNCTION();
       
   745 
       
   746     // in case of selftimer being enabled, autofocuskey should not do anything
       
   747     if (mSelfTimer && mSelfTimer->isEnabled()){
       
   748         CX_DEBUG(("Selftimer enabled, ignoring autofocus key release"));
       
   749         CX_DEBUG_EXIT_FUNCTION();
       
   750         return;
       
   751     }
       
   752 
       
   753     if (mEngine->autoFocusControl().supported()) {
       
   754         // Check that capture is not in progress, or pending.
       
   755         // Otherwise wouldn't want to cancel the focus.
       
   756         CxeStillCaptureControl::State state(mEngine->stillCaptureControl().state());
       
   757         if (state != CxeStillCaptureControl::Capturing && !mCapturePending) {
       
   758             mEngine->autoFocusControl().cancel();
       
   759         } else {
       
   760             // set pending AF release
       
   761             mPendingAfCanceling = true;
       
   762         }
       
   763 
       
   764     } else {
       
   765         CX_DEBUG(("Autofocus not supported, ignoring key release"));
       
   766     }
       
   767 
       
   768     CX_DEBUG_EXIT_FUNCTION();
       
   769 }
       
   770 
       
   771 void CxuiStillPrecaptureView::showEvent(QShowEvent *event)
       
   772 {
       
   773     CxuiPrecaptureView::showEvent(event);
       
   774 
       
   775     updateImagesLeftLabel();
       
   776     updateQualityIcon();
       
   777     updateFaceTrackingIcon();
       
   778 
       
   779     // cancel selftimer when returning to precapture
       
   780     // since selftimer needs to be turned off after capturing an image
       
   781     // (with selftimer postcapture is always shown)
       
   782     if (mSelfTimer && mSelfTimer->isEnabled()) {
       
   783         mSelfTimer->cancel();
       
   784     }
       
   785 
       
   786     // In case the user presses and holds the auto-focus key (ie. half-press)
       
   787     // in post-capture view, we need to start auto-focusing when entering
       
   788     // the still precapture view.
       
   789     if (event->type() == QEvent::Show &&
       
   790             mCaptureKeyHandler && mCaptureKeyHandler->isAutofocusKeyPressed()) {
       
   791 
       
   792         CX_DEBUG(("Still pre-capture coming visible and auto-focus key pressed -> starting AF"));
       
   793         handleAutofocusKeyPressed();
       
   794     }
       
   795 }
       
   796 
       
   797 /*!
       
   798 * Allow showing UI controls?
       
   799 */
       
   800 bool CxuiStillPrecaptureView::allowShowControls() const
       
   801 {
       
   802     // show controls when selftimer counter is not active
       
   803     // and when autofocus key is not being pressed
       
   804     bool engineOk(mEngine && mEngine->isEngineReady());
       
   805     bool selfTimerOk(!mSelfTimer || !mSelfTimer->isOngoing());
       
   806     bool keysOk(!mCaptureKeyHandler || !mCaptureKeyHandler->isAutofocusKeyPressed());
       
   807 
       
   808     return engineOk && selfTimerOk && keysOk;
       
   809 }
       
   810 
       
   811 /*!
       
   812 * Handle change in viewfinder state.
       
   813 */
       
   814 void CxuiStillPrecaptureView::handleViewfinderStateChanged(
       
   815     CxeViewfinderControl::State newState, CxeError::Id error)
       
   816 {
       
   817     CX_DEBUG_ENTER_FUNCTION();
       
   818     // Call base class to get standby timer and display always visible when needed.
       
   819     CxuiPrecaptureView::handleVfStateChanged(newState, error);
       
   820 
       
   821     if (newState == CxeViewfinderControl::Running) {
       
   822 
       
   823         // the toolbar is created when the viewfinder is started the first time
       
   824         // in order to hide the delay caused by the creation
       
   825         if(!mWidgetsLoaded) {
       
   826             loadWidgets();
       
   827         }
       
   828 
       
   829         if(mMainWindow->currentView() == this &&
       
   830             mCaptureKeyHandler->isAutofocusKeyPressed()) {
       
   831             // Viewfinder just started and the user is pressing the auto-focus key.
       
   832             // Start focusing.
       
   833 
       
   834             CX_DEBUG(("Viewfinder starting and auto-focus key pressed -> starting AF"));
       
   835             handleAutofocusKeyPressed();
       
   836         }
       
   837     }
       
   838 
       
   839     CX_DEBUG_EXIT_FUNCTION();
       
   840 }
       
   841 
       
   842 void CxuiStillPrecaptureView::handleStillCaptureStateChanged(
       
   843     CxeStillCaptureControl::State newState, CxeError::Id /*error*/)
       
   844 {
       
   845     if (newState == CxeStillCaptureControl::Ready) {
       
   846         OstTrace0(camerax_performance, DUP1_CXUISTILLPRECAPTUREVIEW_SHOT_TO_SHOT, "msg: e_CX_SHOT_TO_SHOT 0");
       
   847 
       
   848         if (mCapturePending) {
       
   849             CX_DEBUG(("mCapturePending is true, starting capture now"));
       
   850             capture();
       
   851         }
       
   852     }
       
   853 }
       
   854 
       
   855 /*!
       
   856  * Signal used to reset mCapturePending after a short timeout. If the image
       
   857  * cannot be captured within a given time of the key press, it is better to cancel
       
   858  * the whole operation.
       
   859  */
       
   860 void CxuiStillPrecaptureView::resetCapturePendingFlag()
       
   861 {
       
   862     CX_DEBUG_IN_FUNCTION();
       
   863 
       
   864     mCapturePending = false;
       
   865 }
       
   866 
       
   867 /*
       
   868     Slot for handling scene mode change
       
   869     \param scene QVariantMap containing settings related to the new scene mode
       
   870  */
       
   871 void CxuiStillPrecaptureView::handleSceneChanged(const QVariant &newSceneData)
       
   872 {
       
   873     CX_DEBUG_ENTER_FUNCTION();
       
   874     if (mEngine->mode() == Cxe::ImageMode) {
       
   875 
       
   876         CxeScene scene = newSceneData.toMap();
       
   877         // update toolbar scene mode icon
       
   878         updateSceneIcon(scene[CxeSettingIds::SCENE_ID].toString());
       
   879 
       
   880         // for now, we are only interested in flashmode change
       
   881         if (scene.contains(CxeSettingIds::FLASH_MODE)) {
       
   882             CX_DEBUG(("updating flash to: %d", scene[CxeSettingIds::FLASH_MODE].value<int>()));
       
   883             handleSettingValueChanged(CxeSettingIds::FLASH_MODE, scene[CxeSettingIds::FLASH_MODE]);
       
   884         } else {
       
   885             // No flash mode specified within the scene.
       
   886             // Check from setting model what is it currently.
       
   887             Cxe::FlashMode flashMode = mEngine->settings().get<Cxe::FlashMode>(CxeSettingIds::FLASH_MODE, Cxe::FlashAuto);
       
   888             handleSettingValueChanged(CxeSettingIds::FLASH_MODE, QVariant(flashMode));
       
   889         }
       
   890 
       
   891         // If facetracking is changed, we need to update the indicator icon
       
   892         if (scene.contains(CxeSettingIds::FACE_TRACKING)) {
       
   893             handleSettingValueChanged(CxeSettingIds::FACE_TRACKING, scene[CxeSettingIds::FACE_TRACKING]);
       
   894         }
       
   895 
       
   896     }
       
   897 
       
   898     CX_DEBUG_EXIT_FUNCTION();
       
   899 }
       
   900 
       
   901 /*!
       
   902 * Enter standby mode.
       
   903 */
       
   904 void CxuiStillPrecaptureView::enterStandby()
       
   905 {
       
   906     CX_DEBUG_ENTER_FUNCTION();
       
   907 
       
   908     if (mSelfTimer && mSelfTimer->isOngoing()) {
       
   909         // If self-timer is running, stop and reset the delay now.
       
   910         mSelfTimer->reset();
       
   911     }
       
   912 
       
   913     // Base class handles releasing camera.
       
   914     CxuiPrecaptureView::enterStandby();
       
   915 
       
   916     CX_DEBUG_EXIT_FUNCTION();
       
   917 }
       
   918 
       
   919 /*
       
   920     Slot for handling setting value changes. Notice that changing the scene mode
       
   921     does not emit settingValueChanged signal.
       
   922     \param key      CxSettingIds key defining the changed setting
       
   923     \param newValue QVariant containing the new setting value
       
   924 
       
   925     \sa CxuiStillPrecaptureView::handleSceneChanged(CxeScene &scene)
       
   926  */
       
   927 void CxuiStillPrecaptureView::handleSettingValueChanged(const QString& key, QVariant newValue)
       
   928 {
       
   929     CX_DEBUG_ENTER_FUNCTION();
       
   930 
       
   931     if (mEngine->mode() == Cxe::ImageMode) {
       
   932 
       
   933         // update images left and image quality icons
       
   934         if (key == CxeSettingIds::IMAGE_QUALITY) {
       
   935             // update the quality indicator on screen
       
   936             updateQualityIcon();
       
   937             // update images left when quality values are changed
       
   938             updateImagesLeftLabel();
       
   939         } else if (key == CxeSettingIds::FACE_TRACKING) {
       
   940             reloadIndicatorWidgets();
       
   941             updateFaceTrackingIcon();
       
   942         } else if (key == CxeSettingIds::GEOTAGGING) {
       
   943             reloadIndicatorWidgets();
       
   944         }
       
   945 
       
   946         // update toolbar flash icon
       
   947         if (mFlashSetting && key == CxeSettingIds::FLASH_MODE) {
       
   948             CX_DEBUG((("flash mode: %d"), newValue.toInt()));
       
   949             QString icon = getSettingItemIcon(key, newValue);
       
   950             CX_DEBUG((("flash mode icon: %s"), icon.toAscii().constData()))
       
   951             mFlashSetting->setIcon(HbIcon(icon));
       
   952         }
       
   953 
       
   954     }
       
   955 
       
   956     CX_DEBUG_EXIT_FUNCTION();
       
   957 }
       
   958 
       
   959 
       
   960 /*!
       
   961     Close open dialogs.
       
   962 */
       
   963 void CxuiStillPrecaptureView::closeDialogs()
       
   964 {
       
   965 
       
   966     if (mSettingsDialog && mSettingsDialog->isVisible()) {
       
   967         mSettingsDialog->close();
       
   968     }
       
   969 
       
   970     if (mSceneModePopup && mSceneModePopup->isVisible()) {
       
   971         mSceneModePopup->close();
       
   972     }
       
   973 
       
   974     if (mStillSettingsPopup && mStillSettingsPopup->isVisible()) {
       
   975         mStillSettingsPopup->close();
       
   976     }
       
   977 
       
   978     hideSettingsGrid();
       
   979 }
       
   980 
       
   981 
       
   982 /*!
       
   983 *Helper method to create setting dialog
       
   984 */
       
   985 void CxuiStillPrecaptureView::launchSetting()
       
   986 {
       
   987     CX_DEBUG_ENTER_FUNCTION();
       
   988 
       
   989     QObject *action = sender();
       
   990 
       
   991     if (action) {
       
   992         QString settingsKey = action->property(PROPERTY_KEY_SETTING_ID).toString();
       
   993         CX_DEBUG(("settingsKey=%s", settingsKey.toAscii().constData()));
       
   994         launchSettingsDialog(action);
       
   995         // special case to get value changed event to the selftimer class
       
   996         if (settingsKey == CxeSettingIds::SELF_TIMER) {
       
   997             // selftimer is not found in settings so set the value now
       
   998             mSettingsDialogList->setOriginalSelectedItemByValue(mSelfTimer->getTimeout());
       
   999             connect(mSettingsDialogList, SIGNAL(valueSelected(int)),
       
  1000                     mSelfTimer, SLOT(changeTimeOut(int)));
       
  1001         }
       
  1002     }
       
  1003 
       
  1004     CX_DEBUG_EXIT_FUNCTION();
       
  1005 }
       
  1006 
       
  1007 /*!
       
  1008     Update the images left counter
       
  1009 */
       
  1010 void CxuiStillPrecaptureView::updateImagesLeftLabel()
       
  1011 {
       
  1012     CX_DEBUG_ENTER_FUNCTION();
       
  1013 
       
  1014     if (mImagesLeft && mImagesLeftContainer) {
       
  1015         int images = mEngine->stillCaptureControl().imagesLeft();
       
  1016 
       
  1017         if (images > CXUI_IMAGES_LEFT_LIMIT) {
       
  1018             mImagesLeftContainer->hide();
       
  1019         } else {
       
  1020             mImagesLeftContainer->show();
       
  1021         }
       
  1022 
       
  1023         CX_DEBUG(("Images left %d", images));
       
  1024         mImagesLeft->setPlainText(hbTrId("txt_cam_fullscreen_imagesleft").arg(images));
       
  1025     }
       
  1026 
       
  1027     CX_DEBUG_EXIT_FUNCTION();
       
  1028 }
       
  1029 
       
  1030 /*!
       
  1031     Update the face tracking icon
       
  1032 */
       
  1033 void CxuiStillPrecaptureView::updateFaceTrackingIcon()
       
  1034 {
       
  1035     CX_DEBUG_ENTER_FUNCTION();
       
  1036     if (mFaceTrackingIcon && mEngine) {
       
  1037         QString key = "";
       
  1038         QString icon = "";
       
  1039 
       
  1040         key = CxeSettingIds::FACE_TRACKING;
       
  1041 
       
  1042         int currentValue = mEngine->settings().get<int>(key, -1);
       
  1043         icon = getSettingItemIcon(key, currentValue);
       
  1044 
       
  1045         mFaceTrackingIcon->setIcon(HbIcon(icon));
       
  1046     }
       
  1047 
       
  1048     CX_DEBUG_EXIT_FUNCTION();
       
  1049 }
       
  1050 
       
  1051 // end of file