camerauis/cameraxui/cxui/src/cxuiapplicationstate.cpp
changeset 58 ddba9caa7f32
parent 42 feebad15db8c
--- a/camerauis/cameraxui/cxui/src/cxuiapplicationstate.cpp	Fri Sep 03 11:00:58 2010 +0300
+++ b/camerauis/cameraxui/cxui/src/cxuiapplicationstate.cpp	Fri Sep 17 16:35:28 2010 +0300
@@ -48,6 +48,9 @@
     // USB mass memory mode signal
     connect(mApplicationMonitor, SIGNAL(usbMassMemoryModeToggled(bool)),
             this, SLOT(handleUsbMassMemoryModeChanged(bool)));
+    
+    // Task switcher state signal
+    connect(mApplicationMonitor, SIGNAL(taskSwitcherStateChanged(bool)), this, SLOT(handleTaskSwitcherStateChanged(bool)));
 
     // Severe error signals
     connect(mErrorManager, SIGNAL(errorPopupShown()), this, SLOT(handleSevereError()));
@@ -121,10 +124,10 @@
         mErrorManager->clear();
     } else {
         CX_DEBUG(("CxuiApplicationState - application is in partial / full foreground"));
-        // Check that we were in background. Switching between partial and full background
-        // needs no actions.
-        if (currentState() == Background) {
-           CX_DEBUG(("CxuiApplicationState - application was in background before, moving to foreground"));
+        // Check that we were in background or standby state. 
+        // State can be standby, if camera lost focus to task switcher.
+        if (currentState() == Background || currentState() == Standby) {
+           CX_DEBUG(("CxuiApplicationState - application was in partial/full background, moving to foreground"));
             // Check that there's no active errors that have been ignored in background.
             checkErrors();
             if (currentState() != Error) {
@@ -165,6 +168,26 @@
 }
 
 /*!
+* Handle Task Switcher state changes.
+* If Task Switcher activates, we enter standby mode.
+* When we receive foreground event, we can move back to Normal mode.
+* @param foreground Is the Task Switcher in foreground/active.
+*/
+void CxuiApplicationState::handleTaskSwitcherStateChanged(bool foreground)
+{
+    CX_DEBUG_ENTER_FUNCTION();
+    if (foreground) {
+        // When task switcher is active, we enter standby mode.
+        if (currentState() == Normal) {
+            // Go to standby mode (release camera).
+            CX_DEBUG(("CxuiApplicationState - application losing partial-foreground to task switcher"));
+            setState(Standby);
+        }
+    }
+    CX_DEBUG_EXIT_FUNCTION();
+}
+
+/*!
 * Handle battery emptying. We need to stop all activity and exit the application.
 */
 void CxuiApplicationState::handleBatteryEmpty()