--- a/camerauis/cameraxui/cxui/src/cxuiviewmanager.cpp Fri Apr 16 14:51:30 2010 +0300
+++ b/camerauis/cameraxui/cxui/src/cxuiviewmanager.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"
@@ -18,16 +18,14 @@
#include <QTimer>
#include <hbmainwindow.h>
#include <coemain.h>
-#include <avkondomainpskeys.h> // keyguard
-#include <hwrmpowerstatesdkpskeys.h> // battery
#include <QGraphicsSceneEvent>
+#include "cxuiapplication.h"
+#include "cxuiapplicationframeworkmonitor.h"
#include "cxuiviewmanager.h"
#include "cxuivideoprecaptureview.h"
-#include "cxuivideoprecaptureview2.h"
#include "cxuistillprecaptureview.h"
-#include "cxuistillprecaptureview2.h"
#include "cxuipostcaptureview.h"
#include "cxuicapturekeyhandler.h"
#include "cxeengine.h"
@@ -37,16 +35,18 @@
#include "cxenamespace.h"
#include "cxuienums.h"
#include "cxutils.h"
-#include "xqsettingsmanager.h" // Settings Manager API
#include "cxuidocumentloader.h"
#include "cxuistandby.h"
#include "cxuierrormanager.h"
+#include "cxesettings.h"
+#include "cxememorymonitor.h"
+#include "cxuiserviceprovider.h"
+#include "cxuiscenemodeview.h"
+
#include "OstTraceDefinitions.h"
#ifdef OST_TRACE_COMPILER_IN_USE
#include "cxuiviewmanagerTraces.h"
#endif
-#include "cxuiserviceprovider.h"
-
using namespace Cxe;
@@ -58,97 +58,81 @@
//
// ---------------------------------------------------------------------------
//
-CxuiViewManager::CxuiViewManager(HbMainWindow &mainWindow, CxeEngine &engine, CxuiCaptureKeyHandler &keyHandler) :
+CxuiViewManager::CxuiViewManager(CxuiApplication &application, HbMainWindow &mainWindow, CxeEngine &engine) :
+ mApplication(application),
mMainWindow(mainWindow),
mStillPrecaptureView(NULL),
mVideoPrecaptureView(NULL),
mPostcaptureView(NULL),
- mStillPrecaptureView2(NULL),
- mVideoPrecaptureView2(NULL),
mEngine(engine),
- mKeyHandler(keyHandler),
- mSettingsManager(NULL),
- mFocused(true),
- mCameraDocumentLoader(NULL)
+ mKeyHandler(NULL),
+ mApplicationMonitor(NULL),
+ mCameraDocumentLoader(NULL),
+ mSceneModeView(NULL)
{
CX_DEBUG_ENTER_FUNCTION();
+ // Application monitor
+ mApplicationMonitor = new CxuiApplicationFrameworkMonitor(mApplication, mEngine.settings());
+ connect(mApplicationMonitor, SIGNAL(foregroundStateChanged(CxuiApplicationFrameworkMonitor::ForegroundState)),
+ this, SLOT(handleForegroundStateChanged(CxuiApplicationFrameworkMonitor::ForegroundState)));
+ connect(mApplicationMonitor, SIGNAL(batteryEmpty()),
+ this, SLOT(handleBatteryEmpty()));
+
+ // Connect memory monitor start / stop to focused status
+ connect(this, SIGNAL(focusGained()), &mEngine.memoryMonitor(), SLOT(startMonitoring()));
+ connect(this, SIGNAL(focusLost()), &mEngine.memoryMonitor(), SLOT(stopMonitoring()));
+
+ // Key handler
+ mKeyHandler = new CxuiCaptureKeyHandler(mEngine);
+
mMainWindow.installEventFilter(this); // in order to filter capture and AF keys
OstTrace0( camerax_performance, CXUIVIEWMANAGER_CXUIVIEWMANAGER, "msg: e_CX_VIEWMANAGER_CREATE_DOCLOADER 1" );
- mCameraDocumentLoader = new CxuiDocumentLoader;
+ mCameraDocumentLoader = new CxuiDocumentLoader(&engine);
OstTrace0( camerax_performance, DUP1_CXUIVIEWMANAGER_CXUIVIEWMANAGER, "msg: e_CX_VIEWMANAGER_CREATE_DOCLOADER 0" );
// standby functionality and necessary signal connections
- mStandbyHandler = new CxuiStandby(keyHandler, mCameraDocumentLoader, &engine);
+ mStandbyHandler = new CxuiStandby(*mKeyHandler, mCameraDocumentLoader, &mEngine);
connect(mStandbyHandler, SIGNAL(aboutToEnterStandby()),this, SLOT(aboutToLooseFocus()));
connect(mStandbyHandler, SIGNAL(aboutToExitStandby()),this, SLOT(aboutToGainFocus()));
// error manager, handling errors and notifying users based on their severity
- mErrorManager = new CxuiErrorManager(keyHandler, mCameraDocumentLoader);
+ mErrorManager = new CxuiErrorManager(*mKeyHandler, mCameraDocumentLoader);
// connecting necessary signals from error manager to release and init camera.
connect(mErrorManager, SIGNAL(aboutToRecoverError()), this, SLOT(aboutToLooseFocus()));
connect(mErrorManager, SIGNAL(errorRecovered()), this, SLOT(aboutToGainFocus()));
- if (!CxuiServiceProvider::isCameraEmbedded()) {
- // for embedded mode: don't create view yet, create
- // when engine inits to correct mode
-#ifdef FORCE_SECONDARY_CAMERA
- // 2nd camera hack: always use 1st camera view
- if (mEngine.mode() == Cxe::VideoMode) {
- createVideoPrecaptureView();
-
- mMainWindow.blockSignals(true);
- mMainWindow.setCurrentView(mVideoPrecaptureView, false);
- mMainWindow.blockSignals(false);
- } else {
- createStillPrecaptureView();
-
- mMainWindow.blockSignals(true);
- mMainWindow.setCurrentView(mStillPrecaptureView, false);
- mMainWindow.blockSignals(false);
- }
-
-#else
- if (mEngine.cameraDeviceControl().cameraIndex() == Cxe::PrimaryCameraIndex) {
- if (mEngine.mode() == Cxe::VideoMode) {
- createVideoPrecaptureView();
- mMainWindow.blockSignals(true);
- mMainWindow.setCurrentView(mVideoPrecaptureView, false);
- mMainWindow.blockSignals(false);
- } else {
- createStillPrecaptureView();
- mMainWindow.blockSignals(true);
- mMainWindow.setCurrentView(mStillPrecaptureView, false);
- mMainWindow.blockSignals(false);
- }
- } else {
- if (mEngine.mode() == Cxe::VideoMode) {
- createVideoPrecaptureView2();
- mMainWindow.blockSignals(true);
- mMainWindow.setCurrentView(mVideoPrecaptureView2, false);
- mMainWindow.blockSignals(false);
- } else {
- createStillPrecaptureView2();
- mMainWindow.blockSignals(true);
- mMainWindow.setCurrentView(mStillPrecaptureView2, false);
- mMainWindow.blockSignals(false);
- }
- }
-#endif
- connectPreCaptureSignals();
- }
-
- startEventMonitors();
+ if (!CxuiServiceProvider::isCameraEmbedded()) {
+ // For embedded mode: don't create view yet, create
+ // when engine inits to correct mode
+ CX_DEBUG_ASSERT(mEngine.cameraDeviceControl().cameraIndex() == Cxe::PrimaryCameraIndex);
+ if (mEngine.mode() == Cxe::VideoMode) {
+ createVideoPrecaptureView();
+ mMainWindow.blockSignals(true);
+ mMainWindow.setCurrentView(mVideoPrecaptureView, false);
+ mMainWindow.blockSignals(false);
+ } else {
+ createStillPrecaptureView();
+ mMainWindow.blockSignals(true);
+ mMainWindow.setCurrentView(mStillPrecaptureView, false);
+ mMainWindow.blockSignals(false);
+ }
+ connectPreCaptureSignals();
+ }
//connecting initmode signals
connect(&mEngine.cameraDeviceControl(), SIGNAL(initModeComplete(CxeError::Id)),
this, SLOT(createPostcaptureView()));
+
connect(&mEngine.cameraDeviceControl(), SIGNAL(initModeComplete(CxeError::Id)),
mErrorManager, SLOT(analyze(CxeError::Id)));
+ connect(&mEngine.stillCaptureControl(), SIGNAL(imageCaptured(CxeError::Id, int)),
+ mErrorManager, SLOT(analyze(CxeError::Id)));
+
if (CxuiServiceProvider::isCameraEmbedded()) {
// connect signals to set up the view after image/video prepare
connect(&mEngine.stillCaptureControl(), SIGNAL(imagePrepareComplete(CxeError::Id)),
@@ -159,7 +143,7 @@
// start standby timer now because view will not be ready when viewfinder is started
mStandbyHandler->startTimer();
}
-
+
CX_DEBUG_EXIT_FUNCTION();
}
@@ -173,7 +157,8 @@
CX_DEBUG_ENTER_FUNCTION();
delete mCameraDocumentLoader;
- delete mSettingsManager;
+ delete mKeyHandler;
+ delete mApplicationMonitor;
CX_DEBUG_EXIT_FUNCTION();
}
@@ -199,22 +184,20 @@
{
CX_DEBUG_ENTER_FUNCTION();
OstTrace0( camerax_performance, CXUIVIEWMANAGER_CREATESTILLPRECAPTUREVIEW, "msg: e_CX_CREATE_STILLPRECAPTUREVIEW 1" );
- bool ok = false;
- CX_DEBUG_ASSERT(mCameraDocumentLoader);
-
- OstTrace0( camerax_performance, DUP2_CXUIVIEWMANAGER_ADDPRECAPTUREVIEWS, "msg: e_CX_DOCLOADER_LOAD 1" );
// Use document loader to create widgets and layouts
// (non-sectioned parts are parsed and loaded)
+ OstTrace0( camerax_performance, DUP2_CXUIVIEWMANAGER_ADDPRECAPTUREVIEWS, "msg: e_CX_DOCLOADER_LOAD 1" );
+
+ bool ok = false;
+ CX_DEBUG_ASSERT(mCameraDocumentLoader);
mCameraDocumentLoader->load(STILL_1ST_XML, &ok);
Q_ASSERT_X(ok, "createStillPrecaptureView", "error in xml file parsing");
- QGraphicsWidget *widget = NULL;
-
OstTrace0( camerax_performance, DUP2_CXUIVIEWMANAGER_CREATESTILLPRECAPTUREVIEW, "msg: e_CX_DOCLOADER_LOAD 0" );
-
OstTrace0( camerax_performance, DUP4_CXUIVIEWMANAGER_ADDPRECAPTUREVIEWS, "msg: e_CX_DOCLOADER_FINDWIDGET 1" );
+ QGraphicsWidget *widget = NULL;
// ask for the still precapture view widget pointer
widget = mCameraDocumentLoader->findWidget(STILL_PRE_CAPTURE_VIEW);
mStillPrecaptureView = qobject_cast<CxuiStillPrecaptureView *> (widget);
@@ -222,9 +205,11 @@
OstTrace0( camerax_performance, DUP5_CXUIVIEWMANAGER_ADDPRECAPTUREVIEWS, "msg: e_CX_DOCLOADER_FINDWIDGET 0" );
// call for needed consturction methods
- mStillPrecaptureView->construct(&mMainWindow, &mEngine, mCameraDocumentLoader, &mKeyHandler);
+ mStillPrecaptureView->construct(&mMainWindow, &mEngine, mCameraDocumentLoader, mKeyHandler);
// .. and add to main window (which also takes ownership)
+ OstTrace0( camerax_performance, DUP1_CXUIVIEWMANAGER_MAINWINDOW_ADDVIEW, "msg: e_CX_MAINWINDOW_ADDVIEW 1" );
mMainWindow.addView(widget);
+ OstTrace0( camerax_performance, DUP2_CXUIVIEWMANAGER_MAINWINDOW_ADDVIEW, "msg: e_CX_MAINWINDOW_ADDVIEW 0" );
OstTrace0( camerax_performance, DUP1_CXUIVIEWMANAGER_CREATESTILLPRECAPTUREVIEW, "msg: e_CX_CREATE_STILLPRECAPTUREVIEW 0" );
@@ -232,11 +217,11 @@
}
// ---------------------------------------------------------------------------
-// CxuiViewManager::createStillPrecaptureView2
+// CxuiViewManager::createStillScenesView
//
// ---------------------------------------------------------------------------
//
-void CxuiViewManager::createStillPrecaptureView2()
+void CxuiViewManager::createSceneModesView()
{
CX_DEBUG_ENTER_FUNCTION();
@@ -245,24 +230,48 @@
// Use document loader to create widgets and layouts
// (non-sectioned parts are parsed and loaded)
- mCameraDocumentLoader->load(STILL_2ND_XML, &ok);
- Q_ASSERT_X(ok, "createStillPrecaptureView2", "error in xml file parsing");
+ mCameraDocumentLoader->load(SCENEMODE_SETTING_XML, &ok);
QGraphicsWidget *widget = NULL;
- // ask for the still precapture view widget pointer
- widget = mCameraDocumentLoader->findWidget(STILL_PRE_CAPTURE_VIEW2);
- mStillPrecaptureView2 = qobject_cast<CxuiStillPrecaptureView2 *> (widget);
- CX_DEBUG_ASSERT(mStillPrecaptureView2);
+ // ask for the scenes mode view widget pointer
+ widget = mCameraDocumentLoader->findWidget(STILL_SCENES_VIEW);
+ Q_ASSERT_X(ok && (widget != 0), "camerax ui", "invalid xml file");
+ mSceneModeView = qobject_cast<CxuiSceneModeView *> (widget);
- // call for needed consturction methods
- mStillPrecaptureView2->construct(&mMainWindow, &mEngine, mCameraDocumentLoader, &mKeyHandler);
+ // call for needed construction methods
+ mSceneModeView->construct(&mMainWindow, &mEngine, mCameraDocumentLoader, mKeyHandler);
// .. and add to main window (which also takes ownership)
mMainWindow.addView(widget);
+ mSceneModeView->loadBackgroundImages();
+ connect(mSceneModeView, SIGNAL(viewCloseEvent()), this, SLOT(changeToPrecaptureView()));
CX_DEBUG_EXIT_FUNCTION();
}
+/*!
+* CxuiViewManager::showScenesView
+* A private method for displaying Scene Modes selection view
+*/
+void CxuiViewManager::showScenesView()
+{
+ CX_DEBUG_ENTER_FUNCTION();
+ if (!mSceneModeView) {
+ createSceneModesView();
+ }
+ else {
+ mSceneModeView->loadBackgroundImages();
+ }
+ CX_DEBUG_ASSERT(mSceneModeView);
+ mMainWindow.blockSignals(true);
+ mMainWindow.setCurrentView(mSceneModeView, false);
+ emit disableStandbyTimer();
+ connectCaptureKeySignals();
+ mMainWindow.blockSignals(false);
+ CX_DEBUG_EXIT_FUNCTION();
+}
+
+
// ---------------------------------------------------------------------------
// CxuiViewManager::createVideoPrecaptureView
//
@@ -285,44 +294,18 @@
widget = mCameraDocumentLoader->findWidget(VIDEO_PRE_CAPTURE_VIEW);
mVideoPrecaptureView = qobject_cast<CxuiVideoPrecaptureView *> (widget);
CX_DEBUG_ASSERT(mVideoPrecaptureView);
- mVideoPrecaptureView->construct(&mMainWindow, &mEngine, mCameraDocumentLoader, &mKeyHandler);
+ mVideoPrecaptureView->construct(&mMainWindow, &mEngine, mCameraDocumentLoader, mKeyHandler);
// add view to main window
+ OstTrace0( camerax_performance, DUP3_CXUIVIEWMANAGER_MAINWINDOW_ADDVIEW, "msg: e_CX_MAINWINDOW_ADDVIEW 1" );
mMainWindow.addView(mVideoPrecaptureView);
+ OstTrace0( camerax_performance, DUP4_CXUIVIEWMANAGER_MAINWINDOW_ADDVIEW, "msg: e_CX_MAINWINDOW_ADDVIEW 0" );
OstTrace0( camerax_performance, DUP1_CXUIVIEWMANAGER_CREATEVIDEOPRECAPTUREVIEW, "msg: e_CX_CREATE_VIDEOPRECAPTUREVIEW 0" );
CX_DEBUG_EXIT_FUNCTION();
}
// ---------------------------------------------------------------------------
-// CxuiViewManager::createVideoPrecaptureView2
-//
-// ---------------------------------------------------------------------------
-//
-void CxuiViewManager::createVideoPrecaptureView2()
-{
- CX_DEBUG_ENTER_FUNCTION();
- CX_DEBUG_ASSERT(mCameraDocumentLoader);
-
- bool ok = false;
- // load and create the default widgets in video xml
- mCameraDocumentLoader->load(VIDEO_2ND_XML, &ok);
- CX_DEBUG_ASSERT(ok);
-
- // get pointer to videoprecaptureview and do some initialisation
- QGraphicsWidget *widget = NULL;
- widget = mCameraDocumentLoader->findWidget(VIDEO_PRE_CAPTURE_VIEW2);
- mVideoPrecaptureView2 = qobject_cast<CxuiVideoPrecaptureView2 *> (widget);
- CX_DEBUG_ASSERT(mVideoPrecaptureView2);
- mVideoPrecaptureView2->construct(&mMainWindow, &mEngine, mCameraDocumentLoader);
-
- // add view to main window
- mMainWindow.addView(mVideoPrecaptureView2);
-
- CX_DEBUG_EXIT_FUNCTION();
-}
-
-// ---------------------------------------------------------------------------
// CxuiViewManager::createStillPostcaptureView
//
// ---------------------------------------------------------------------------
@@ -365,44 +348,20 @@
CX_DEBUG_ENTER_FUNCTION();
CX_DEBUG(("CxuiViewManager::getPrecaptureView() mode=%d, camera index=%d", mode, camera));
-#ifdef FORCE_SECONDARY_CAMERA
- // 2nd camera forced: always use 1st camera view
- CX_DEBUG(("CxuiViewManager::getPrecaptureView() forcing primary camera view"));
- camera = Cxe::PrimaryCameraIndex;
-#endif // FORCE_SECONDARY_CAMERA
+ CX_DEBUG_ASSERT(camera == Cxe::PrimaryCameraIndex);
if (mode == ImageMode) {
-
CX_DEBUG(("CxuiViewManager::getPrecaptureView() image mode"));
- if (camera == Cxe::PrimaryCameraIndex) {
- CX_DEBUG(("CxuiViewManager::getPrecaptureView() primary camera"));
- if(!mStillPrecaptureView) {
- createStillPrecaptureView();
- }
- return mStillPrecaptureView;
- } else {
- CX_DEBUG(("CxuiViewManager::getPrecaptureView() secondary camera"));
- if(!mStillPrecaptureView2) {
- createStillPrecaptureView2();
- }
- return mStillPrecaptureView2;
+ if(!mStillPrecaptureView) {
+ createStillPrecaptureView();
}
+ return mStillPrecaptureView;
} else {
-
CX_DEBUG(("CxuiViewManager::getPrecaptureView() video mode"));
- if (camera == Cxe::PrimaryCameraIndex) {
- CX_DEBUG(("CxuiViewManager::getPrecaptureView() primary camera"));
- if(!mVideoPrecaptureView) {
- createVideoPrecaptureView();
- }
- return mVideoPrecaptureView;
- } else {
- CX_DEBUG(("CxuiViewManager::getPrecaptureView() secondary camera"));
- if(!mVideoPrecaptureView2) {
- createVideoPrecaptureView2();
- }
- return mVideoPrecaptureView2;
+ if(!mVideoPrecaptureView) {
+ createVideoPrecaptureView();
}
+ return mVideoPrecaptureView;
}
}
@@ -431,9 +390,6 @@
// connecting all necessary signals for postcapture view
connectPostCaptureSignals();
- //@todo: refactor postcapture view to new focus and state handling as agreed with package owner
- connect(this, SIGNAL(focusGained()), mPostcaptureView, SLOT(startTimers()), Qt::UniqueConnection);
-
CX_DEBUG_EXIT_FUNCTION();
}
@@ -463,6 +419,7 @@
// connecting necessary pre-capture view signals
connectPreCaptureSignals();
+ emit startStandbyTimer();
CX_DEBUG_EXIT_FUNCTION();
}
@@ -509,87 +466,23 @@
//
bool CxuiViewManager::eventFilter(QObject *object, QEvent *event)
{
+ Q_UNUSED(object)
+
bool eventWasConsumed = false;
switch (event->type())
{
case QEvent::KeyPress:
case QEvent::KeyRelease:
- eventWasConsumed = mKeyHandler.handleKeyEvent(event);
- break;
- case QEvent::WindowActivate:
- if (object == &mMainWindow) {
- CX_DEBUG(("CxuiViewManager - window activated"));
- // If we gained focus and keyguard is off.
- if (!mFocused) {
- mFocused = true;
- if (mKeyLockState == EKeyguardNotActive) {
- aboutToGainFocus();
- }
- }
- }
- break;
- case QEvent::WindowDeactivate:
- if (object == &mMainWindow)
- {
- CX_DEBUG(("CxuiViewManager - window de-activated"));
- if (mFocused) {
- mFocused = false;
- aboutToLooseFocus();
- }
- }
+ eventWasConsumed = mKeyHandler->handleKeyEvent(event);
break;
}
-
// No need to call base class implementation, because we derive from QObject directly.
// QObject::eventFilter() implementation always returns false.
return eventWasConsumed;
}
// ---------------------------------------------------------------------------
-// CxuiViewManager::startEventMonitors
-//
-// ---------------------------------------------------------------------------
-//
-void CxuiViewManager::startEventMonitors()
-{
- CX_DEBUG_ENTER_FUNCTION();
- bool ok = false;
-
- mSettingsManager = new XQSettingsManager(this);
- ok = connect(mSettingsManager, SIGNAL(valueChanged(XQSettingsKey, QVariant)),
- this, SLOT(eventMonitor(XQSettingsKey, QVariant)));
- CX_DEBUG_ASSERT(ok);
-
- // Keyguard status (locked / unlocked)
- XQSettingsKey keyguard(XQSettingsKey::TargetPublishAndSubscribe,
- KPSUidAvkonDomain.iUid,
- KAknKeyguardStatus);
-
- QVariant value = mSettingsManager->readItemValue(keyguard);
- if (value == QVariant::Int) {
- mKeyLockState = value.toInt();
- }
- ok = mSettingsManager->startMonitoring(keyguard);
- CX_DEBUG_ASSERT(ok);
-
- // Battery status (ok / low / empty)
- XQSettingsKey battery(XQSettingsKey::TargetPublishAndSubscribe,
- KPSUidHWRMPowerState.iUid,
- KHWRMBatteryStatus);
- value = mSettingsManager->readItemValue(battery);
- if (value == QVariant::Int) {
- mBatteryStatus = value.toInt();
- }
- ok = mSettingsManager->startMonitoring(battery);
- CX_DEBUG_ASSERT(ok);
-
- CX_DEBUG_EXIT_FUNCTION();
-}
-
-
-
-// ---------------------------------------------------------------------------
// CxuiViewManager::connectCaptureKeySignals
//
// ---------------------------------------------------------------------------
@@ -599,17 +492,17 @@
CX_DEBUG_ENTER_FUNCTION();
// Disconnect all existing capture key signals
- mKeyHandler.disconnect();
+ mKeyHandler->disconnect();
QObject *currentView = mMainWindow.currentView();
if (currentView) {
// If the view class does not implement the named slot, the connect will fail
// and output some warnings as debug prints. This is by design.
- connect(&mKeyHandler, SIGNAL(autofocusKeyPressed()), currentView, SLOT(handleAutofocusKeyPressed()));
- connect(&mKeyHandler, SIGNAL(autofocusKeyReleased()), currentView, SLOT(handleAutofocusKeyReleased()));
- connect(&mKeyHandler, SIGNAL(captureKeyPressed()), currentView, SLOT(handleCaptureKeyPressed()));
- connect(&mKeyHandler, SIGNAL(captureKeyReleased()), currentView, SLOT(handleCaptureKeyReleased()));
+ connect(mKeyHandler, SIGNAL(autofocusKeyPressed()), currentView, SLOT(handleAutofocusKeyPressed()));
+ connect(mKeyHandler, SIGNAL(autofocusKeyReleased()), currentView, SLOT(handleAutofocusKeyReleased()));
+ connect(mKeyHandler, SIGNAL(captureKeyPressed()), currentView, SLOT(handleCaptureKeyPressed()));
+ connect(mKeyHandler, SIGNAL(captureKeyReleased()), currentView, SLOT(handleCaptureKeyReleased()));
}
CX_DEBUG_EXIT_FUNCTION();
@@ -642,10 +535,12 @@
connect(this, SIGNAL(focusGained()), mStandbyHandler, SLOT(handleMouseEvent()), Qt::UniqueConnection);
// connecting key events to standby.
- connect(&mKeyHandler, SIGNAL(autofocusKeyPressed()), mStandbyHandler, SLOT(stopTimer()), Qt::UniqueConnection);
- connect(&mKeyHandler, SIGNAL(autofocusKeyReleased()), mStandbyHandler, SLOT(startTimer()), Qt::UniqueConnection);
- connect(&mKeyHandler, SIGNAL(captureKeyPressed()), mStandbyHandler, SLOT(startTimer()), Qt::UniqueConnection);
- connect(&mKeyHandler, SIGNAL(captureKeyReleased()), mStandbyHandler, SLOT(startTimer()), Qt::UniqueConnection);
+ connect(mKeyHandler, SIGNAL(autofocusKeyPressed()), mStandbyHandler, SLOT(stopTimer()), Qt::UniqueConnection);
+ connect(mKeyHandler, SIGNAL(autofocusKeyReleased()), mStandbyHandler, SLOT(startTimer()), Qt::UniqueConnection);
+ connect(mKeyHandler, SIGNAL(captureKeyPressed()), mStandbyHandler, SLOT(startTimer()), Qt::UniqueConnection);
+ connect(mKeyHandler, SIGNAL(captureKeyReleased()), mStandbyHandler, SLOT(startTimer()), Qt::UniqueConnection);
+ connect(this, SIGNAL(disableStandbyTimer()), mStandbyHandler, SLOT(stopTimer()), Qt::UniqueConnection);
+ connect(this, SIGNAL(startStandbyTimer()), mStandbyHandler, SLOT(startTimer()), Qt::UniqueConnection);
// connecting pre-capture view signals to standby.
connect(currentView, SIGNAL(startStandbyTimer()), mStandbyHandler, SLOT(startTimer()), Qt::UniqueConnection);
@@ -656,6 +551,10 @@
// connecting precapture view signals to viewmanager slots
connect(currentView, SIGNAL(changeToPostcaptureView()), this, SLOT(changeToPostcaptureView()), Qt::UniqueConnection);
connect(currentView, SIGNAL(changeToPrecaptureView()), this, SLOT(changeToPrecaptureView()), Qt::UniqueConnection);
+
+ //connecting scene modes signal
+ connect(currentView, SIGNAL(showScenesView()), this, SLOT(showScenesView()), Qt::UniqueConnection);
+
connect(currentView, SIGNAL(switchCamera()), this, SLOT(switchCamera()), Qt::UniqueConnection);
// connecting error signals from precapture view to errormanager.
@@ -679,6 +578,7 @@
QObject *currentView = mMainWindow.currentView();
if (currentView == mPostcaptureView) {
// connecting view manager focus events to pre-capture views
+ connect(this, SIGNAL(focusGained()), currentView, SLOT(startTimers()), Qt::UniqueConnection);
connect(this, SIGNAL(focusLost()), currentView, SLOT(handleFocusLost()), Qt::UniqueConnection);
connect(currentView, SIGNAL(changeToPrecaptureView()), mStandbyHandler, SLOT(startTimer()), Qt::UniqueConnection);
@@ -699,7 +599,7 @@
CX_DEBUG_ENTER_FUNCTION();
// Disconnect all existing capture key signals
- mKeyHandler.disconnect();
+ mKeyHandler->disconnect();
disconnect(SIGNAL(focusGained()));
disconnect(SIGNAL(focusLost()));
@@ -708,6 +608,40 @@
CX_DEBUG_EXIT_FUNCTION();
}
+/*!
+* Raise application to foreground if it's currently (fully) in background.
+*/
+void CxuiViewManager::toForeground()
+{
+ CX_DEBUG_ENTER_FUNCTION();
+
+ if (mApplicationMonitor
+ && mApplicationMonitor->foregroundState() == CxuiApplicationFrameworkMonitor::ForegroundFullyLost) {
+ // Bring to foreground and gain focus.
+ CX_DEBUG(("CxuiViewManager - fully in background, bringing to foreground now."));
+ mMainWindow.raise();
+ mMainWindow.activateWindow();
+ }
+
+ CX_DEBUG_EXIT_FUNCTION();
+}
+
+/*!
+* Handle change in foreground state.
+*/
+void CxuiViewManager::handleForegroundStateChanged(CxuiApplicationFrameworkMonitor::ForegroundState state)
+{
+ switch (state) {
+ case CxuiApplicationFrameworkMonitor::ForegroundPartiallyLost:
+ break;
+ case CxuiApplicationFrameworkMonitor::ForegroundFullyLost:
+ aboutToLooseFocus();
+ break;
+ case CxuiApplicationFrameworkMonitor::ForegroundOwned:
+ aboutToGainFocus();
+ break;
+ }
+}
// ---------------------------------------------------------------------------
// CxuiViewManager::aboutToLooseFocus()
@@ -721,6 +655,10 @@
emit focusLost();
disconnectSignals();
+ // We do not stop listening to capture key events even if we go to background,
+ // as capture key brings us back to foreground.
+ connect(mKeyHandler, SIGNAL(captureKeyPressed()), this, SLOT(toForeground()));
+
CX_DEBUG_EXIT_FUNCTION();
}
@@ -734,6 +672,9 @@
{
CX_DEBUG_ENTER_FUNCTION();
+ // Disconnect capture key event and bringing us to foreground connection (if there is one).
+ disconnect(mKeyHandler, SIGNAL(captureKeyPressed()), this, SLOT(toForeground()));
+
// we are getting the focus.
if (mMainWindow.currentView() != mPostcaptureView) {
connectPreCaptureSignals();
@@ -741,68 +682,21 @@
connectPostCaptureSignals();
}
+ if (mKeyHandler) {
+ mKeyHandler->listenKeys(true);
+ }
emit focusGained();
CX_DEBUG_EXIT_FUNCTION();
}
-
-// ---------------------------------------------------------------------------
-// CxuiViewManager::eventMonitor
-//
-// ---------------------------------------------------------------------------
-//
-void CxuiViewManager::eventMonitor( const XQSettingsKey& key, const QVariant& value )
+/*!
+* Handle battery emptying
+*/
+void CxuiViewManager::handleBatteryEmpty()
{
CX_DEBUG_ENTER_FUNCTION();
-
- if (key.uid() == KPSUidAvkonDomain.iUid && key.key() == KAknKeyguardStatus) {
- CX_DEBUG(("new Keyguard value = %d, mKeyLockState = %d", value.toInt(), mKeyLockState));
- if (mSettingsManager->error() == XQSettingsManager::NoError) {
- // New key guard state
- int newKeyLockState = value.toInt();
-
- // Check if the keylock value has actually changed
- bool keylockValueChanged = (newKeyLockState != mKeyLockState);
- mKeyLockState = newKeyLockState;
-
- // Ignore unlock events when on background
- bool unlockedOnBackground = (!mFocused && newKeyLockState == EKeyguardNotActive);
-
- if (keylockValueChanged &&
- !unlockedOnBackground) {
- // Key lock value changed and we need to handle it
- if (mKeyLockState == EKeyguardNotActive) {
- // All other keylock states are handled as a active in S60 code
- aboutToGainFocus();
- } else {
- mFocused = false;
- aboutToLooseFocus();
- }
- }
- } else {
- // Error from settings manager - ignore
- CX_DEBUG(("mSettingsManager indicated error %d for key guard status", mSettingsManager->error()));
- }
- } else if (key.uid() == KPSUidHWRMPowerState.iUid && key.key() == KHWRMBatteryStatus ) {
- CX_DEBUG(("new battery status = %d, mBatteryStatus = %d", value.toInt(), mBatteryStatus));
-
- if (mSettingsManager->error() == XQSettingsManager::NoError) {
-
- // If status changed, check if battery is going empty.
- const int newState = value.toInt();
- if( newState != mBatteryStatus ) {
- mBatteryStatus = newState;
-
- // Notify that battery is almost empty,
- // need to stop any recordings etc.
- if( mBatteryStatus == EBatteryStatusEmpty ) {
- emit batteryEmpty();
- }
- }
- }
- }
-
+ emit batteryEmpty();
CX_DEBUG_EXIT_FUNCTION();
}