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