author | hgs |
Fri, 17 Sep 2010 16:35:28 +0300 | |
changeset 58 | ddba9caa7f32 |
parent 52 | 7e18d488ac5f |
child 64 | 8ab66fc302e6 |
permissions | -rw-r--r-- |
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1 |
/* |
28 | 2 |
* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). |
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
3 |
* All rights reserved. |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
4 |
* This component and the accompanying materials are made available |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
5 |
* under the terms of "Eclipse Public License v1.0" |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
6 |
* which accompanies this distribution, and is available |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html". |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
8 |
* |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
9 |
* Initial Contributors: |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
10 |
* Nokia Corporation - initial contribution. |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
11 |
* |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
12 |
* Contributors: |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
13 |
* |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
14 |
* Description: |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
15 |
* |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
16 |
*/ |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
17 |
#include <QDebug> |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
18 |
#include <QTimer> |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
19 |
#include <hbmainwindow.h> |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
20 |
#include <QGraphicsSceneEvent> |
38 | 21 |
#include <hbstyleloader.h> |
58 | 22 |
#include <afactivitystorage.h> |
23 |
#include <afactivation.h> |
|
41 | 24 |
#include <hbaction.h> |
46 | 25 |
#include <xqserviceutil.h> |
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
26 |
|
28 | 27 |
#include "cxuiapplication.h" |
41 | 28 |
#include "cxuiapplicationstate.h" |
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
29 |
#include "cxuiviewmanager.h" |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
30 |
#include "cxuivideoprecaptureview.h" |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
31 |
#include "cxuistillprecaptureview.h" |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
32 |
#include "cxuipostcaptureview.h" |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
33 |
#include "cxuicapturekeyhandler.h" |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
34 |
#include "cxeengine.h" |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
35 |
#include "cxecameradevicecontrol.h" |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
36 |
#include "cxefeaturemanager.h" // mEngine->featureManager() |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
37 |
#include "cxeviewfindercontrol.h" |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
38 |
#include "cxenamespace.h" |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
39 |
#include "cxuienums.h" |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
40 |
#include "cxutils.h" |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
41 |
#include "cxuidocumentloader.h" |
28 | 42 |
#include "cxesettings.h" |
43 |
#include "cxememorymonitor.h" |
|
44 |
#include "cxuiserviceprovider.h" |
|
45 |
#include "cxuiscenemodeview.h" |
|
46 |
||
42 | 47 |
|
48 |
#ifdef Q_OS_SYMBIAN |
|
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
49 |
#include "OstTraceDefinitions.h" |
42 | 50 |
|
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
51 |
#ifdef OST_TRACE_COMPILER_IN_USE |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
52 |
#include "cxuiviewmanagerTraces.h" |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
53 |
#endif |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
54 |
|
42 | 55 |
#endif //Q_OS_SYMBIAN |
56 |
||
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
57 |
|
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
58 |
using namespace Cxe; |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
59 |
using namespace CxUiLayout; |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
60 |
|
41 | 61 |
namespace |
62 |
{ |
|
63 |
static const int CXUI_STANDBY_CAMERA_TIMEOUT = 60000; // 60 seconds |
|
64 |
} |
|
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
65 |
|
41 | 66 |
|
67 |
/*! |
|
68 |
* Constructor. |
|
69 |
*/ |
|
28 | 70 |
CxuiViewManager::CxuiViewManager(CxuiApplication &application, HbMainWindow &mainWindow, CxeEngine &engine) : |
71 |
mApplication(application), |
|
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
72 |
mMainWindow(mainWindow), |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
73 |
mEngine(engine), |
28 | 74 |
mKeyHandler(NULL), |
75 |
mCameraDocumentLoader(NULL), |
|
41 | 76 |
mApplicationState(NULL), |
42 | 77 |
mErrorManager(NULL) |
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
78 |
{ |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
79 |
CX_DEBUG_ENTER_FUNCTION(); |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
80 |
|
41 | 81 |
// create mappings to map view name to correct docml file |
82 |
mDocmlFilesByView.insert(STILL_PRE_CAPTURE_VIEW, STILL_1ST_XML); |
|
83 |
mDocmlFilesByView.insert(VIDEO_PRE_CAPTURE_VIEW, VIDEO_1ST_XML); |
|
84 |
mDocmlFilesByView.insert(POSTCAPTURE_VIEW, POSTCAPTURE_XML); |
|
42 | 85 |
mDocmlFilesByView.insert(SCENE_MODE_VIEW, SCENEMODE_SETTING_XML); |
28 | 86 |
|
87 |
// Key handler |
|
88 |
mKeyHandler = new CxuiCaptureKeyHandler(mEngine); |
|
89 |
||
41 | 90 |
// Document loader |
42 | 91 |
OstTrace0(camerax_performance, CXUIVIEWMANAGER_CXUIVIEWMANAGER_1, "msg: e_CX_VIEWMANAGER_CREATE_DOCLOADER 1"); |
28 | 92 |
mCameraDocumentLoader = new CxuiDocumentLoader(&engine); |
42 | 93 |
OstTrace0(camerax_performance, CXUIVIEWMANAGER_CXUIVIEWMANAGER_2, "msg: e_CX_VIEWMANAGER_CREATE_DOCLOADER 0"); |
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
94 |
|
41 | 95 |
// Application state |
42 | 96 |
mApplicationState = new CxuiApplicationState(mApplication, mEngine.settings(), mCameraDocumentLoader); |
41 | 97 |
CX_ASSERT_ALWAYS(mApplicationState); |
98 |
bool ok = connect(mApplicationState, SIGNAL(stateChanged(CxuiApplicationState::State, CxuiApplicationState::State)), |
|
99 |
this, SLOT(handleApplicationStateChanged(CxuiApplicationState::State, CxuiApplicationState::State))); |
|
100 |
Q_ASSERT_X(ok, "CxuiViewManager", "Application state change signal connect failed."); |
|
101 |
connect(this, SIGNAL(standbyExitRequested()), mApplicationState, SLOT(exitStandby()), Qt::QueuedConnection); |
|
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
102 |
|
41 | 103 |
// Standby timer |
104 |
mStandbyTimer.setInterval(CXUI_STANDBY_CAMERA_TIMEOUT); |
|
105 |
mStandbyTimer.setSingleShot(true); |
|
106 |
connect(&mStandbyTimer, SIGNAL(timeout()), mApplicationState, SLOT(enterStandby())); |
|
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
107 |
|
41 | 108 |
// Filter capture and AF keys and follow user activity from mouse events. |
109 |
QCoreApplication::instance()->installEventFilter(this); |
|
110 |
||
111 |
// Monitor memory on normal state, not on standby, error or background. |
|
112 |
connect(this, SIGNAL(normalStateEntered()), &mEngine.memoryMonitor(), SLOT(startMonitoring())); |
|
113 |
connect(this, SIGNAL(normalStateExited()), &mEngine.memoryMonitor(), SLOT(stopMonitoring())); |
|
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
114 |
|
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
115 |
//connecting initmode signals |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
116 |
connect(&mEngine.cameraDeviceControl(), SIGNAL(initModeComplete(CxeError::Id)), |
41 | 117 |
mApplicationState, SLOT(handleApplicationError(CxeError::Id))); |
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
118 |
|
28 | 119 |
connect(&mEngine.stillCaptureControl(), SIGNAL(imageCaptured(CxeError::Id, int)), |
41 | 120 |
mApplicationState, SLOT(handleApplicationError(CxeError::Id))); |
28 | 121 |
|
38 | 122 |
// Register stylesheet. It will be automatically destroyed on application |
123 |
// exit. |
|
124 |
HbStyleLoader::registerFilePath(":/camerax/cxui.css"); |
|
125 |
||
40 | 126 |
// Create the view we are starting in, or connect signals so it |
127 |
// will be created once we know the mode we are starting to. |
|
128 |
initStartupView(); |
|
129 |
||
41 | 130 |
// For UI startup testing, we need to emit applicationReady signal once UI is ready to be used. |
131 |
connect(mMainWindow.currentView(), SIGNAL(viewReady()), &mApplication, SIGNAL(applicationReady())); |
|
132 |
||
133 |
CX_DEBUG_EXIT_FUNCTION(); |
|
134 |
} |
|
135 |
||
136 |
||
137 |
/*! |
|
138 |
* Destructor. |
|
139 |
*/ |
|
140 |
CxuiViewManager::~CxuiViewManager() |
|
141 |
{ |
|
142 |
CX_DEBUG_ENTER_FUNCTION(); |
|
143 |
QCoreApplication::instance()->removeEventFilter(this); |
|
144 |
||
145 |
if (!CxuiServiceProvider::isCameraEmbedded()) { |
|
146 |
currentView()->saveActivity(); |
|
147 |
} |
|
148 |
||
149 |
delete mApplicationState; |
|
150 |
delete mCameraDocumentLoader; |
|
151 |
delete mKeyHandler; |
|
152 |
||
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
153 |
CX_DEBUG_EXIT_FUNCTION(); |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
154 |
} |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
155 |
|
41 | 156 |
|
157 |
||
158 |
/*! |
|
159 |
* Handle change in overall state of application. |
|
160 |
* @param newState The new application state. |
|
161 |
*/ |
|
162 |
void CxuiViewManager::handleApplicationStateChanged(CxuiApplicationState::State newState, |
|
163 |
CxuiApplicationState::State oldState) |
|
164 |
{ |
|
165 |
Q_UNUSED(oldState); |
|
166 |
CX_DEBUG_ENTER_FUNCTION(); |
|
167 |
||
46 | 168 |
CxuiView *view = currentView(); |
41 | 169 |
CX_DEBUG(("CxuiViewManager - current view %d", view)); |
170 |
||
171 |
switch (newState) { |
|
172 |
case CxuiApplicationState::Normal: |
|
52 | 173 |
// If camera is in embedded mode, we need to start |
174 |
// listening to key events again |
|
175 |
if (CxuiServiceProvider::isCameraEmbedded()){ |
|
176 |
mKeyHandler->startListeningKeys(); |
|
177 |
} else { |
|
178 |
// If in standalone mode, we disable raising to |
|
179 |
// foreground with capture key. |
|
180 |
disconnect(mKeyHandler, SIGNAL(captureKeyPressed()), |
|
181 |
this, SLOT(toForeground())); |
|
182 |
} |
|
41 | 183 |
connectSignals(view); |
184 |
||
185 |
CX_DEBUG(("CxuiViewManager - emitting normalStateEntered")); |
|
186 |
emit normalStateEntered(); |
|
187 |
break; |
|
188 |
case CxuiApplicationState::Standby: |
|
189 |
if (view && !view->isStandbyModeSupported()) { |
|
190 |
// If we move to Stanby, and current view does not |
|
191 |
// support standby mode, move to Normal mode right away. |
|
192 |
CX_DEBUG(("CxuiViewManager - view does not support stanbdy, exiting standby right away..")); |
|
193 |
mApplicationState->exitStandby(); |
|
194 |
} else { |
|
195 |
handleExitingNormalState(); |
|
196 |
} |
|
197 |
break; |
|
198 |
case CxuiApplicationState::Error: |
|
199 |
case CxuiApplicationState::Background: |
|
200 |
handleExitingNormalState(); |
|
201 |
||
202 |
if (newState == CxuiApplicationState::Background) { |
|
203 |
// Moved to background. |
|
52 | 204 |
// If we're in embedded mode, we should stop listening to camera key |
205 |
// events |
|
206 |
if (CxuiServiceProvider::isCameraEmbedded()){ |
|
207 |
mKeyHandler->stopListeningKeys(); |
|
208 |
} else { |
|
209 |
// If not in embedded mode, then we bring application back to |
|
210 |
// foreground by capture key press |
|
211 |
connect(mKeyHandler, SIGNAL(captureKeyPressed()), |
|
212 |
this, SLOT(toForeground())); |
|
213 |
} |
|
41 | 214 |
} |
215 |
break; |
|
216 |
} |
|
217 |
||
218 |
CX_DEBUG_EXIT_FUNCTION(); |
|
219 |
} |
|
220 |
||
221 |
/*! |
|
222 |
* Helper method to handle (possible) exiting from normal state. |
|
223 |
* @param oldState The previous state. |
|
224 |
*/ |
|
225 |
void CxuiViewManager::handleExitingNormalState() |
|
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
226 |
{ |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
227 |
CX_DEBUG_ENTER_FUNCTION(); |
41 | 228 |
// Store view that is active now. |
46 | 229 |
CxuiView *view = currentView(); |
41 | 230 |
CX_DEBUG(("CxuiViewManager - current view %d", view)); |
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
231 |
|
41 | 232 |
// Emit signal so current view can enter standby. |
233 |
emit normalStateExited(); |
|
234 |
// Disconnect signals so we don't send key event's etc. |
|
235 |
// Using the view before normalStateExited() signal was emitted, |
|
236 |
// just in case it caused view switch. |
|
237 |
disconnectSignals(view); |
|
238 |
// Make sure standby timer is not running. |
|
239 |
stopStandbyTimer(); |
|
42 | 240 |
|
41 | 241 |
CX_DEBUG_EXIT_FUNCTION(); |
242 |
} |
|
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
243 |
|
41 | 244 |
/*! |
245 |
* Slot for starting standby timer. |
|
246 |
*/ |
|
247 |
void CxuiViewManager::startStandbyTimer() |
|
248 |
{ |
|
249 |
CX_DEBUG_ENTER_FUNCTION(); |
|
250 |
mStandbyTimer.start(); |
|
251 |
CX_DEBUG_EXIT_FUNCTION(); |
|
252 |
} |
|
253 |
||
254 |
/*! |
|
255 |
* Slot for stopping standby timer. |
|
256 |
*/ |
|
257 |
void CxuiViewManager::stopStandbyTimer() |
|
258 |
{ |
|
259 |
CX_DEBUG_ENTER_FUNCTION(); |
|
260 |
mStandbyTimer.stop(); |
|
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
261 |
CX_DEBUG_EXIT_FUNCTION(); |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
262 |
} |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
263 |
|
40 | 264 |
/*! |
41 | 265 |
* Helper function to return current view cast to CxuiView. |
266 |
*/ |
|
267 |
CxuiView* CxuiViewManager::currentView() const |
|
40 | 268 |
{ |
41 | 269 |
CxuiView *view = qobject_cast<CxuiView*> (mMainWindow.currentView()); |
270 |
return view; |
|
40 | 271 |
} |
272 |
||
273 |
/*! |
|
274 |
* Select and initialize the view we need to start into. |
|
275 |
*/ |
|
276 |
void CxuiViewManager::initStartupView() |
|
277 |
{ |
|
278 |
CX_DEBUG_ENTER_FUNCTION(); |
|
279 |
||
58 | 280 |
AfActivation activation; |
281 |
AfActivityStorage activityStorage; |
|
282 |
if (activation.reason() == Hb::ActivationReasonService || |
|
46 | 283 |
// @todo: There's a bug in orbit and we never get Hb::ActivationReasonService as |
284 |
// activation reason. Use XQServiceUtil to determine if starting service as |
|
285 |
// a workaround for now |
|
286 |
XQServiceUtil::isService()) { |
|
287 |
||
40 | 288 |
// For embedded mode: don't create view yet, create when engine inits to correct mode. |
289 |
// Connect signals to set up the view after image/video prepare |
|
290 |
connect(&mEngine.stillCaptureControl(), SIGNAL(imagePrepareComplete(CxeError::Id)), |
|
291 |
this, SLOT(changeToPrecaptureView())); |
|
292 |
connect(&mEngine.videoCaptureControl(), SIGNAL(videoPrepareComplete(CxeError::Id)), |
|
293 |
this, SLOT(changeToPrecaptureView())); |
|
294 |
||
58 | 295 |
} else if (activation.reason() == Hb::ActivationReasonActivity) { |
41 | 296 |
// restoring activity, read startup view from stored activity |
297 |
||
298 |
// view to start in |
|
299 |
QString viewName = STILL_PRE_CAPTURE_VIEW; |
|
300 |
||
301 |
bool preCapture = true; |
|
58 | 302 |
QString activityId = activation.name(); |
41 | 303 |
if (activityId == CxuiActivityIds::STILL_PRECAPTURE_ACTIVITY) { |
304 |
viewName = STILL_PRE_CAPTURE_VIEW; |
|
305 |
} else if (activityId == CxuiActivityIds::STILL_POSTCAPTURE_ACTIVITY) { |
|
306 |
viewName = POSTCAPTURE_VIEW; |
|
307 |
preCapture = false; |
|
308 |
} else if (activityId == CxuiActivityIds::VIDEO_PRECAPTURE_ACTIVITY) { |
|
309 |
viewName = VIDEO_PRE_CAPTURE_VIEW; |
|
310 |
} else if (activityId == CxuiActivityIds::VIDEO_POSTCAPTURE_ACTIVITY) { |
|
311 |
viewName = POSTCAPTURE_VIEW; |
|
312 |
preCapture = false; |
|
313 |
} |
|
314 |
||
315 |
CxuiView *view = createView(viewName); |
|
316 |
if (preCapture) { |
|
46 | 317 |
connectPreCaptureSignals(static_cast<CxuiPrecaptureView *>(view)); |
41 | 318 |
} else { |
319 |
connectPostCaptureSignals(); |
|
320 |
} |
|
46 | 321 |
mMainWindow.setCurrentView(view, false); |
41 | 322 |
|
323 |
// restore view from activity |
|
58 | 324 |
view->restoreActivity(activityId, activityStorage.activityData(activityId)); |
41 | 325 |
|
326 |
clearAllActivities(); |
|
327 |
} else { |
|
328 |
// normal start |
|
329 |
// no activity id, get default view from engine state |
|
330 |
CxuiView *view = NULL; |
|
331 |
if (mEngine.mode() == Cxe::VideoMode) { |
|
332 |
view = createView(VIDEO_PRE_CAPTURE_VIEW); |
|
333 |
} else { |
|
334 |
view = createView(STILL_PRE_CAPTURE_VIEW); |
|
335 |
} |
|
46 | 336 |
connectPreCaptureSignals(static_cast<CxuiPrecaptureView *>(view)); |
41 | 337 |
mMainWindow.setCurrentView(view, false); |
338 |
||
339 |
clearAllActivities(); |
|
40 | 340 |
} |
341 |
||
46 | 342 |
// Check the current application state, signalled to handleApplicationStateChanged. |
343 |
mApplicationState->startMonitoring(); |
|
344 |
||
40 | 345 |
CX_DEBUG_EXIT_FUNCTION(); |
346 |
} |
|
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
347 |
|
41 | 348 |
/*! |
349 |
* Create view and add it to main window. |
|
350 |
*/ |
|
351 |
CxuiView* CxuiViewManager::createView(const QString &viewName) |
|
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
352 |
{ |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
353 |
CX_DEBUG_ENTER_FUNCTION(); |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
354 |
|
42 | 355 |
OstTrace0(camerax_performance, CXUIVIEWMANAGER_CREATEVIEW_IN, "msg: e_CX_CREATE_VIEW 1"); |
41 | 356 |
|
357 |
CX_DEBUG(("View name: %s", viewName.toAscii().data())); |
|
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
358 |
|
41 | 359 |
CxuiView* view = mViews[viewName]; |
360 |
if (view == NULL) { |
|
361 |
CX_DEBUG(("View not loaded yet, loading now")); |
|
362 |
bool ok = false; |
|
363 |
// Use document loader to create widgets and layouts |
|
364 |
// (non-sectioned parts are parsed and loaded) |
|
365 |
QString docmlFile = mDocmlFilesByView[viewName]; |
|
42 | 366 |
CX_ASSERT_ALWAYS(mCameraDocumentLoader); |
41 | 367 |
CX_ASSERT_ALWAYS(!docmlFile.isNull()); |
368 |
||
42 | 369 |
OstTrace0(camerax_performance, CXUIVIEWMANAGER_CREATEVIEW_2, "msg: e_CX_DOCUMENTLOADER_LOAD 1"); |
41 | 370 |
mCameraDocumentLoader->load(docmlFile, &ok); |
42 | 371 |
OstTrace0(camerax_performance, CXUIVIEWMANAGER_CREATEVIEW_4, "msg: e_CX_DOCUMENTLOADER_LOAD 0"); |
41 | 372 |
Q_ASSERT_X(ok, "createView", "error in xml file parsing"); |
373 |
||
42 | 374 |
OstTrace0(camerax_performance, CXUIVIEWMANAGER_CREATEVIEW_6, "msg: e_CX_DOCUMENTLOADER_FINDWIDGET 1"); |
41 | 375 |
QGraphicsWidget *widget = NULL; |
376 |
// ask for the view widget pointer |
|
377 |
widget = mCameraDocumentLoader->findWidget(viewName); |
|
378 |
view = qobject_cast<CxuiView *> (widget); |
|
42 | 379 |
CX_ASSERT_ALWAYS(view); |
380 |
OstTrace0(camerax_performance, CXUIVIEWMANAGER_CREATEVIEW_8, "msg: e_CX_DOCUMENTLOADER_FINDWIDGET 1"); |
|
41 | 381 |
|
382 |
// call for needed consturction methods |
|
58 | 383 |
view->construct(&mMainWindow, &mEngine, mCameraDocumentLoader, mKeyHandler); |
41 | 384 |
// .. and add to main window (which also takes ownership) |
42 | 385 |
OstTrace0(camerax_performance, CXUIVIEWMANAGER_CREATEVIEW_10, "msg: e_CX_MAINWINDOW_ADDVIEW 1"); |
41 | 386 |
mMainWindow.addView(view); |
387 |
mViews.insert(viewName, view); |
|
42 | 388 |
OstTrace0(camerax_performance, CXUIVIEWMANAGER_CREATEVIEW_12, "msg: e_CX_MAINWINDOW_ADDVIEW 0"); |
389 |
} |
|
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
390 |
|
42 | 391 |
OstTrace0(camerax_performance, CXUIVIEWMANAGER_CREATEVIEW_OUT, "msg: e_CX_CREATE_VIEW 0"); |
41 | 392 |
|
393 |
CX_DEBUG_EXIT_FUNCTION(); |
|
394 |
return view; |
|
395 |
} |
|
396 |
||
397 |
/*! |
|
28 | 398 |
* CxuiViewManager::showScenesView |
399 |
* A private method for displaying Scene Modes selection view |
|
400 |
*/ |
|
401 |
void CxuiViewManager::showScenesView() |
|
402 |
{ |
|
403 |
CX_DEBUG_ENTER_FUNCTION(); |
|
41 | 404 |
// Disconnect signals from old view. |
405 |
disconnectSignals(); |
|
406 |
||
42 | 407 |
CxuiSceneModeView *view = qobject_cast<CxuiSceneModeView*>(createView(SCENE_MODE_VIEW)); |
408 |
CX_ASSERT_ALWAYS(view); |
|
409 |
view->loadBackgroundImages(); |
|
410 |
||
41 | 411 |
stopStandbyTimer(); |
412 |
connectSceneModeSignals(); |
|
46 | 413 |
mMainWindow.setCurrentView(view, false); |
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
414 |
|
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
415 |
CX_DEBUG_EXIT_FUNCTION(); |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
416 |
} |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
417 |
|
41 | 418 |
/*! |
419 |
* Get the precapture view appropriate for given camera mode and index. |
|
420 |
* If the view does not exist, it is created. |
|
421 |
* @param mode Which camera mode the view should match. |
|
422 |
* @param index Which camera index the view should match. |
|
423 |
*/ |
|
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
424 |
CxuiPrecaptureView* |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
425 |
CxuiViewManager::getPrecaptureView(Cxe::CameraMode mode, Cxe::CameraIndex camera) |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
426 |
{ |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
427 |
CX_DEBUG_ENTER_FUNCTION(); |
41 | 428 |
CX_DEBUG(("CxuiViewManager::getPrecaptureView - mode=%d, camera index=%d", mode, camera)); |
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
429 |
|
28 | 430 |
CX_DEBUG_ASSERT(camera == Cxe::PrimaryCameraIndex); |
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
431 |
|
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
432 |
if (mode == ImageMode) { |
41 | 433 |
CX_DEBUG(("CxuiViewManager::getPrecaptureView - image mode")); |
434 |
return qobject_cast<CxuiPrecaptureView*>(createView(STILL_PRE_CAPTURE_VIEW)); |
|
435 |
||
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
436 |
} else { |
41 | 437 |
CX_DEBUG(("CxuiViewManager::getPrecaptureView - video mode")); |
438 |
return qobject_cast<CxuiPrecaptureView*>(createView(VIDEO_PRE_CAPTURE_VIEW)); |
|
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
439 |
} |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
440 |
} |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
441 |
|
41 | 442 |
/*! |
443 |
* Move to post-capture view. |
|
444 |
*/ |
|
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
445 |
void CxuiViewManager::changeToPostcaptureView() |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
446 |
{ |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
447 |
CX_DEBUG_ENTER_FUNCTION(); |
41 | 448 |
// Disconnect signals from old view. |
449 |
disconnectSignals(); |
|
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
450 |
|
41 | 451 |
CxuiView *postCaptureView = createView(POSTCAPTURE_VIEW); |
452 |
||
453 |
// Connecting all necessary signals for postcapture view. |
|
454 |
// Not connected yet if not in normal state. We connect the signals |
|
455 |
// once we enter normal state again. |
|
456 |
if (mApplicationState->currentState() == CxuiApplicationState::Normal) { |
|
457 |
connectPostCaptureSignals(); |
|
458 |
} |
|
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
459 |
|
46 | 460 |
// Connect signals before we set the post-capture view as current view. |
461 |
// We need to have signals connected if post-capture view for example |
|
462 |
// needs to move back to pre-capture view already in showEvent. |
|
463 |
mMainWindow.setCurrentView(postCaptureView, false); |
|
464 |
||
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
465 |
CX_DEBUG_EXIT_FUNCTION(); |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
466 |
} |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
467 |
|
41 | 468 |
/*! |
469 |
* Move to pre-capture view. |
|
470 |
*/ |
|
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
471 |
void CxuiViewManager::changeToPrecaptureView() |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
472 |
{ |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
473 |
CX_DEBUG_ENTER_FUNCTION(); |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
474 |
|
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
475 |
if (CxuiServiceProvider::isCameraEmbedded()) { |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
476 |
// disconnect signals, we only want to call this once after the initial prepare |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
477 |
disconnect(&mEngine.stillCaptureControl(), SIGNAL(imagePrepareComplete(CxeError::Id)), |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
478 |
this, SLOT(changeToPrecaptureView())); |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
479 |
disconnect(&mEngine.videoCaptureControl(), SIGNAL(videoPrepareComplete(CxeError::Id)), |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
480 |
this, SLOT(changeToPrecaptureView())); |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
481 |
} |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
482 |
|
41 | 483 |
// If normal mode is not active, don't switch to precapture view and reserve camera now. |
484 |
if (mApplicationState->currentState() != CxuiApplicationState::Normal) { |
|
485 |
CX_DEBUG(("CxuiViewManager - Change to precapture blocked as not normal mode (error, standby, background).")); |
|
40 | 486 |
} else { |
41 | 487 |
|
488 |
// Disconnect signals from old view. |
|
489 |
disconnectSignals(); |
|
490 |
||
46 | 491 |
CxuiPrecaptureView *view = |
492 |
getPrecaptureView(mEngine.mode(), mEngine.cameraDeviceControl().cameraIndex()); |
|
493 |
||
494 |
// Connect necessary pre-capture view signals. |
|
495 |
connectPreCaptureSignals(view); |
|
496 |
||
40 | 497 |
mMainWindow.setCurrentView(view, false); |
498 |
||
42 | 499 |
// Release resources needed by scene view. |
500 |
HbView *sceneView = mViews.take(SCENE_MODE_VIEW); |
|
501 |
if (sceneView) { |
|
502 |
// This will not delete the view. |
|
503 |
mMainWindow.removeView(sceneView); |
|
504 |
// We can get to this slot from scene view, so don't delete the object too early. |
|
505 |
sceneView->deleteLater(); |
|
506 |
sceneView = NULL; |
|
40 | 507 |
} |
42 | 508 |
|
41 | 509 |
// Make sure engine prepares for new image/video if necessary |
510 |
mEngine.initMode(mEngine.mode()); |
|
511 |
||
512 |
startStandbyTimer(); |
|
513 |
||
38 | 514 |
} |
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
515 |
CX_DEBUG_EXIT_FUNCTION(); |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
516 |
} |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
517 |
|
41 | 518 |
/*! |
519 |
* Switch between cameras. |
|
520 |
*/ |
|
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
521 |
void CxuiViewManager::switchCamera() |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
522 |
{ |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
523 |
CX_DEBUG_ENTER_FUNCTION(); |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
524 |
|
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
525 |
Cxe::CameraIndex nextCamera; |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
526 |
Qt::Orientation nextViewOrientation; |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
527 |
|
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
528 |
if (mEngine.cameraDeviceControl().cameraIndex() == Cxe::PrimaryCameraIndex) { |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
529 |
nextCamera = Cxe::SecondaryCameraIndex; |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
530 |
nextViewOrientation = Qt::Vertical; |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
531 |
} else { |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
532 |
nextCamera = Cxe::PrimaryCameraIndex; |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
533 |
nextViewOrientation = Qt::Horizontal; |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
534 |
} |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
535 |
|
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
536 |
CxuiPrecaptureView* view = getPrecaptureView(mEngine.mode(), nextCamera); |
46 | 537 |
connectPreCaptureSignals(view); |
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
538 |
mMainWindow.setCurrentView(view, false); |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
539 |
view->updateOrientation(nextViewOrientation); |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
540 |
|
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
541 |
mEngine.cameraDeviceControl().switchCamera(nextCamera); |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
542 |
|
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
543 |
CX_DEBUG_EXIT_FUNCTION(); |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
544 |
} |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
545 |
|
41 | 546 |
/*! |
547 |
* Event filter function. |
|
548 |
* Used to get mouse and key events for standby and capture key handling. |
|
549 |
* @param object Target object. |
|
550 |
* @param event Event to be checked. |
|
551 |
*/ |
|
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
552 |
bool CxuiViewManager::eventFilter(QObject *object, QEvent *event) |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
553 |
{ |
28 | 554 |
Q_UNUSED(object) |
555 |
||
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
556 |
bool eventWasConsumed = false; |
41 | 557 |
bool userActivity = false; |
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
558 |
|
41 | 559 |
switch (event->type()) { |
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
560 |
case QEvent::KeyPress: |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
561 |
case QEvent::KeyRelease: |
41 | 562 |
userActivity = true; |
28 | 563 |
eventWasConsumed = mKeyHandler->handleKeyEvent(event); |
41 | 564 |
if (eventWasConsumed && mApplicationState->currentState() == CxuiApplicationState::Standby) { |
565 |
// Queued exit from standby. |
|
566 |
emit standbyExitRequested(); |
|
567 |
} |
|
568 |
break; |
|
569 |
||
570 |
case QEvent::GraphicsSceneMouseMove: |
|
571 |
case QEvent::GraphicsSceneMousePress: |
|
572 |
userActivity = true; |
|
573 |
break; |
|
574 |
case QEvent::GraphicsSceneMouseRelease: |
|
575 |
userActivity = true; |
|
576 |
if (mApplicationState->currentState() == CxuiApplicationState::Standby) { |
|
577 |
// Queued exit from standby. |
|
578 |
// Standby popup in view can receive mouse event before it is dismissed. |
|
579 |
emit standbyExitRequested(); |
|
580 |
} |
|
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
581 |
break; |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
582 |
} |
41 | 583 |
|
584 |
// Restart standby timer if there is user activity. |
|
585 |
// Only restart the timer if it is running, do not set it running here. |
|
586 |
if (userActivity && mStandbyTimer.isActive()) { |
|
587 |
startStandbyTimer(); |
|
588 |
} |
|
589 |
||
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
590 |
// No need to call base class implementation, because we derive from QObject directly. |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
591 |
// QObject::eventFilter() implementation always returns false. |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
592 |
return eventWasConsumed; |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
593 |
} |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
594 |
|
41 | 595 |
/*! |
596 |
* Connect signals specific to given view. |
|
597 |
*/ |
|
46 | 598 |
void CxuiViewManager::connectSignals(CxuiView *view) |
41 | 599 |
{ |
600 |
CX_DEBUG_ENTER_FUNCTION(); |
|
42 | 601 |
OstTrace0(camerax_performance, CXUIVIEWMANAGER_CONNECTSIGNALS_1, "msg: e_CX_VIEWMANAGER_CONNECT_SIGNALS 1"); |
602 |
||
41 | 603 |
if (view) { |
604 |
if (view == mViews[POSTCAPTURE_VIEW]) { |
|
605 |
connectPostCaptureSignals(); |
|
42 | 606 |
} else if (view == mViews[SCENE_MODE_VIEW]) { |
41 | 607 |
connectSceneModeSignals(); |
608 |
} else { |
|
46 | 609 |
connectPreCaptureSignals(static_cast<CxuiPrecaptureView *>(view)); |
41 | 610 |
} |
611 |
} |
|
42 | 612 |
|
613 |
OstTrace0(camerax_performance, CXUIVIEWMANAGER_CONNECTSIGNALS_2, "msg: e_CX_VIEWMANAGER_CONNECT_SIGNALS 0"); |
|
41 | 614 |
CX_DEBUG_EXIT_FUNCTION(); |
615 |
} |
|
616 |
||
617 |
/*! |
|
618 |
* Disconnect signals. |
|
619 |
* We don't want to send or receive signals with inactive views, so this is done every time changing a view. |
|
620 |
* @param view View object from which signals are disconnected. If NULL is given, current view is used. |
|
621 |
*/ |
|
46 | 622 |
void CxuiViewManager::disconnectSignals(CxuiView *view) |
41 | 623 |
{ |
624 |
CX_DEBUG_ENTER_FUNCTION(); |
|
42 | 625 |
OstTrace0(camerax_performance, CXUIVIEWMANAGER_DISCONNECT_1, "msg: e_CX_VIEWMANAGER_DISCONNECT_SIGNALS 1"); |
41 | 626 |
|
627 |
// Disconnect all existing capture key signals |
|
628 |
mKeyHandler->disconnect(); |
|
629 |
||
630 |
if (!view) { |
|
631 |
// If view is not given, take current view. |
|
46 | 632 |
view = currentView(); |
41 | 633 |
} |
634 |
||
635 |
CX_DEBUG(("CxuiViewManager - disconnecting from view %d", view)); |
|
636 |
if (view) { |
|
637 |
// Disconnect all signals from current view to us. |
|
638 |
disconnect(view, 0, this, 0); |
|
639 |
// Disconnect all signals from us to current view. |
|
640 |
disconnect(this, 0, view, 0); |
|
641 |
} |
|
642 |
||
42 | 643 |
OstTrace0(camerax_performance, CXUIVIEWMANAGER_DISCONNECT_2, "msg: e_CX_VIEWMANAGER_DISCONNECT_SIGNALS 0"); |
41 | 644 |
CX_DEBUG_EXIT_FUNCTION(); |
645 |
} |
|
646 |
||
647 |
/*! |
|
648 |
* Connect signals to pre-capture view. |
|
649 |
*/ |
|
46 | 650 |
void CxuiViewManager::connectPreCaptureSignals(CxuiPrecaptureView *view) |
41 | 651 |
{ |
652 |
CX_DEBUG_ENTER_FUNCTION(); |
|
653 |
||
46 | 654 |
// Disconnect from the current, "old" view |
41 | 655 |
disconnectSignals(); |
656 |
||
46 | 657 |
// connecting pre-capture view signals to standby timer. |
658 |
connect(view, SIGNAL(startStandbyTimer()), this, SLOT(startStandbyTimer()), Qt::UniqueConnection); |
|
659 |
connect(view, SIGNAL(stopStandbyTimer()), this, SLOT(stopStandbyTimer()), Qt::UniqueConnection); |
|
660 |
connect(view, SIGNAL(changeToPrecaptureView()), this, SLOT(startStandbyTimer()), Qt::UniqueConnection); |
|
661 |
connect(view, SIGNAL(changeToPostcaptureView()), this, SLOT(stopStandbyTimer()), Qt::UniqueConnection); |
|
41 | 662 |
|
46 | 663 |
// connecting pre-capture view signals to viewmanager slots |
664 |
connect(view, SIGNAL(changeToPostcaptureView()), this, SLOT(changeToPostcaptureView()), Qt::UniqueConnection); |
|
665 |
connect(view, SIGNAL(changeToPrecaptureView()), this, SLOT(changeToPrecaptureView()), Qt::UniqueConnection); |
|
666 |
||
667 |
//connecting scene modes signal |
|
668 |
connect(view, SIGNAL(showScenesView()), this, SLOT(showScenesView()), Qt::UniqueConnection); |
|
41 | 669 |
|
46 | 670 |
connect(view, SIGNAL(switchCamera()), this, SLOT(switchCamera()), Qt::UniqueConnection); |
41 | 671 |
|
46 | 672 |
// connecting error signals from precapture view to application state. |
673 |
connect(view, SIGNAL(errorEncountered(CxeError::Id)), |
|
674 |
mApplicationState, SLOT(handleApplicationError(CxeError::Id)), |
|
675 |
Qt::UniqueConnection); |
|
41 | 676 |
|
46 | 677 |
// Standby signals |
678 |
connect(this, SIGNAL(normalStateEntered()), view, SLOT(exitStandby()), Qt::UniqueConnection); |
|
679 |
connect(this, SIGNAL(normalStateExited()), view, SLOT(enterStandby()), Qt::UniqueConnection); |
|
41 | 680 |
|
46 | 681 |
// connects all capture key signals. |
682 |
connectCaptureKeySignals(view); |
|
41 | 683 |
|
684 |
CX_DEBUG_EXIT_FUNCTION(); |
|
685 |
} |
|
686 |
||
687 |
/*! |
|
688 |
* Connect signals to post-capture view. |
|
689 |
*/ |
|
690 |
void CxuiViewManager::connectPostCaptureSignals() |
|
691 |
{ |
|
692 |
CX_DEBUG_ENTER_FUNCTION(); |
|
693 |
||
46 | 694 |
// Disconnect from the current, "old" view |
41 | 695 |
disconnectSignals(); |
42 | 696 |
|
46 | 697 |
CxuiView *view = mViews[POSTCAPTURE_VIEW]; |
698 |
if (view) { |
|
699 |
connect(view, SIGNAL(changeToPrecaptureView()), this, SLOT(changeToPrecaptureView()), Qt::UniqueConnection); |
|
41 | 700 |
|
701 |
// Standby signals |
|
46 | 702 |
connect(this, SIGNAL(normalStateEntered()), view, SLOT(exitStandby()), Qt::UniqueConnection); |
703 |
connect(this, SIGNAL(normalStateExited()), view, SLOT(enterStandby()), Qt::UniqueConnection); |
|
41 | 704 |
|
705 |
// connect necessary capturekey signals |
|
46 | 706 |
connectCaptureKeySignals(view); |
41 | 707 |
} |
708 |
CX_DEBUG_EXIT_FUNCTION(); |
|
709 |
} |
|
710 |
||
711 |
/*! |
|
712 |
* Connect signals to scene mode view. |
|
713 |
*/ |
|
714 |
void CxuiViewManager::connectSceneModeSignals() |
|
715 |
{ |
|
716 |
CX_DEBUG_ENTER_FUNCTION(); |
|
46 | 717 |
|
718 |
// Disconnect from the current, "old" view |
|
41 | 719 |
disconnectSignals(); |
720 |
||
46 | 721 |
CxuiView *view = mViews[SCENE_MODE_VIEW]; |
722 |
if (view) { |
|
42 | 723 |
// Standby signals for releasing camera |
46 | 724 |
connect(this, SIGNAL(normalStateEntered()), view, SLOT(exitStandby())); |
725 |
connect(this, SIGNAL(normalStateExited()), view, SLOT(enterStandby())); |
|
41 | 726 |
|
42 | 727 |
// Moving back to pre-capture view |
46 | 728 |
connect(view, SIGNAL(viewCloseEvent()), this, SLOT(changeToPrecaptureView())); |
729 |
||
730 |
connectCaptureKeySignals(view); |
|
42 | 731 |
} |
41 | 732 |
CX_DEBUG_EXIT_FUNCTION(); |
733 |
} |
|
734 |
||
735 |
/*! |
|
736 |
* Connect key handler capture key signals. |
|
737 |
*/ |
|
46 | 738 |
void CxuiViewManager::connectCaptureKeySignals(CxuiView *view) |
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
739 |
{ |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
740 |
CX_DEBUG_ENTER_FUNCTION(); |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
741 |
|
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
742 |
// Disconnect all existing capture key signals |
28 | 743 |
mKeyHandler->disconnect(); |
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
744 |
|
46 | 745 |
if (view) { |
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
746 |
// If the view class does not implement the named slot, the connect will fail |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
747 |
// and output some warnings as debug prints. This is by design. |
46 | 748 |
connect(mKeyHandler, SIGNAL(autofocusKeyPressed()), view, SLOT(handleAutofocusKeyPressed())); |
749 |
connect(mKeyHandler, SIGNAL(autofocusKeyReleased()), view, SLOT(handleAutofocusKeyReleased())); |
|
750 |
connect(mKeyHandler, SIGNAL(captureKeyPressed()), view, SLOT(handleCaptureKeyPressed())); |
|
751 |
connect(mKeyHandler, SIGNAL(captureKeyReleased()), view, SLOT(handleCaptureKeyReleased())); |
|
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
752 |
} |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
753 |
|
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
754 |
CX_DEBUG_EXIT_FUNCTION(); |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
755 |
} |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
756 |
|
41 | 757 |
/*! |
758 |
* Clears all camera activities from activity manager. |
|
759 |
*/ |
|
760 |
void CxuiViewManager::clearAllActivities() |
|
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
761 |
{ |
58 | 762 |
AfActivityStorage activityStorage; |
763 |
activityStorage.removeActivity(CxuiActivityIds::STILL_PRECAPTURE_ACTIVITY); |
|
764 |
activityStorage.removeActivity(CxuiActivityIds::STILL_POSTCAPTURE_ACTIVITY); |
|
765 |
activityStorage.removeActivity(CxuiActivityIds::VIDEO_PRECAPTURE_ACTIVITY); |
|
766 |
activityStorage.removeActivity(CxuiActivityIds::VIDEO_POSTCAPTURE_ACTIVITY); |
|
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
767 |
} |
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
768 |
|
28 | 769 |
/*! |
770 |
* Raise application to foreground if it's currently (fully) in background. |
|
771 |
*/ |
|
772 |
void CxuiViewManager::toForeground() |
|
773 |
{ |
|
774 |
CX_DEBUG_ENTER_FUNCTION(); |
|
775 |
||
41 | 776 |
if (mApplicationState->currentState() == CxuiApplicationState::Background) { |
28 | 777 |
// Bring to foreground and gain focus. |
41 | 778 |
CX_DEBUG(("CxuiViewManager - in background, bringing to foreground now.")); |
28 | 779 |
mMainWindow.raise(); |
780 |
mMainWindow.activateWindow(); |
|
781 |
} |
|
782 |
||
783 |
CX_DEBUG_EXIT_FUNCTION(); |
|
784 |
} |
|
785 |
||
19
d9aefe59d544
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
786 |
// end of file |