camerauis/cameraxui/cxui/src/cxuiview.cpp
changeset 37 64817133cd1d
parent 36 b12f3922a74f
child 42 feebad15db8c
child 48 42ba2d16bf40
equal deleted inserted replaced
36:b12f3922a74f 37:64817133cd1d
    63 /*!
    63 /*!
    64 * CxuiView::construct
    64 * CxuiView::construct
    65 */
    65 */
    66 void CxuiView::construct(HbMainWindow *mainWindow, CxeEngine *engine,
    66 void CxuiView::construct(HbMainWindow *mainWindow, CxeEngine *engine,
    67                          CxuiDocumentLoader *documentLoader,
    67                          CxuiDocumentLoader *documentLoader,
    68                          CxuiCaptureKeyHandler * keyHandler)
    68                          CxuiCaptureKeyHandler * keyHandler,
       
    69                          HbActivityManager *activityManager)
    69 {
    70 {
    70     CX_DEBUG_ENTER_FUNCTION();
    71     CX_DEBUG_ENTER_FUNCTION();
    71 
    72 
    72     //Minimum requirements to construct the view
    73     //Minimum requirements to construct the view
    73     CX_ASSERT_ALWAYS(mainWindow);
    74     CX_ASSERT_ALWAYS(mainWindow);
    74     CX_ASSERT_ALWAYS(engine);
    75     CX_ASSERT_ALWAYS(engine);
    75     CX_ASSERT_ALWAYS(documentLoader);
    76     CX_ASSERT_ALWAYS(documentLoader);
       
    77     CX_ASSERT_ALWAYS(activityManager);
    76 
    78 
    77     mMainWindow = mainWindow;
    79     mMainWindow = mainWindow;
    78     mDocumentLoader = documentLoader;
    80     mDocumentLoader = documentLoader;
    79     mCaptureKeyHandler = keyHandler;
    81     mCaptureKeyHandler = keyHandler;
    80     mEngine = engine;
    82     mEngine = engine;
       
    83     mActivityManager = activityManager;
    81 
    84 
    82     // adjust the timer, and connect it to correct slot
    85     // adjust the timer, and connect it to correct slot
    83     connect(&mHideControlsTimeout, SIGNAL(timeout()), this, SLOT(hideControls()));
    86     connect(&mHideControlsTimeout, SIGNAL(timeout()), this, SLOT(hideControls()));
    84     mHideControlsTimeout.setSingleShot(true);
    87     mHideControlsTimeout.setSingleShot(true);
    85     mHideControlsTimeout.setInterval(CXUI_HIDE_CONTROLS_TIMEOUT);
    88     mHideControlsTimeout.setInterval(CXUI_HIDE_CONTROLS_TIMEOUT);
    86 }
    89 }
       
    90 
       
    91 /*!
       
    92 * Is standby mode supported / needed by this view.
       
    93 * Default implementation returns false.
       
    94 * Inherited classes need to re-implement this if standby mode is needed.
       
    95 * @return True if standby mode is supported, false otherwise.
       
    96 */
       
    97 bool CxuiView::isStandbyModeSupported() const
       
    98 {
       
    99     return false;
       
   100 }
       
   101 
    87 
   102 
    88 /*!
   103 /*!
    89 * CxuiView::updateOrientation
   104 * CxuiView::updateOrientation
    90 */
   105 */
    91 void CxuiView::updateOrientation(Qt::Orientation orientation)
   106 void CxuiView::updateOrientation(Qt::Orientation orientation)
   104     }
   119     }
   105 
   120 
   106     CX_DEBUG_EXIT_FUNCTION();
   121     CX_DEBUG_EXIT_FUNCTION();
   107 }
   122 }
   108 
   123 
       
   124 
       
   125 /*!
       
   126  * Restore view state from activity. Default implementation does nothing.
       
   127  */
       
   128 void CxuiView::restoreActivity(const QString &activityId, const QVariant &data)
       
   129 {
       
   130     Q_UNUSED(activityId);
       
   131     Q_UNUSED(data);
       
   132 }
       
   133 
       
   134 /*!
       
   135  * Save view state to activity. Default implementation does nothing.
       
   136  */
       
   137 void CxuiView::saveActivity()
       
   138 {
       
   139 
       
   140 }
       
   141 
       
   142 /*!
       
   143  * Clear activity from activity manager. Default implementation does nothing.
       
   144  */
       
   145 void CxuiView::clearActivity()
       
   146 {
       
   147 
       
   148 }
       
   149 
   109 /*!
   150 /*!
   110 * Allow showing UI controls?
   151 * Allow showing UI controls?
   111 * Default behaviour is that controls can be shown at any time.
   152 * Default behaviour is that controls can be shown at any time.
   112 */
   153 */
   113 bool CxuiView::allowShowControls() const
   154 bool CxuiView::allowShowControls() const
       
   155 {
       
   156     return true;
       
   157 }
       
   158 
       
   159 /*!
       
   160  * Play feedback when touching view outside of any widget?
       
   161  * Default behaviour is that feedback is always played.
       
   162  */
       
   163 bool CxuiView::isFeedbackEnabled() const
   114 {
   164 {
   115     return true;
   165     return true;
   116 }
   166 }
   117 
   167 
   118 /*!
   168 /*!
   130 
   180 
   131     CX_DEBUG_EXIT_FUNCTION();
   181     CX_DEBUG_EXIT_FUNCTION();
   132 }
   182 }
   133 
   183 
   134 /*!
   184 /*!
       
   185 * Slot for entering standby mode.
       
   186 * By default, release camera.
       
   187 */
       
   188 void CxuiView::enterStandby()
       
   189 {
       
   190     CX_DEBUG_IN_FUNCTION();
       
   191     releaseCamera();
       
   192     CX_DEBUG_IN_FUNCTION();
       
   193 }
       
   194 
       
   195 /*!
       
   196 * Slot for exiting standby mode.
       
   197 * By default, no action needed.
       
   198 */
       
   199 void CxuiView::exitStandby()
       
   200 {
       
   201     CX_DEBUG_IN_FUNCTION();
       
   202 }
       
   203 
       
   204 /*!
   135 * CxuiView::launchNotSupportedNotification
   205 * CxuiView::launchNotSupportedNotification
   136 * Show "not supported" notification.
   206 * Show "not supported" notification.
   137 */
   207 */
   138 void CxuiView::launchNotSupportedNotification()
   208 void CxuiView::launchNotSupportedNotification()
   139 {
   209 {
   156 /*!
   226 /*!
   157  * CxuiView::launchPhotosApp
   227  * CxuiView::launchPhotosApp
   158  */
   228  */
   159 void CxuiView::launchPhotosApp()
   229 void CxuiView::launchPhotosApp()
   160 {
   230 {
       
   231     // Release camera device in order to free resources for Photos application
       
   232     releaseCamera();
   161     QProcess::startDetached(PhotosAppExe);
   233     QProcess::startDetached(PhotosAppExe);
   162 }
   234 }
   163 
   235 
   164 /*!
   236 /*!
   165  * CxuiView::launchVideosApp
   237  * CxuiView::launchVideosApp
   166  * Launching Videos application as a separate process
   238  * Launching Videos application as a separate process
   167  */
   239  */
   168 void CxuiView::launchVideosApp()
   240 void CxuiView::launchVideosApp()
   169 {
   241 {
   170     //Releasing cameda device in order to free
   242     // Release camera device in order to free resources for Videos application
   171     //graphical memory
       
   172     releaseCamera();
   243     releaseCamera();
   173     QProcess::startDetached(VideosAppExe);
   244     QProcess::startDetached(VideosAppExe);
   174 }
   245 }
   175 
   246 
   176 /*!
   247 /*!
   365  * \param event event to be handled
   436  * \param event event to be handled
   366  */
   437  */
   367 void CxuiView::mousePressEvent(QGraphicsSceneMouseEvent *event)
   438 void CxuiView::mousePressEvent(QGraphicsSceneMouseEvent *event)
   368 {
   439 {
   369     //! @todo temporary workaround for title bar mouse event handling bug
   440     //! @todo temporary workaround for title bar mouse event handling bug
   370     if (event->type() == QEvent::GraphicsSceneMousePress && event->scenePos().y() > 70) {
   441     if (event->type() == QEvent::GraphicsSceneMousePress && event->scenePos().y() > 70 &&
       
   442         isFeedbackEnabled()) {
   371         mControlsFeedback.setModalities(HbFeedback::All);
   443         mControlsFeedback.setModalities(HbFeedback::All);
   372         mControlsFeedback.play();
   444         mControlsFeedback.play();
   373         event->accept();
   445         event->accept();
   374     }
   446     }
   375 }
   447 }
   380  * \param event to be handled
   452  * \param event to be handled
   381  */
   453  */
   382 void CxuiView::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
   454 void CxuiView::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
   383 {
   455 {
   384     //! @todo temporary workaround for title bar mouse event handling bug
   456     //! @todo temporary workaround for title bar mouse event handling bug
   385     if (event->type() == QEvent::GraphicsSceneMouseRelease && event->scenePos().y() > 70) {
   457     if (event->type() == QEvent::GraphicsSceneMouseRelease && event->scenePos().y() > 70 &&
       
   458         isFeedbackEnabled()) {
   386         // todo: sound disabling doesn't work in orbit yet so don't do feedback on release
   459         // todo: sound disabling doesn't work in orbit yet so don't do feedback on release
   387         // needs to be enabled when orbit support is done
   460         // needs to be enabled when orbit support is done
   388         //mControlsFeedback.setModalities(HbFeedback::Tactile);
   461         //mControlsFeedback.setModalities(HbFeedback::Tactile);
   389         //mControlsFeedback.play();
   462         //mControlsFeedback.play();
   390         toggleControls();
   463         toggleControls();
   391         event->accept();
   464         event->accept();
   392     }
   465     }
   393 }
   466 }
       
   467 
   394 // End of file
   468 // End of file