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