camerauis/cameraxui/cxui/src/cxuivideoprecaptureview.cpp
changeset 21 fa6d9f75d6a6
parent 19 d9aefe59d544
child 24 2094593137f5
--- a/camerauis/cameraxui/cxui/src/cxuivideoprecaptureview.cpp	Fri Apr 16 14:51:30 2010 +0300
+++ b/camerauis/cameraxui/cxui/src/cxuivideoprecaptureview.cpp	Mon May 03 12:22:55 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -42,6 +42,7 @@
 #include "cxesettings.h"
 #include "cxuienums.h"
 #include "cxutils.h"
+#include "cxuizoomslider.h"
 #include "cxuicapturekeyhandler.h"
 #include "cxuidocumentloader.h"
 #include "OstTraceDefinitions.h"
@@ -77,7 +78,6 @@
     mToolBarIdle(NULL),
     mToolBarRec(NULL),
     mToolBarPaused(NULL),
-    mToggleLightAction(NULL),
     mVideoScenePopup(NULL),
     mVideoCaptureControl(NULL),
     mMenu(NULL),
@@ -110,6 +110,8 @@
             this, SLOT(handleSnapshot(CxeError::Id)));
     connect(mVideoCaptureControl, SIGNAL(stateChanged(CxeVideoCaptureControl::State, CxeError::Id)),
             this, SLOT(handleVideoStateChanged(CxeVideoCaptureControl::State,CxeError::Id)));
+    connect(mVideoCaptureControl, SIGNAL(remainingTimeChanged()),
+            this, SLOT(updateTimeLabels()));
 
     HbAction *quitAction = new HbAction(Hb::QuitNaviAction, this);
     setNavigationAction(quitAction);
@@ -138,13 +140,11 @@
     mQualityIcon = qobject_cast<HbLabel *> (widget);
     CX_DEBUG_ASSERT(mQualityIcon);
 
-    // Create background graphics for indicator containers
-    HbWidget *indicatorContainer;
     widget = mDocumentLoader->findWidget(VIDEO_PRE_CAPTURE_INDICATOR_CONTAINER_TOP);
-    indicatorContainer = qobject_cast<HbWidget *>(widget);
-    CX_DEBUG_ASSERT(indicatorContainer);
-    createWidgetBackgroundGraphic(indicatorContainer, TRANSPARENT_BACKGROUND_GRAPHIC);
-    indicatorContainer->show();
+    mIndicators = qobject_cast<HbWidget *>(widget);
+    CX_DEBUG_ASSERT(mIndicators);
+    // Create background graphics for indicator container
+    createWidgetBackgroundGraphic(mIndicators, TRANSPARENT_BACKGROUND_GRAPHIC);
 
     CX_DEBUG_EXIT_FUNCTION();
 }
@@ -177,7 +177,7 @@
     Q_ASSERT_X(ok, "camerax ui", "error in xml file parsing");
     // get needed pointers to some of the widgets
     widget = mDocumentLoader->findWidget(VIDEO_PRE_CAPTURE_ZOOM_SLIDER);
-    mSlider = qobject_cast<HbSlider *> (widget);
+    mSlider = qobject_cast<CxuiZoomSlider *> (widget);
     CX_DEBUG_ASSERT(mSlider);
 
     //Let's add a plus and minus buttons to the slider
@@ -197,10 +197,6 @@
     CX_DEBUG_ASSERT(mToolBarRec);
     CX_DEBUG_ASSERT(mToolBarPaused);
 
-    QObject* object = mDocumentLoader->findObject(VIDEO_PRE_CAPTURE_TOGGLE_LIGHT_ACTION);
-    mToggleLightAction = qobject_cast<HbAction *>(object);
-    CX_DEBUG_ASSERT(mToggleLightAction);
-
     hideControls();
 
     if (CxuiServiceProvider::isCameraEmbedded()) {
@@ -227,21 +223,13 @@
         if (!CxuiServiceProvider::instance()->allowCameraSwitching()) {
             CX_DEBUG(("EMBEDDED: don't allow camera switching"));
 
-            HbAction *goto_2nd_cam = qobject_cast<HbAction*> (mDocumentLoader->findObject(VIDEO_PRE_CAPTURE_GOTO_2ND_CAMERA_ACTION));
-            if (goto_2nd_cam) {
-                CX_DEBUG(("EMBEDDED: setting camera switch to disabled"));
-                goto_2nd_cam->setEnabled(false);
-
-            }
         }
 
     }
 
 
-    // Create background graphics for indicator containers
+    // Create background graphic for indicator container
     HbWidget *indicatorContainer;
-
-
     widget = mDocumentLoader->findWidget(VIDEO_PRE_CAPTURE_INDICATOR_CONTAINER_BOTTOM);
     indicatorContainer = qobject_cast<HbWidget *>(widget);
     CX_DEBUG_ASSERT(indicatorContainer);
@@ -313,10 +301,17 @@
 {
     CX_DEBUG_ENTER_FUNCTION();
 
-    mMenu = takeMenu();
-    hideControls();
-    mVideoCaptureControl->record();
-    //mRecordingAnimation->start();
+    int time(0);
+    mVideoCaptureControl->remainingTime(time);
+
+    if (time) {
+        mMenu = takeMenu();
+        hideControls();
+        mVideoCaptureControl->record();
+    } else {
+        launchDiskFullNotification();
+    }
+
     CX_DEBUG_EXIT_FUNCTION();
 }
 
@@ -463,31 +458,15 @@
     CxeVideoCaptureControl::State state = mVideoCaptureControl->state();
     switch (state) {
         case CxeVideoCaptureControl::Ready:
-            // Update remaining time label
             getRemainingTime();
-            setVideoTime(mRemainingTimeText, mTimeRemaining);
-            // Update elapsed time label
             // Not recording => elapsed time is zero
             mTimeElapsed = 0;
-            setVideoTime(mElapsedTimeText, mTimeElapsed);
-
-            // Adjust labels' visibility
-            mRemainingTimeText->show();
-            mElapsedTimeText->show();
             break;
 
         case CxeVideoCaptureControl::Recording:
         case CxeVideoCaptureControl::Paused:
-            // Update remaining time label
             getRemainingTime();
-            setVideoTime(mRemainingTimeText, mTimeRemaining);
-            // Update elapsed time label
             getElapsedTime();
-            setVideoTime(mElapsedTimeText, mTimeElapsed);
-
-            // Adjust labels' visibility
-            mRemainingTimeText->show();
-            mElapsedTimeText->show();
             break;
 
         case CxeVideoCaptureControl::Idle:
@@ -495,19 +474,16 @@
         case CxeVideoCaptureControl::Preparing:
         default:
             // Minimize processing during initialization phase.
-            // Calculating remaining time involves checking disk space,
+            // Calculating remaining time involves checking disk space, avoiding that.
             // which
             mTimeRemaining = 0;
-            setVideoTime(mRemainingTimeText, mTimeRemaining);
             mTimeElapsed = 0;
-            setVideoTime(mElapsedTimeText, mTimeElapsed);
-
-            // Adjust labels' visibility
-            mRemainingTimeText->hide();
-            mElapsedTimeText->hide();
             break;
     }
 
+    setVideoTime(mRemainingTimeText, mTimeRemaining);
+    setVideoTime(mElapsedTimeText, mTimeElapsed);
+
     CX_DEBUG_EXIT_FUNCTION();
 }
 
@@ -559,6 +535,10 @@
     }
 }
 
+/*!
+* Slot to handle video capture control state change.
+* Update visible items and stop / start timers.
+*/
 void CxuiVideoPrecaptureView::handleVideoStateChanged(CxeVideoCaptureControl::State newState,
         CxeError::Id error)
 {
@@ -569,29 +549,35 @@
 
     switch (newState) {
     case CxeVideoCaptureControl::Ready:
-        setRecordingItemsVisibility(false);
+        if (mDocumentLoader){
+            mDocumentLoader->load(VIDEO_1ST_XML, VIDEO_PRE_CAPTURE_IDLE);
+        }
         if (mCapturePending) {
             mCapturePending = false;
             record();
         }
         break;
     case CxeVideoCaptureControl::Recording:
-        setRecordingItemsVisibility(true);
+        if (mDocumentLoader){
+            mDocumentLoader->load(VIDEO_1ST_XML, VIDEO_PRE_CAPTURE_RECORDING);
+        }
         mElapsedTimer.start(CXUI_ELAPSED_TIME_TIMEOUT);
         disableFeedback();
         break;
     case CxeVideoCaptureControl::Paused:
         mElapsedTimer.stop();
-        if (mRecordingIcon) {
-            mRecordingIcon->hide();
+
+        if (mDocumentLoader){
+            mDocumentLoader->load(VIDEO_1ST_XML, VIDEO_PRE_CAPTURE_PAUSED);
         }
-        if (mElapsedTimeText) {
-            mElapsedTimeText->show();
-        }
+
         enableFeedback();
         break;
     case CxeVideoCaptureControl::Stopping:
-        setRecordingItemsVisibility(false);
+        if (mDocumentLoader){
+            mDocumentLoader->load(VIDEO_1ST_XML, VIDEO_PRE_CAPTURE_PAUSED);
+        }
+
         enableFeedback();
 
         if (isPostcaptureOn()) {
@@ -701,14 +687,8 @@
 void CxuiVideoPrecaptureView::handleFocusLost()
 {
     CX_DEBUG_IN_FUNCTION();
-
-    CxeVideoCaptureControl::State state = mVideoCaptureControl->state();
-    if (state == CxeVideoCaptureControl::Recording){
-        stop(); // delete recording icon
-    } else {
-        releaseCamera();
-    }
-
+    // Release camera. Stopping possibly ongoing recording is handled by engine.
+    releaseCamera();
 }
 
 void CxuiVideoPrecaptureView::handleBatteryEmpty()
@@ -726,31 +706,8 @@
 void CxuiVideoPrecaptureView::launchVideoScenePopup()
 {
     CX_DEBUG_ENTER_FUNCTION();
-
-    if (mVideoScenePopup) {
-        CX_DEBUG(("mVideoScenePopup already exists, showing..."));
-        mVideoScenePopup->show();
-    } else {
-        CX_DEBUG(("Loading popup DocML"));
-        CxuiDocumentLoader* documentLoader = new CxuiDocumentLoader(mEngine);
-        bool ok = false;
-
-        // Use document loader to create popup
-        documentLoader->load(SCENEMODE_VIDEO_SETTING_XML, &ok);
-
-        CX_DEBUG(("load ok=%d", ok));
-
-        mVideoScenePopup = qobject_cast<HbDialog*>(documentLoader->findWidget("video_scenemode_popup"));
-        CX_DEBUG_ASSERT(mVideoScenePopup);
-        mVideoScenePopup->setTimeout(HbDialog::NoTimeout);
-        mVideoScenePopup->setBackgroundFaded(false);
-
-        delete documentLoader;
-        documentLoader = NULL;
-    }
-
-    connect(mKeyHandler, SIGNAL(autofocusKeyPressed()), mVideoScenePopup, SLOT(close()));
-
+    hideControls();
+    emit showScenesView();
     CX_DEBUG_EXIT_FUNCTION();
 }