camerauis/cameraxui/cxengine/src/cxestillcapturecontroldesktop.cpp
changeset 55 0da2a5b56583
parent 46 c826656d6714
--- a/camerauis/cameraxui/cxengine/src/cxestillcapturecontroldesktop.cpp	Mon Aug 23 13:50:05 2010 +0300
+++ b/camerauis/cameraxui/cxengine/src/cxestillcapturecontroldesktop.cpp	Fri Sep 03 11:00:58 2010 +0300
@@ -32,8 +32,11 @@
 #include "cxecameradevicedesktop.h"
 
 // constants
-const int KMaintainAspectRatio = false;
-
+namespace
+{
+    static const int KMaintainAspectRatio = false;
+    static const int VIEWFINDER_START_TIMEOUT = 500; // 0.5 second
+}
 
 
 /**
@@ -62,6 +65,10 @@
     initializeStates();
     reset();
 
+    mViewFinderStartTimer.setSingleShot(true);
+    mViewFinderStartTimer.setInterval(VIEWFINDER_START_TIMEOUT);
+    connect(&mViewFinderStartTimer, SIGNAL(timeout()), this, SLOT(startViewfinder()));
+
     mImageDataQueue = new CxeImageDataQueueDesktop();
 
     CX_DEBUG_EXIT_FUNCTION();
@@ -131,6 +138,10 @@
         CX_DEBUG_EXIT_FUNCTION();
         return;
     }
+
+    mViewFinderStartTimer.stop();
+    mViewfinderControl.stop();
+
     mState = Uninitialized;
     CX_DEBUG_EXIT_FUNCTION();
 }
@@ -173,8 +184,8 @@
     }
 
     if (!err) {
-        // If viewfinder is already running, this call does nothing
-        mViewfinderControl.start();
+        // Start viewfinder with delay.
+        mViewFinderStartTimer.start();
         // inform zoom control to prepare zoom
         emit prepareZoomForStill(ecamStillResolutionIndex);
     } else {
@@ -573,6 +584,17 @@
     CX_DEBUG_EXIT_FUNCTION();
 }
 
+/*!
+* Slot for starting viewfinder after a delay.
+* Delay helps viewfinder widget to find the right, visible transparent window to attach to.
+*/
+void CxeStillCaptureControlDesktop::startViewfinder()
+{
+    CX_DEBUG_ENTER_FUNCTION();
+    mViewfinderControl.start();
+    CX_DEBUG_EXIT_FUNCTION();
+}
+
 
 /*!
 * Returns supported image qualities based on the camera index