camerauis/cameraxui/cxui/src/cxuiviewmanager.cpp
changeset 46 c826656d6714
parent 42 feebad15db8c
child 52 7e18d488ac5f
equal deleted inserted replaced
42:feebad15db8c 46:c826656d6714
    19 #include <hbmainwindow.h>
    19 #include <hbmainwindow.h>
    20 #include <QGraphicsSceneEvent>
    20 #include <QGraphicsSceneEvent>
    21 #include <hbstyleloader.h>
    21 #include <hbstyleloader.h>
    22 #include <hbactivitymanager.h>
    22 #include <hbactivitymanager.h>
    23 #include <hbaction.h>
    23 #include <hbaction.h>
       
    24 #include <xqserviceutil.h>
    24 
    25 
    25 #include "cxuiapplication.h"
    26 #include "cxuiapplication.h"
    26 #include "cxuiapplicationstate.h"
    27 #include "cxuiapplicationstate.h"
    27 #include "cxuiviewmanager.h"
    28 #include "cxuiviewmanager.h"
    28 #include "cxuivideoprecaptureview.h"
    29 #include "cxuivideoprecaptureview.h"
   161                                                     CxuiApplicationState::State oldState)
   162                                                     CxuiApplicationState::State oldState)
   162 {
   163 {
   163     Q_UNUSED(oldState);
   164     Q_UNUSED(oldState);
   164     CX_DEBUG_ENTER_FUNCTION();
   165     CX_DEBUG_ENTER_FUNCTION();
   165 
   166 
   166     CxuiView *view = qobject_cast<CxuiView *>(mMainWindow.currentView());
   167     CxuiView *view = currentView();
   167     CX_DEBUG(("CxuiViewManager - current view %d", view));
   168     CX_DEBUG(("CxuiViewManager - current view %d", view));
   168 
   169 
   169     switch (newState) {
   170     switch (newState) {
   170     case CxuiApplicationState::Normal:
   171     case CxuiApplicationState::Normal:
   171         // Disable raising to foreground with capture key.
   172         // Disable raising to foreground with capture key.
   207 */
   208 */
   208 void CxuiViewManager::handleExitingNormalState()
   209 void CxuiViewManager::handleExitingNormalState()
   209 {
   210 {
   210     CX_DEBUG_ENTER_FUNCTION();
   211     CX_DEBUG_ENTER_FUNCTION();
   211     // Store view that is active now.
   212     // Store view that is active now.
   212     CxuiView *view = qobject_cast<CxuiView *>(mMainWindow.currentView());
   213     CxuiView *view = currentView();
   213     CX_DEBUG(("CxuiViewManager - current view %d", view));
   214     CX_DEBUG(("CxuiViewManager - current view %d", view));
   214 
   215 
   215     // Emit signal so current view can enter standby.
   216     // Emit signal so current view can enter standby.
   216     emit normalStateExited();
   217     emit normalStateExited();
   217     // Disconnect signals so we don't send key event's etc.
   218     // Disconnect signals so we don't send key event's etc.
   248  * Helper function to return current view cast to CxuiView.
   249  * Helper function to return current view cast to CxuiView.
   249  */
   250  */
   250 CxuiView* CxuiViewManager::currentView() const
   251 CxuiView* CxuiViewManager::currentView() const
   251 {
   252 {
   252     CxuiView *view = qobject_cast<CxuiView*> (mMainWindow.currentView());
   253     CxuiView *view = qobject_cast<CxuiView*> (mMainWindow.currentView());
   253     CX_ASSERT_ALWAYS(view);
       
   254     return view;
   254     return view;
   255 }
   255 }
   256 
   256 
   257 /*!
   257 /*!
   258 * Select and initialize the view we need to start into.
   258 * Select and initialize the view we need to start into.
   259 */
   259 */
   260 void CxuiViewManager::initStartupView()
   260 void CxuiViewManager::initStartupView()
   261 {
   261 {
   262     CX_DEBUG_ENTER_FUNCTION();
   262     CX_DEBUG_ENTER_FUNCTION();
   263 
   263 
   264     if (mApplication.activateReason() == Hb::ActivationReasonService) {
   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 
   265         // For embedded mode: don't create view yet, create when engine inits to correct mode.
   270         // 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
   271         // Connect signals to set up the view after image/video prepare
   267         connect(&mEngine.stillCaptureControl(), SIGNAL(imagePrepareComplete(CxeError::Id)),
   272         connect(&mEngine.stillCaptureControl(), SIGNAL(imagePrepareComplete(CxeError::Id)),
   268                 this, SLOT(changeToPrecaptureView()));
   273                 this, SLOT(changeToPrecaptureView()));
   269         connect(&mEngine.videoCaptureControl(), SIGNAL(videoPrepareComplete(CxeError::Id)),
   274         connect(&mEngine.videoCaptureControl(), SIGNAL(videoPrepareComplete(CxeError::Id)),
   288             viewName = POSTCAPTURE_VIEW;
   293             viewName = POSTCAPTURE_VIEW;
   289             preCapture = false;
   294             preCapture = false;
   290         }
   295         }
   291 
   296 
   292         CxuiView *view = createView(viewName);
   297         CxuiView *view = createView(viewName);
   293         mMainWindow.setCurrentView(view, false);
       
   294 
       
   295         if (preCapture) {
   298         if (preCapture) {
   296             connectPreCaptureSignals();
   299             connectPreCaptureSignals(static_cast<CxuiPrecaptureView *>(view));
   297         } else {
   300         } else {
   298             connectPostCaptureSignals();
   301             connectPostCaptureSignals();
   299         }
   302         }
   300 
   303         mMainWindow.setCurrentView(view, false);
   301         // Check the current application state, signalled to handleApplicationStateChanged.
       
   302         mApplicationState->startMonitoring();
       
   303 
   304 
   304         // restore view from activity
   305         // restore view from activity
   305         bool ok = mApplication.activityManager()->waitActivity();
   306         bool ok = mApplication.activityManager()->waitActivity();
   306 
   307 
   307         view->restoreActivity(activityId,
   308         view->restoreActivity(activityId,
   315         if (mEngine.mode() == Cxe::VideoMode) {
   316         if (mEngine.mode() == Cxe::VideoMode) {
   316             view = createView(VIDEO_PRE_CAPTURE_VIEW);
   317             view = createView(VIDEO_PRE_CAPTURE_VIEW);
   317         } else {
   318         } else {
   318             view = createView(STILL_PRE_CAPTURE_VIEW);
   319             view = createView(STILL_PRE_CAPTURE_VIEW);
   319         }
   320         }
   320 
   321         connectPreCaptureSignals(static_cast<CxuiPrecaptureView *>(view));
   321         mMainWindow.setCurrentView(view, false);
   322         mMainWindow.setCurrentView(view, false);
   322         connectPreCaptureSignals();
       
   323 
       
   324         // Check the current application state, signalled to handleApplicationStateChanged.
       
   325         mApplicationState->startMonitoring();
       
   326 
   323 
   327         clearAllActivities();
   324         clearAllActivities();
   328     }
   325     }
       
   326 
       
   327     // Check the current application state, signalled to handleApplicationStateChanged.
       
   328     mApplicationState->startMonitoring();
   329 
   329 
   330     CX_DEBUG_EXIT_FUNCTION();
   330     CX_DEBUG_EXIT_FUNCTION();
   331 }
   331 }
   332 
   332 
   333 /*!
   333 /*!
   391 
   391 
   392     CxuiSceneModeView *view = qobject_cast<CxuiSceneModeView*>(createView(SCENE_MODE_VIEW));
   392     CxuiSceneModeView *view = qobject_cast<CxuiSceneModeView*>(createView(SCENE_MODE_VIEW));
   393     CX_ASSERT_ALWAYS(view);
   393     CX_ASSERT_ALWAYS(view);
   394     view->loadBackgroundImages();
   394     view->loadBackgroundImages();
   395 
   395 
   396     mMainWindow.setCurrentView(view, false);
       
   397     stopStandbyTimer();
   396     stopStandbyTimer();
   398     connectSceneModeSignals();
   397     connectSceneModeSignals();
       
   398     mMainWindow.setCurrentView(view, false);
   399 
   399 
   400     CX_DEBUG_EXIT_FUNCTION();
   400     CX_DEBUG_EXIT_FUNCTION();
   401 }
   401 }
   402 
   402 
   403 /*!
   403 /*!
   432     CX_DEBUG_ENTER_FUNCTION();
   432     CX_DEBUG_ENTER_FUNCTION();
   433     // Disconnect signals from old view.
   433     // Disconnect signals from old view.
   434     disconnectSignals();
   434     disconnectSignals();
   435 
   435 
   436     CxuiView *postCaptureView = createView(POSTCAPTURE_VIEW);
   436     CxuiView *postCaptureView = createView(POSTCAPTURE_VIEW);
   437 
       
   438     mMainWindow.setCurrentView(postCaptureView, false);
       
   439 
   437 
   440     // Connecting all necessary signals for postcapture view.
   438     // Connecting all necessary signals for postcapture view.
   441     // Not connected yet if not in normal state. We connect the signals
   439     // Not connected yet if not in normal state. We connect the signals
   442     // once we enter normal state again.
   440     // once we enter normal state again.
   443     if (mApplicationState->currentState() == CxuiApplicationState::Normal) {
   441     if (mApplicationState->currentState() == CxuiApplicationState::Normal) {
   444         connectPostCaptureSignals();
   442         connectPostCaptureSignals();
   445     }
   443     }
       
   444 
       
   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);
   446 
   449 
   447     CX_DEBUG_EXIT_FUNCTION();
   450     CX_DEBUG_EXIT_FUNCTION();
   448 }
   451 }
   449 
   452 
   450 /*!
   453 /*!
   468     } else {
   471     } else {
   469 
   472 
   470         // Disconnect signals from old view.
   473         // Disconnect signals from old view.
   471         disconnectSignals();
   474         disconnectSignals();
   472 
   475 
   473         HbView *view = getPrecaptureView(mEngine.mode(),
   476         CxuiPrecaptureView *view =
   474             mEngine.cameraDeviceControl().cameraIndex());
   477             getPrecaptureView(mEngine.mode(), mEngine.cameraDeviceControl().cameraIndex());
       
   478 
       
   479         // Connect necessary pre-capture view signals.
       
   480         connectPreCaptureSignals(view);
       
   481 
   475         mMainWindow.setCurrentView(view, false);
   482         mMainWindow.setCurrentView(view, false);
   476 
   483 
   477         // Release resources needed by scene view.
   484         // Release resources needed by scene view.
   478         HbView *sceneView = mViews.take(SCENE_MODE_VIEW);
   485         HbView *sceneView = mViews.take(SCENE_MODE_VIEW);
   479         if (sceneView) {
   486         if (sceneView) {
   482             // We can get to this slot from scene view, so don't delete the object too early.
   489             // We can get to this slot from scene view, so don't delete the object too early.
   483             sceneView->deleteLater();
   490             sceneView->deleteLater();
   484             sceneView = NULL;
   491             sceneView = NULL;
   485         }
   492         }
   486 
   493 
   487         // connecting necessary pre-capture view signals
       
   488         connectPreCaptureSignals();
       
   489 
       
   490         // Make sure engine prepares for new image/video if necessary
   494         // Make sure engine prepares for new image/video if necessary
   491         mEngine.initMode(mEngine.mode());
   495         mEngine.initMode(mEngine.mode());
   492 
   496 
   493         startStandbyTimer();
   497         startStandbyTimer();
   494 
   498 
   513         nextCamera = Cxe::PrimaryCameraIndex;
   517         nextCamera = Cxe::PrimaryCameraIndex;
   514         nextViewOrientation = Qt::Horizontal;
   518         nextViewOrientation = Qt::Horizontal;
   515     }
   519     }
   516 
   520 
   517     CxuiPrecaptureView* view = getPrecaptureView(mEngine.mode(), nextCamera);
   521     CxuiPrecaptureView* view = getPrecaptureView(mEngine.mode(), nextCamera);
       
   522     connectPreCaptureSignals(view);
   518     mMainWindow.setCurrentView(view, false);
   523     mMainWindow.setCurrentView(view, false);
   519     view->updateOrientation(nextViewOrientation);
   524     view->updateOrientation(nextViewOrientation);
   520 
       
   521     connectPreCaptureSignals();
       
   522 
   525 
   523     mEngine.cameraDeviceControl().switchCamera(nextCamera);
   526     mEngine.cameraDeviceControl().switchCamera(nextCamera);
   524 
   527 
   525     CX_DEBUG_EXIT_FUNCTION();
   528     CX_DEBUG_EXIT_FUNCTION();
   526 }
   529 }
   575 }
   578 }
   576 
   579 
   577 /*!
   580 /*!
   578 * Connect signals specific to given view.
   581 * Connect signals specific to given view.
   579 */
   582 */
   580 void CxuiViewManager::connectSignals(QObject *view)
   583 void CxuiViewManager::connectSignals(CxuiView *view)
   581 {
   584 {
   582     CX_DEBUG_ENTER_FUNCTION();
   585     CX_DEBUG_ENTER_FUNCTION();
   583     OstTrace0(camerax_performance, CXUIVIEWMANAGER_CONNECTSIGNALS_1, "msg: e_CX_VIEWMANAGER_CONNECT_SIGNALS 1");
   586     OstTrace0(camerax_performance, CXUIVIEWMANAGER_CONNECTSIGNALS_1, "msg: e_CX_VIEWMANAGER_CONNECT_SIGNALS 1");
   584 
   587 
   585     if (view) {
   588     if (view) {
   586         if (view == mViews[POSTCAPTURE_VIEW]) {
   589         if (view == mViews[POSTCAPTURE_VIEW]) {
   587             connectPostCaptureSignals();
   590             connectPostCaptureSignals();
   588         } else if (view == mViews[SCENE_MODE_VIEW]) {
   591         } else if (view == mViews[SCENE_MODE_VIEW]) {
   589             connectSceneModeSignals();
   592             connectSceneModeSignals();
   590         } else {
   593         } else {
   591             connectPreCaptureSignals();
   594             connectPreCaptureSignals(static_cast<CxuiPrecaptureView *>(view));
   592         }
   595         }
   593     }
   596     }
   594 
   597 
   595     OstTrace0(camerax_performance, CXUIVIEWMANAGER_CONNECTSIGNALS_2, "msg: e_CX_VIEWMANAGER_CONNECT_SIGNALS 0");
   598     OstTrace0(camerax_performance, CXUIVIEWMANAGER_CONNECTSIGNALS_2, "msg: e_CX_VIEWMANAGER_CONNECT_SIGNALS 0");
   596     CX_DEBUG_EXIT_FUNCTION();
   599     CX_DEBUG_EXIT_FUNCTION();
   599 /*!
   602 /*!
   600 * Disconnect signals.
   603 * Disconnect signals.
   601 * We don't want to send or receive signals with inactive views, so this is done every time changing a view.
   604 * 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.
   605 * @param view View object from which signals are disconnected. If NULL is given, current view is used.
   603 */
   606 */
   604 void CxuiViewManager::disconnectSignals(QObject *view)
   607 void CxuiViewManager::disconnectSignals(CxuiView *view)
   605 {
   608 {
   606     CX_DEBUG_ENTER_FUNCTION();
   609     CX_DEBUG_ENTER_FUNCTION();
   607     OstTrace0(camerax_performance, CXUIVIEWMANAGER_DISCONNECT_1, "msg: e_CX_VIEWMANAGER_DISCONNECT_SIGNALS 1");
   610     OstTrace0(camerax_performance, CXUIVIEWMANAGER_DISCONNECT_1, "msg: e_CX_VIEWMANAGER_DISCONNECT_SIGNALS 1");
   608 
   611 
   609     // Disconnect all existing capture key signals
   612     // Disconnect all existing capture key signals
   610     mKeyHandler->disconnect();
   613     mKeyHandler->disconnect();
   611 
   614 
   612     if (!view) {
   615     if (!view) {
   613         // If view is not given, take current view.
   616         // If view is not given, take current view.
   614         view = mMainWindow.currentView();
   617         view = currentView();
   615     }
   618     }
   616 
   619 
   617     CX_DEBUG(("CxuiViewManager - disconnecting from view %d", view));
   620     CX_DEBUG(("CxuiViewManager - disconnecting from view %d", view));
   618     if (view) {
   621     if (view) {
   619         // Disconnect all signals from current view to us.
   622         // Disconnect all signals from current view to us.
   627 }
   630 }
   628 
   631 
   629 /*!
   632 /*!
   630 * Connect signals to pre-capture view.
   633 * Connect signals to pre-capture view.
   631 */
   634 */
   632 void CxuiViewManager::connectPreCaptureSignals()
   635 void CxuiViewManager::connectPreCaptureSignals(CxuiPrecaptureView *view)
   633 {
   636 {
   634     CX_DEBUG_ENTER_FUNCTION();
   637     CX_DEBUG_ENTER_FUNCTION();
   635 
   638 
       
   639     // Disconnect from the current, "old" view
   636     disconnectSignals();
   640     disconnectSignals();
   637 
   641 
   638     HbView *currentView = mMainWindow.currentView();
   642     // connecting pre-capture view signals to standby timer.
   639 
   643     connect(view, SIGNAL(startStandbyTimer()),       this, SLOT(startStandbyTimer()), Qt::UniqueConnection);
   640     if (currentView != mViews[POSTCAPTURE_VIEW]) {
   644     connect(view, SIGNAL(stopStandbyTimer()),        this, SLOT(stopStandbyTimer()),  Qt::UniqueConnection);
   641         // connects all capture key signals.
   645     connect(view, SIGNAL(changeToPrecaptureView()),  this, SLOT(startStandbyTimer()), Qt::UniqueConnection);
   642         connectCaptureKeySignals();
   646     connect(view, SIGNAL(changeToPostcaptureView()), this, SLOT(stopStandbyTimer()),  Qt::UniqueConnection);
   643 
   647 
   644         // connecting pre-capture view signals to standby timer.
   648     // connecting pre-capture view signals to viewmanager slots
   645         connect(currentView, SIGNAL(startStandbyTimer()),       this, SLOT(startStandbyTimer()), Qt::UniqueConnection);
   649     connect(view, SIGNAL(changeToPostcaptureView()), this, SLOT(changeToPostcaptureView()), Qt::UniqueConnection);
   646         connect(currentView, SIGNAL(stopStandbyTimer()),        this, SLOT(stopStandbyTimer()),  Qt::UniqueConnection);
   650     connect(view, SIGNAL(changeToPrecaptureView()),  this, SLOT(changeToPrecaptureView()),  Qt::UniqueConnection);
   647         connect(currentView, SIGNAL(changeToPrecaptureView()),  this, SLOT(startStandbyTimer()), Qt::UniqueConnection);
   651 
   648         connect(currentView, SIGNAL(changeToPostcaptureView()), this, SLOT(stopStandbyTimer()),  Qt::UniqueConnection);
   652     //connecting scene modes signal
   649 
   653     connect(view, SIGNAL(showScenesView()), this, SLOT(showScenesView()), Qt::UniqueConnection);
   650         // connecting pre-capture view signals to viewmanager slots
   654 
   651         connect(currentView, SIGNAL(changeToPostcaptureView()), this, SLOT(changeToPostcaptureView()), Qt::UniqueConnection);
   655     connect(view, SIGNAL(switchCamera()), this, SLOT(switchCamera()), Qt::UniqueConnection);
   652         connect(currentView, SIGNAL(changeToPrecaptureView()),  this, SLOT(changeToPrecaptureView()),  Qt::UniqueConnection);
   656 
   653 
   657     // connecting error signals from precapture view to application state.
   654         //connecting scene modes signal
   658     connect(view, SIGNAL(errorEncountered(CxeError::Id)),
   655         connect(currentView, SIGNAL(showScenesView()), this, SLOT(showScenesView()), Qt::UniqueConnection);
   659             mApplicationState, SLOT(handleApplicationError(CxeError::Id)),
   656 
   660             Qt::UniqueConnection);
   657         connect(currentView, SIGNAL(switchCamera()), this, SLOT(switchCamera()), Qt::UniqueConnection);
   661 
   658 
   662     // Standby signals
   659         // connecting error signals from precapture view to application state.
   663     connect(this, SIGNAL(normalStateEntered()), view, SLOT(exitStandby()), Qt::UniqueConnection);
   660         connect(currentView, SIGNAL(errorEncountered(CxeError::Id)),
   664     connect(this, SIGNAL(normalStateExited()), view, SLOT(enterStandby()), Qt::UniqueConnection);
   661                 mApplicationState, SLOT(handleApplicationError(CxeError::Id)),
   665 
   662                 Qt::UniqueConnection);
   666     // connects all capture key signals.
       
   667     connectCaptureKeySignals(view);
       
   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     // Disconnect from the current, "old" view
       
   680     disconnectSignals();
       
   681 
       
   682     CxuiView *view = mViews[POSTCAPTURE_VIEW];
       
   683     if (view) {
       
   684         connect(view, SIGNAL(changeToPrecaptureView()), this, SLOT(changeToPrecaptureView()), Qt::UniqueConnection);
   663 
   685 
   664         // Standby signals
   686         // Standby signals
   665         connect(this, SIGNAL(normalStateEntered()), currentView, SLOT(exitStandby()), Qt::UniqueConnection);
   687         connect(this, SIGNAL(normalStateEntered()), view, SLOT(exitStandby()), Qt::UniqueConnection);
   666         connect(this, SIGNAL(normalStateExited()), currentView, SLOT(enterStandby()), Qt::UniqueConnection);
   688         connect(this, SIGNAL(normalStateExited()), view, SLOT(enterStandby()), Qt::UniqueConnection);
   667     }
   689 
   668 
   690         // connect necessary capturekey signals
   669     CX_DEBUG_EXIT_FUNCTION();
   691         connectCaptureKeySignals(view);
   670 }
   692     }
   671 
   693     CX_DEBUG_EXIT_FUNCTION();
   672 /*!
   694 }
   673 * Connect signals to post-capture view.
   695 
   674 */
   696 /*!
   675 void CxuiViewManager::connectPostCaptureSignals()
   697 * Connect signals to scene mode view.
   676 {
   698 */
   677     CX_DEBUG_ENTER_FUNCTION();
   699 void CxuiViewManager::connectSceneModeSignals()
   678 
   700 {
       
   701     CX_DEBUG_ENTER_FUNCTION();
       
   702 
       
   703     // Disconnect from the current, "old" view
   679     disconnectSignals();
   704     disconnectSignals();
   680     QObject *currentView = mMainWindow.currentView();
   705 
   681     if (currentView == mViews[POSTCAPTURE_VIEW]) {
   706     CxuiView *view = mViews[SCENE_MODE_VIEW];
   682 
   707     if (view) {
   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
   708         // Standby signals for releasing camera
   711         connect(this, SIGNAL(normalStateEntered()), currentView, SLOT(exitStandby()));
   709         connect(this, SIGNAL(normalStateEntered()), view, SLOT(exitStandby()));
   712         connect(this, SIGNAL(normalStateExited()), currentView, SLOT(enterStandby()));
   710         connect(this, SIGNAL(normalStateExited()), view, SLOT(enterStandby()));
   713 
   711 
   714         // Moving back to pre-capture view
   712         // Moving back to pre-capture view
   715         connect(currentView, SIGNAL(viewCloseEvent()), this, SLOT(changeToPrecaptureView()));
   713         connect(view, SIGNAL(viewCloseEvent()), this, SLOT(changeToPrecaptureView()));
       
   714 
       
   715         connectCaptureKeySignals(view);
   716     }
   716     }
   717     CX_DEBUG_EXIT_FUNCTION();
   717     CX_DEBUG_EXIT_FUNCTION();
   718 }
   718 }
   719 
   719 
   720 /*!
   720 /*!
   721 * Connect key handler capture key signals.
   721 * Connect key handler capture key signals.
   722 */
   722 */
   723 void CxuiViewManager::connectCaptureKeySignals()
   723 void CxuiViewManager::connectCaptureKeySignals(CxuiView *view)
   724 {
   724 {
   725     CX_DEBUG_ENTER_FUNCTION();
   725     CX_DEBUG_ENTER_FUNCTION();
   726 
   726 
   727     // Disconnect all existing capture key signals
   727     // Disconnect all existing capture key signals
   728     mKeyHandler->disconnect();
   728     mKeyHandler->disconnect();
   729 
   729 
   730     QObject *currentView = mMainWindow.currentView();
   730     if (view) {
   731 
       
   732     if (currentView) {
       
   733         // If the view class does not implement the named slot, the connect will fail
   731         // If the view class does not implement the named slot, the connect will fail
   734         // and output some warnings as debug prints. This is by design.
   732         // and output some warnings as debug prints. This is by design.
   735         connect(mKeyHandler, SIGNAL(autofocusKeyPressed()),  currentView, SLOT(handleAutofocusKeyPressed()));
   733         connect(mKeyHandler, SIGNAL(autofocusKeyPressed()),  view, SLOT(handleAutofocusKeyPressed()));
   736         connect(mKeyHandler, SIGNAL(autofocusKeyReleased()), currentView, SLOT(handleAutofocusKeyReleased()));
   734         connect(mKeyHandler, SIGNAL(autofocusKeyReleased()), view, SLOT(handleAutofocusKeyReleased()));
   737         connect(mKeyHandler, SIGNAL(captureKeyPressed()),    currentView, SLOT(handleCaptureKeyPressed()));
   735         connect(mKeyHandler, SIGNAL(captureKeyPressed()),    view, SLOT(handleCaptureKeyPressed()));
   738         connect(mKeyHandler, SIGNAL(captureKeyReleased()),   currentView, SLOT(handleCaptureKeyReleased()));
   736         connect(mKeyHandler, SIGNAL(captureKeyReleased()),   view, SLOT(handleCaptureKeyReleased()));
   739     }
   737     }
   740 
   738 
   741     CX_DEBUG_EXIT_FUNCTION();
   739     CX_DEBUG_EXIT_FUNCTION();
   742 }
   740 }
   743 
   741