66 mMainWindow(mainWindow), |
70 mMainWindow(mainWindow), |
67 mEngine(engine), |
71 mEngine(engine), |
68 mKeyHandler(NULL), |
72 mKeyHandler(NULL), |
69 mCameraDocumentLoader(NULL), |
73 mCameraDocumentLoader(NULL), |
70 mApplicationState(NULL), |
74 mApplicationState(NULL), |
71 mErrorManager(NULL), |
75 mErrorManager(NULL) |
72 mSceneModeView(NULL) |
|
73 { |
76 { |
74 CX_DEBUG_ENTER_FUNCTION(); |
77 CX_DEBUG_ENTER_FUNCTION(); |
75 |
78 |
76 // create mappings to map view name to correct docml file |
79 // create mappings to map view name to correct docml file |
77 mDocmlFilesByView.insert(STILL_PRE_CAPTURE_VIEW, STILL_1ST_XML); |
80 mDocmlFilesByView.insert(STILL_PRE_CAPTURE_VIEW, STILL_1ST_XML); |
78 mDocmlFilesByView.insert(VIDEO_PRE_CAPTURE_VIEW, VIDEO_1ST_XML); |
81 mDocmlFilesByView.insert(VIDEO_PRE_CAPTURE_VIEW, VIDEO_1ST_XML); |
79 mDocmlFilesByView.insert(POSTCAPTURE_VIEW, POSTCAPTURE_XML); |
82 mDocmlFilesByView.insert(POSTCAPTURE_VIEW, POSTCAPTURE_XML); |
80 mDocmlFilesByView.insert(STILL_SCENES_VIEW, SCENEMODE_SETTING_XML); |
83 mDocmlFilesByView.insert(SCENE_MODE_VIEW, SCENEMODE_SETTING_XML); |
81 |
84 |
82 // Key handler |
85 // Key handler |
83 mKeyHandler = new CxuiCaptureKeyHandler(mEngine); |
86 mKeyHandler = new CxuiCaptureKeyHandler(mEngine); |
84 |
87 |
85 // Document loader |
88 // Document loader |
86 OstTrace0( camerax_performance, CXUIVIEWMANAGER_CXUIVIEWMANAGER, "msg: e_CX_VIEWMANAGER_CREATE_DOCLOADER 1" ); |
89 OstTrace0(camerax_performance, CXUIVIEWMANAGER_CXUIVIEWMANAGER_1, "msg: e_CX_VIEWMANAGER_CREATE_DOCLOADER 1"); |
87 mCameraDocumentLoader = new CxuiDocumentLoader(&engine); |
90 mCameraDocumentLoader = new CxuiDocumentLoader(&engine); |
88 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"); |
89 |
92 |
90 // Application state |
93 // Application state |
91 mApplicationState = new CxuiApplicationState(mApplication, mEngine.settings(), *mKeyHandler, mCameraDocumentLoader); |
94 mApplicationState = new CxuiApplicationState(mApplication, mEngine.settings(), mCameraDocumentLoader); |
92 CX_ASSERT_ALWAYS(mApplicationState); |
95 CX_ASSERT_ALWAYS(mApplicationState); |
93 bool ok = connect(mApplicationState, SIGNAL(stateChanged(CxuiApplicationState::State, CxuiApplicationState::State)), |
96 bool ok = connect(mApplicationState, SIGNAL(stateChanged(CxuiApplicationState::State, CxuiApplicationState::State)), |
94 this, SLOT(handleApplicationStateChanged(CxuiApplicationState::State, CxuiApplicationState::State))); |
97 this, SLOT(handleApplicationStateChanged(CxuiApplicationState::State, CxuiApplicationState::State))); |
95 Q_ASSERT_X(ok, "CxuiViewManager", "Application state change signal connect failed."); |
98 Q_ASSERT_X(ok, "CxuiViewManager", "Application state change signal connect failed."); |
96 connect(this, SIGNAL(standbyExitRequested()), mApplicationState, SLOT(exitStandby()), Qt::QueuedConnection); |
99 connect(this, SIGNAL(standbyExitRequested()), mApplicationState, SLOT(exitStandby()), Qt::QueuedConnection); |
236 void CxuiViewManager::stopStandbyTimer() |
240 void CxuiViewManager::stopStandbyTimer() |
237 { |
241 { |
238 CX_DEBUG_ENTER_FUNCTION(); |
242 CX_DEBUG_ENTER_FUNCTION(); |
239 mStandbyTimer.stop(); |
243 mStandbyTimer.stop(); |
240 CX_DEBUG_EXIT_FUNCTION(); |
244 CX_DEBUG_EXIT_FUNCTION(); |
241 } |
|
242 |
|
243 /** |
|
244 * Init engine to correct mode based on activity being restored. |
|
245 */ |
|
246 void CxuiViewManager::initEngine() |
|
247 { |
|
248 Cxe::CameraMode mode = Cxe::ImageMode; |
|
249 QString activityId = mApplication.activateId(); |
|
250 if (activityId == CxuiActivityIds::VIDEO_PRECAPTURE_ACTIVITY || |
|
251 activityId == CxuiActivityIds::VIDEO_POSTCAPTURE_ACTIVITY) { |
|
252 mode = Cxe::VideoMode; |
|
253 } |
|
254 if (activityId == CxuiActivityIds::STILL_PRECAPTURE_ACTIVITY || |
|
255 activityId == CxuiActivityIds::VIDEO_PRECAPTURE_ACTIVITY) { |
|
256 // init engine only if going to pre-capture |
|
257 mEngine.initMode(mode); |
|
258 } else { |
|
259 // in post-capture don't init but set the correct mode to engine |
|
260 // so init can be done later |
|
261 mEngine.setMode(mode); |
|
262 } |
|
263 } |
245 } |
264 |
246 |
265 /*! |
247 /*! |
266 * Helper function to return current view cast to CxuiView. |
248 * Helper function to return current view cast to CxuiView. |
267 */ |
249 */ |
285 connect(&mEngine.stillCaptureControl(), SIGNAL(imagePrepareComplete(CxeError::Id)), |
267 connect(&mEngine.stillCaptureControl(), SIGNAL(imagePrepareComplete(CxeError::Id)), |
286 this, SLOT(changeToPrecaptureView())); |
268 this, SLOT(changeToPrecaptureView())); |
287 connect(&mEngine.videoCaptureControl(), SIGNAL(videoPrepareComplete(CxeError::Id)), |
269 connect(&mEngine.videoCaptureControl(), SIGNAL(videoPrepareComplete(CxeError::Id)), |
288 this, SLOT(changeToPrecaptureView())); |
270 this, SLOT(changeToPrecaptureView())); |
289 |
271 |
290 } else if (mApplication.activateReason() == Hb::ActivationReasonActivity ) { |
272 } else if (mApplication.activateReason() == Hb::ActivationReasonActivity) { |
291 // restoring activity, read startup view from stored activity |
273 // restoring activity, read startup view from stored activity |
292 |
274 |
293 // view to start in |
275 // view to start in |
294 QString viewName = STILL_PRE_CAPTURE_VIEW; |
276 QString viewName = STILL_PRE_CAPTURE_VIEW; |
295 |
277 |
353 */ |
335 */ |
354 CxuiView* CxuiViewManager::createView(const QString &viewName) |
336 CxuiView* CxuiViewManager::createView(const QString &viewName) |
355 { |
337 { |
356 CX_DEBUG_ENTER_FUNCTION(); |
338 CX_DEBUG_ENTER_FUNCTION(); |
357 |
339 |
358 OstTrace0( camerax_performance, CXUIVIEWMANAGER_CREATEVIEW, "msg: e_CX_CREATE_VIEW 1" ); |
340 OstTrace0(camerax_performance, CXUIVIEWMANAGER_CREATEVIEW_IN, "msg: e_CX_CREATE_VIEW 1"); |
359 |
341 |
360 CX_DEBUG(("View name: %s", viewName.toAscii().data())); |
342 CX_DEBUG(("View name: %s", viewName.toAscii().data())); |
361 |
343 |
362 CxuiView* view = mViews[viewName]; |
344 CxuiView* view = mViews[viewName]; |
363 if (view == NULL) { |
345 if (view == NULL) { |
364 CX_DEBUG(("View not loaded yet, loading now")); |
346 CX_DEBUG(("View not loaded yet, loading now")); |
365 bool ok = false; |
347 bool ok = false; |
366 // Use document loader to create widgets and layouts |
348 // Use document loader to create widgets and layouts |
367 // (non-sectioned parts are parsed and loaded) |
349 // (non-sectioned parts are parsed and loaded) |
368 QString docmlFile = mDocmlFilesByView[viewName]; |
350 QString docmlFile = mDocmlFilesByView[viewName]; |
369 CX_DEBUG_ASSERT(mCameraDocumentLoader); |
351 CX_ASSERT_ALWAYS(mCameraDocumentLoader); |
370 CX_ASSERT_ALWAYS(!docmlFile.isNull()); |
352 CX_ASSERT_ALWAYS(!docmlFile.isNull()); |
371 |
353 |
372 OstTrace0( camerax_performance, DUP2_CXUIVIEWMANAGER_ADDPRECAPTUREVIEWS, "msg: e_CX_DOCLOADER_LOAD 1" ); |
354 OstTrace0(camerax_performance, CXUIVIEWMANAGER_CREATEVIEW_2, "msg: e_CX_DOCUMENTLOADER_LOAD 1"); |
373 |
|
374 mCameraDocumentLoader->load(docmlFile, &ok); |
355 mCameraDocumentLoader->load(docmlFile, &ok); |
375 |
356 OstTrace0(camerax_performance, CXUIVIEWMANAGER_CREATEVIEW_4, "msg: e_CX_DOCUMENTLOADER_LOAD 0"); |
376 Q_ASSERT_X(ok, "createView", "error in xml file parsing"); |
357 Q_ASSERT_X(ok, "createView", "error in xml file parsing"); |
377 |
358 |
378 OstTrace0( camerax_performance, DUP2_CXUIVIEWMANAGER_CREATEVIEW, "msg: e_CX_DOCLOADER_LOAD 0" ); |
359 OstTrace0(camerax_performance, CXUIVIEWMANAGER_CREATEVIEW_6, "msg: e_CX_DOCUMENTLOADER_FINDWIDGET 1"); |
379 |
|
380 OstTrace0( camerax_performance, DUP4_CXUIVIEWMANAGER_ADDVIEWS, "msg: e_CX_DOCLOADER_FINDWIDGET 1" ); |
|
381 QGraphicsWidget *widget = NULL; |
360 QGraphicsWidget *widget = NULL; |
382 // ask for the view widget pointer |
361 // ask for the view widget pointer |
383 widget = mCameraDocumentLoader->findWidget(viewName); |
362 widget = mCameraDocumentLoader->findWidget(viewName); |
384 view = qobject_cast<CxuiView *> (widget); |
363 view = qobject_cast<CxuiView *> (widget); |
385 CX_DEBUG_ASSERT(view); |
364 CX_ASSERT_ALWAYS(view); |
386 OstTrace0( camerax_performance, DUP5_CXUIVIEWMANAGER_ADDVIEWS, "msg: e_CX_DOCLOADER_FINDWIDGET 0" ); |
365 OstTrace0(camerax_performance, CXUIVIEWMANAGER_CREATEVIEW_8, "msg: e_CX_DOCUMENTLOADER_FINDWIDGET 1"); |
387 |
366 |
388 // call for needed consturction methods |
367 // call for needed consturction methods |
389 view->construct(&mMainWindow, &mEngine, mCameraDocumentLoader, mKeyHandler, mApplication.activityManager()); |
368 view->construct(&mMainWindow, &mEngine, mCameraDocumentLoader, mKeyHandler, mApplication.activityManager()); |
390 // .. and add to main window (which also takes ownership) |
369 // .. and add to main window (which also takes ownership) |
391 OstTrace0( camerax_performance, DUP1_CXUIVIEWMANAGER_MAINWINDOW_ADDVIEW, "msg: e_CX_MAINWINDOW_ADDVIEW 1" ); |
370 OstTrace0(camerax_performance, CXUIVIEWMANAGER_CREATEVIEW_10, "msg: e_CX_MAINWINDOW_ADDVIEW 1"); |
392 mMainWindow.addView(view); |
371 mMainWindow.addView(view); |
393 mViews.insert(viewName, view); |
372 mViews.insert(viewName, view); |
394 |
373 OstTrace0(camerax_performance, CXUIVIEWMANAGER_CREATEVIEW_12, "msg: e_CX_MAINWINDOW_ADDVIEW 0"); |
395 OstTrace0( camerax_performance, DUP2_CXUIVIEWMANAGER_MAINWINDOW_ADDVIEW, "msg: e_CX_MAINWINDOW_ADDVIEW 0" ); |
374 } |
396 OstTrace0( camerax_performance, DUP1_CXUIVIEWMANAGER_CREATEVIEW, "msg: e_CX_CREATE_STILLPRECAPTUREVIEW 0" ); |
375 |
397 |
376 OstTrace0(camerax_performance, CXUIVIEWMANAGER_CREATEVIEW_OUT, "msg: e_CX_CREATE_VIEW 0"); |
398 } |
|
399 |
377 |
400 CX_DEBUG_EXIT_FUNCTION(); |
378 CX_DEBUG_EXIT_FUNCTION(); |
401 return view; |
379 return view; |
402 } |
|
403 |
|
404 /*! |
|
405 * Create scene mode view. |
|
406 */ |
|
407 CxuiView* CxuiViewManager::createSceneModesView() |
|
408 { |
|
409 CX_DEBUG_ENTER_FUNCTION(); |
|
410 |
|
411 mSceneModeView = qobject_cast<CxuiSceneModeView*>(createView(STILL_SCENES_VIEW)); |
|
412 mSceneModeView->loadBackgroundImages(); |
|
413 |
|
414 CX_DEBUG_EXIT_FUNCTION(); |
|
415 return mSceneModeView; |
|
416 } |
380 } |
417 |
381 |
418 /*! |
382 /*! |
419 * CxuiViewManager::showScenesView |
383 * CxuiViewManager::showScenesView |
420 * A private method for displaying Scene Modes selection view |
384 * A private method for displaying Scene Modes selection view |
528 |
472 |
529 HbView *view = getPrecaptureView(mEngine.mode(), |
473 HbView *view = getPrecaptureView(mEngine.mode(), |
530 mEngine.cameraDeviceControl().cameraIndex()); |
474 mEngine.cameraDeviceControl().cameraIndex()); |
531 mMainWindow.setCurrentView(view, false); |
475 mMainWindow.setCurrentView(view, false); |
532 |
476 |
533 if (mSceneModeView){ |
477 // Release resources needed by scene view. |
534 mViews.remove(STILL_SCENES_VIEW); |
478 HbView *sceneView = mViews.take(SCENE_MODE_VIEW); |
535 delete mSceneModeView; |
479 if (sceneView) { |
536 mSceneModeView = NULL; |
480 // This will not delete the view. |
537 } |
481 mMainWindow.removeView(sceneView); |
|
482 // We can get to this slot from scene view, so don't delete the object too early. |
|
483 sceneView->deleteLater(); |
|
484 sceneView = NULL; |
|
485 } |
|
486 |
538 // connecting necessary pre-capture view signals |
487 // connecting necessary pre-capture view signals |
539 connectPreCaptureSignals(); |
488 connectPreCaptureSignals(); |
540 |
489 |
541 // Make sure engine prepares for new image/video if necessary |
490 // Make sure engine prepares for new image/video if necessary |
542 mEngine.initMode(mEngine.mode()); |
491 mEngine.initMode(mEngine.mode()); |
629 * Connect signals specific to given view. |
578 * Connect signals specific to given view. |
630 */ |
579 */ |
631 void CxuiViewManager::connectSignals(QObject *view) |
580 void CxuiViewManager::connectSignals(QObject *view) |
632 { |
581 { |
633 CX_DEBUG_ENTER_FUNCTION(); |
582 CX_DEBUG_ENTER_FUNCTION(); |
|
583 OstTrace0(camerax_performance, CXUIVIEWMANAGER_CONNECTSIGNALS_1, "msg: e_CX_VIEWMANAGER_CONNECT_SIGNALS 1"); |
|
584 |
634 if (view) { |
585 if (view) { |
635 if (view == mViews[POSTCAPTURE_VIEW]) { |
586 if (view == mViews[POSTCAPTURE_VIEW]) { |
636 connectPostCaptureSignals(); |
587 connectPostCaptureSignals(); |
637 } else if (view == mSceneModeView) { |
588 } else if (view == mViews[SCENE_MODE_VIEW]) { |
638 connectSceneModeSignals(); |
589 connectSceneModeSignals(); |
639 } else { |
590 } else { |
640 connectPreCaptureSignals(); |
591 connectPreCaptureSignals(); |
641 } |
592 } |
642 } |
593 } |
|
594 |
|
595 OstTrace0(camerax_performance, CXUIVIEWMANAGER_CONNECTSIGNALS_2, "msg: e_CX_VIEWMANAGER_CONNECT_SIGNALS 0"); |
643 CX_DEBUG_EXIT_FUNCTION(); |
596 CX_DEBUG_EXIT_FUNCTION(); |
644 } |
597 } |
645 |
598 |
646 /*! |
599 /*! |
647 * Disconnect signals. |
600 * Disconnect signals. |
722 CX_DEBUG_ENTER_FUNCTION(); |
677 CX_DEBUG_ENTER_FUNCTION(); |
723 |
678 |
724 disconnectSignals(); |
679 disconnectSignals(); |
725 QObject *currentView = mMainWindow.currentView(); |
680 QObject *currentView = mMainWindow.currentView(); |
726 if (currentView == mViews[POSTCAPTURE_VIEW]) { |
681 if (currentView == mViews[POSTCAPTURE_VIEW]) { |
|
682 |
727 connect(currentView, SIGNAL(changeToPrecaptureView()), this, SLOT(changeToPrecaptureView()), Qt::UniqueConnection); |
683 connect(currentView, SIGNAL(changeToPrecaptureView()), this, SLOT(changeToPrecaptureView()), Qt::UniqueConnection); |
728 |
684 |
729 // Standby signals |
685 // Standby signals |
730 connect(this, SIGNAL(normalStateEntered()), currentView, SLOT(exitStandby()), Qt::UniqueConnection); |
686 connect(this, SIGNAL(normalStateEntered()), currentView, SLOT(exitStandby()), Qt::UniqueConnection); |
731 connect(this, SIGNAL(normalStateExited()), currentView, SLOT(enterStandby()), Qt::UniqueConnection); |
687 connect(this, SIGNAL(normalStateExited()), currentView, SLOT(enterStandby()), Qt::UniqueConnection); |
743 void CxuiViewManager::connectSceneModeSignals() |
699 void CxuiViewManager::connectSceneModeSignals() |
744 { |
700 { |
745 CX_DEBUG_ENTER_FUNCTION(); |
701 CX_DEBUG_ENTER_FUNCTION(); |
746 disconnectSignals(); |
702 disconnectSignals(); |
747 |
703 |
748 connectCaptureKeySignals(); |
704 HbView *currentView = mMainWindow.currentView(); |
749 |
705 |
750 // Standby signals for releasing camera |
706 if (currentView == mViews[SCENE_MODE_VIEW]) { |
751 connect(this, SIGNAL(normalStateEntered()), mSceneModeView, SLOT(exitStandby())); |
707 |
752 connect(this, SIGNAL(normalStateExited()), mSceneModeView, SLOT(enterStandby())); |
708 connectCaptureKeySignals(); |
753 |
709 |
754 // Moving back to pre-capture view |
710 // Standby signals for releasing camera |
755 connect(mSceneModeView, SIGNAL(viewCloseEvent()), this, SLOT(changeToPrecaptureView())); |
711 connect(this, SIGNAL(normalStateEntered()), currentView, SLOT(exitStandby())); |
756 |
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 } |
757 CX_DEBUG_EXIT_FUNCTION(); |
717 CX_DEBUG_EXIT_FUNCTION(); |
758 } |
718 } |
759 |
719 |
760 /*! |
720 /*! |
761 * Connect key handler capture key signals. |
721 * Connect key handler capture key signals. |