camerauis/cameraxui/cxui/src/cxuipostcaptureview.cpp
changeset 19 d9aefe59d544
child 21 fa6d9f75d6a6
child 28 3075d9b614e6
equal deleted inserted replaced
3:8b2d6d0384b0 19:d9aefe59d544
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 #include <QDebug>
       
    18 #include <QPixmap>
       
    19 #include <QTimer>
       
    20 #include <QGraphicsSceneEvent>
       
    21 #include <QFileInfo>
       
    22 #include <QApplication>
       
    23 #include <QGraphicsRectItem>
       
    24 #include <QBrush>
       
    25 #include <QDir>
       
    26 #include <QProcess>
       
    27 
       
    28 #include <hblabel.h>
       
    29 #include <hbmainwindow.h>
       
    30 #include <hbtoolbar.h>
       
    31 #include <hbaction.h>
       
    32 #include <hbmessagebox.h>
       
    33 #include <hbnotificationdialog.h>
       
    34 
       
    35 #include <shareuidialog.h>
       
    36 
       
    37 #include "cxeviewfindercontrol.h"
       
    38 #include "cxuienums.h"
       
    39 #include "cxuipostcaptureview.h"
       
    40 #include "cxeengine.h"
       
    41 #include "cxecameradevicecontrol.h"
       
    42 #include "cxestillcapturecontrol.h"
       
    43 #include "cxeviewfindercontrol.h"
       
    44 #include "cxevideocapturecontrol.h"
       
    45 #include "cxestillimage.h"
       
    46 #include "cxutils.h"
       
    47 #include "cxefeaturemanager.h"
       
    48 #include "cxuidocumentloader.h"
       
    49 #include "cxesettings.h"
       
    50 #include "cxenamespace.h"
       
    51 #include "cxuiserviceprovider.h"
       
    52 
       
    53 #include "OstTraceDefinitions.h"
       
    54 #ifdef OST_TRACE_COMPILER_IN_USE
       
    55 #include "cxuipostcaptureviewTraces.h"
       
    56 #endif
       
    57 
       
    58 
       
    59 using namespace CxUiLayout;
       
    60 using namespace Cxe;
       
    61 
       
    62 // CONSTANTS
       
    63 const int CXUI_HIDE_CONTROLS_TIMEOUT = 6000; // 6 seconds
       
    64 const QString PhotosAppExe = "photos.exe";
       
    65 const QString VideosAppExe = "videoplayer.exe";
       
    66 
       
    67 //!@todo Temporarily disabled.
       
    68 //const int CXUI_STOP_VIEWFINDER_TIMEOUT = 5000; // 5 seconds
       
    69 //const int CXUI_RELEASE_CAMERA_TIMEOUT = 10000; // 10 seconds
       
    70 
       
    71 // ---------------------------------------------------------------------------
       
    72 // CxuiPostcaptureView::CxuiPostcaptureView
       
    73 //
       
    74 // ---------------------------------------------------------------------------
       
    75 //
       
    76 CxuiPostcaptureView::CxuiPostcaptureView(QGraphicsItem *parent) :
       
    77     HbView(parent),
       
    78     mMainWindow(NULL),
       
    79     mEngine(NULL),
       
    80     mStillToolbar(NULL),
       
    81     mVideoToolbar(NULL),
       
    82     mEmbeddedToolbar(NULL),
       
    83     mBackgroundItem(NULL),
       
    84     mImageLabel(NULL),
       
    85     mHideControlsTimeout(this),
       
    86     mStopViewfinderTimer(this),
       
    87     mReleaseCameraTimer(this),
       
    88     mPostcaptureTimer(this),
       
    89     mTimersStarted(false)
       
    90 {
       
    91     CX_DEBUG_IN_FUNCTION();
       
    92 
       
    93     CX_DEBUG_EXIT_FUNCTION();
       
    94 }
       
    95 
       
    96 // ---------------------------------------------------------------------------
       
    97 // CxuiPostcaptureView::~CxuiPostcaptureView
       
    98 //
       
    99 // ---------------------------------------------------------------------------
       
   100 //
       
   101 CxuiPostcaptureView::~CxuiPostcaptureView()
       
   102 {
       
   103     CX_DEBUG_ENTER_FUNCTION();
       
   104     QCoreApplication::instance()->removeEventFilter(this);
       
   105     stopTimers();
       
   106     CX_DEBUG_EXIT_FUNCTION();
       
   107 }
       
   108 
       
   109 // ---------------------------------------------------------------------------
       
   110 // CxuiPostcaptureView::construct
       
   111 //
       
   112 // ---------------------------------------------------------------------------
       
   113 //
       
   114 void CxuiPostcaptureView::construct(HbMainWindow *mainwindow, CxeEngine *engine,
       
   115                                     CxuiDocumentLoader *documentLoader)
       
   116 {
       
   117     CX_DEBUG_ENTER_FUNCTION();
       
   118 
       
   119     mMainWindow = mainwindow;
       
   120     mEngine = engine;
       
   121     mDocumentLoader = documentLoader;
       
   122 
       
   123     // set back action to go back to pre-capture
       
   124     HbAction *backAction = new HbAction(Hb::BackNaviAction, this);
       
   125     connect(backAction, SIGNAL(triggered()), this, SLOT(goToPrecaptureView()));
       
   126     setNavigationAction(backAction);
       
   127 
       
   128     // creates black background item
       
   129     createBackground();
       
   130 
       
   131     CX_DEBUG_ASSERT(mDocumentLoader);
       
   132     QGraphicsWidget *widget = 0;
       
   133     widget = mDocumentLoader->findWidget(POST_CAPTURE_SNAPSHOT_LABEL);
       
   134     mImageLabel = qobject_cast<HbLabel *>(widget);
       
   135     CX_DEBUG_ASSERT(mImageLabel);
       
   136 
       
   137     // get toolbar pointers from the documentloader
       
   138     widget = mDocumentLoader->findWidget(STILL_POST_CAPTURE_TOOLBAR);
       
   139     mStillToolbar = qobject_cast<HbToolBar *> (widget);
       
   140     CX_DEBUG_ASSERT(mStillToolbar);
       
   141 
       
   142     widget = mDocumentLoader->findWidget(VIDEO_POST_CAPTURE_TOOLBAR);
       
   143     mVideoToolbar = qobject_cast<HbToolBar *> (widget);
       
   144     CX_DEBUG_ASSERT(mVideoToolbar);
       
   145 
       
   146     widget = mDocumentLoader->findWidget(EMBEDDED_POST_CAPTURE_TOOLBAR);
       
   147     mEmbeddedToolbar = qobject_cast<HbToolBar *> (widget);
       
   148     CX_DEBUG_ASSERT(mEmbeddedToolbar);
       
   149 
       
   150     mStopViewfinderTimer.setSingleShot(true);
       
   151     connect(&mStopViewfinderTimer, SIGNAL(timeout()),
       
   152             this, SLOT(stopViewfinder()));
       
   153 
       
   154     mReleaseCameraTimer.setSingleShot(true);
       
   155     connect(&mReleaseCameraTimer, SIGNAL(timeout()),
       
   156             this, SLOT(releaseCamera()));
       
   157 
       
   158     mHideControlsTimeout.setSingleShot(true);
       
   159     connect(&mHideControlsTimeout, SIGNAL(timeout()),
       
   160             this, SLOT(hideControls()));
       
   161 
       
   162     mPostcaptureTimer.setSingleShot(true);
       
   163     connect(&mPostcaptureTimer, SIGNAL(timeout()),
       
   164             this, SLOT(goToPrecaptureView()));
       
   165 
       
   166     // set focus flags
       
   167     setFlag(QGraphicsItem::ItemIsFocusable);
       
   168     setFocusPolicy(Qt::StrongFocus);
       
   169 
       
   170     QCoreApplication::instance()->installEventFilter(this);
       
   171     CX_DEBUG_EXIT_FUNCTION();
       
   172 }
       
   173 
       
   174 // ---------------------------------------------------------------------------
       
   175 // CxuiPostcaptureView::handleCaptureKeyPressed
       
   176 //
       
   177 // ---------------------------------------------------------------------------
       
   178 //
       
   179 void CxuiPostcaptureView::handleCaptureKeyPressed()
       
   180 {
       
   181     CX_DEBUG_ENTER_FUNCTION();
       
   182 
       
   183     goToPrecaptureView();
       
   184 
       
   185     CX_DEBUG_EXIT_FUNCTION();
       
   186 }
       
   187 
       
   188 // ---------------------------------------------------------------------------
       
   189 // CxuiPostcaptureView::handleAutofocusKeyPressed
       
   190 //
       
   191 // ---------------------------------------------------------------------------
       
   192 //
       
   193 void CxuiPostcaptureView::handleAutofocusKeyPressed()
       
   194 {
       
   195     CX_DEBUG_ENTER_FUNCTION();
       
   196 
       
   197     goToPrecaptureView();
       
   198 
       
   199     CX_DEBUG_EXIT_FUNCTION();
       
   200 }
       
   201 
       
   202 /*!
       
   203     Slot for starting video playing.
       
   204  */
       
   205 void CxuiPostcaptureView::playVideo()
       
   206 {
       
   207     launchNotSupportedNotification();
       
   208     //! @todo needs an implementation
       
   209     CX_DEBUG_IN_FUNCTION();
       
   210 }
       
   211 
       
   212 // ---------------------------------------------------------------------------
       
   213 // CxuiPostcaptureView::showDeleteNote
       
   214 //
       
   215 // ---------------------------------------------------------------------------
       
   216 //
       
   217 void CxuiPostcaptureView::showDeleteNote()
       
   218 {
       
   219     CX_DEBUG_ENTER_FUNCTION();
       
   220 
       
   221     QString filename = getCurrentFilename();
       
   222     bool ret = false;
       
   223 
       
   224     hideControls();
       
   225 
       
   226     if (mEngine->mode() == Cxe::VideoMode) {
       
   227         ret = HbMessageBox::question(hbTrId("txt_cam_other_delete_video_clip"));
       
   228     } else {
       
   229         ret = HbMessageBox::question(hbTrId("txt_cam_other_delete_image"));
       
   230     }
       
   231 
       
   232     if (ret) {
       
   233         QFileInfo fileInfo(filename);
       
   234         if (fileInfo.exists()) {
       
   235             //! @todo
       
   236             // We can retry deletion if file deletion does'nt succeed,
       
   237             // but this is left out for the time being since the user
       
   238             // can't delete it so early that it's not saved yet or
       
   239             // is being harvested by MdS etc.
       
   240             QDir dir = fileInfo.absolutePath();
       
   241             bool ok = dir.remove(fileInfo.fileName());
       
   242             CX_DEBUG(("Delete file [%s], status %d", fileInfo.fileName().toAscii().constData(), ok));
       
   243 
       
   244             // Go back to precapture view
       
   245             goToPrecaptureView();
       
   246         }
       
   247     }
       
   248 
       
   249         CX_DEBUG_EXIT_FUNCTION();
       
   250 }
       
   251 
       
   252 
       
   253 
       
   254 /*!
       
   255     Slot for handling image/video sharing.
       
   256  */
       
   257 void CxuiPostcaptureView::launchShare()
       
   258 {
       
   259     CX_DEBUG_ENTER_FUNCTION();
       
   260     
       
   261     stopTimers();
       
   262     stopViewfinder();
       
   263     releaseCamera();
       
   264         
       
   265     QString filename = getCurrentFilename();
       
   266     
       
   267     QVariantList filelist;
       
   268     filelist.append(QVariant(filename));
       
   269     
       
   270     ShareUi dialog;
       
   271     dialog.init(filelist, true);
       
   272     
       
   273     showControls();
       
   274     
       
   275     CX_DEBUG_EXIT_FUNCTION();
       
   276 }
       
   277 
       
   278 // ---------------------------------------------------------------------------
       
   279 // CxuiPostcaptureView::goToPrecaptureView
       
   280 //
       
   281 // ---------------------------------------------------------------------------
       
   282 //
       
   283 void CxuiPostcaptureView::goToPrecaptureView()
       
   284 {
       
   285     CX_DEBUG_ENTER_FUNCTION();
       
   286 
       
   287     // Cannot return to post-capture while stopping in video mode
       
   288     if (mEngine->mode() != Cxe::VideoMode ||
       
   289         mEngine->videoCaptureControl().state() != CxeVideoCaptureControl::Stopping) {
       
   290         stopTimers();
       
   291         // Make sure engine prepares for new image/video if necessary
       
   292         mEngine->initMode(mEngine->mode());
       
   293 
       
   294         // enables starting of timers in postcaptureview
       
   295         mTimersStarted = false;
       
   296 
       
   297         // Switch to pre-capture view
       
   298         emit changeToPrecaptureView();
       
   299     }
       
   300 
       
   301     CX_DEBUG_EXIT_FUNCTION();
       
   302 }
       
   303 
       
   304 // ---------------------------------------------------------------------------
       
   305 // CxuiPostcaptureView::stopViewfinder
       
   306 //
       
   307 // ---------------------------------------------------------------------------
       
   308 //
       
   309 void CxuiPostcaptureView::stopViewfinder()
       
   310 {
       
   311     CX_DEBUG_ENTER_FUNCTION();
       
   312 
       
   313     if (mMainWindow->currentView() == this) {
       
   314         mEngine->viewfinderControl().stop();
       
   315     }
       
   316     mStopViewfinderTimer.stop();
       
   317 
       
   318     CX_DEBUG_EXIT_FUNCTION();
       
   319 }
       
   320 
       
   321 // ---------------------------------------------------------------------------
       
   322 // CxuiPostcaptureView::releaseCamera
       
   323 //
       
   324 // ---------------------------------------------------------------------------
       
   325 //
       
   326 void CxuiPostcaptureView::releaseCamera()
       
   327 {
       
   328     CX_DEBUG_ENTER_FUNCTION();
       
   329 
       
   330     if (mMainWindow->currentView() == this) {
       
   331         mEngine->cameraDeviceControl().release();
       
   332     }
       
   333     mReleaseCameraTimer.stop();
       
   334 
       
   335     CX_DEBUG_EXIT_FUNCTION();
       
   336 }
       
   337 
       
   338 // ---------------------------------------------------------------------------
       
   339 // CxuiPostcaptureView::hideControls
       
   340 //
       
   341 // ---------------------------------------------------------------------------
       
   342 //
       
   343 void CxuiPostcaptureView::hideControls()
       
   344 {
       
   345     CX_DEBUG_ENTER_FUNCTION();
       
   346 
       
   347     if (mStillToolbar) {
       
   348         mStillToolbar->hide();
       
   349     }
       
   350     if (mVideoToolbar) {
       
   351         mVideoToolbar->hide();
       
   352     }
       
   353     if (mEmbeddedToolbar) {
       
   354         mEmbeddedToolbar->hide();
       
   355     }
       
   356 
       
   357     hideItems(Hb::AllItems);
       
   358 
       
   359     mControlsVisible = false;
       
   360 
       
   361     // stop hiding control timer
       
   362     mHideControlsTimeout.stop();
       
   363 
       
   364 
       
   365     // give the keyboard focus back to the view
       
   366     // for the view to receive key events
       
   367     setFocus();
       
   368 
       
   369     CX_DEBUG_EXIT_FUNCTION();
       
   370 }
       
   371 
       
   372 // ---------------------------------------------------------------------------
       
   373 // CxuiPostcaptureView::showControls
       
   374 //
       
   375 // ---------------------------------------------------------------------------
       
   376 //
       
   377 void CxuiPostcaptureView::showControls()
       
   378 {
       
   379     CX_DEBUG_ENTER_FUNCTION();
       
   380 
       
   381     showToolbar();
       
   382 
       
   383     showItems(Hb::AllItems);
       
   384 
       
   385     mHideControlsTimeout.start(CXUI_HIDE_CONTROLS_TIMEOUT);
       
   386     mControlsVisible = true;
       
   387 
       
   388     CX_DEBUG_EXIT_FUNCTION();
       
   389 }
       
   390 
       
   391 // ---------------------------------------------------------------------------
       
   392 // CxuiPostcaptureView::toggleControls
       
   393 //
       
   394 // ---------------------------------------------------------------------------
       
   395 //
       
   396 void CxuiPostcaptureView::toggleControls()
       
   397 {
       
   398     CX_DEBUG_ENTER_FUNCTION();
       
   399 
       
   400     if (mControlsVisible) {
       
   401         hideControls();
       
   402     } else {
       
   403         showControls();
       
   404     }
       
   405 
       
   406     CX_DEBUG_EXIT_FUNCTION();
       
   407 }
       
   408 
       
   409 // ---------------------------------------------------------------------------
       
   410 // CxuiPostcaptureView::eventFilter
       
   411 //
       
   412 // ---------------------------------------------------------------------------
       
   413 //
       
   414 bool CxuiPostcaptureView::eventFilter(QObject *object, QEvent *event)
       
   415 {
       
   416     Q_UNUSED(object)
       
   417 
       
   418     bool eventWasConsumed = false;
       
   419 
       
   420     switch (event->type())
       
   421     {
       
   422     case QEvent::GraphicsSceneMouseRelease:
       
   423         mHideControlsTimeout.start();
       
   424         break;
       
   425     case QEvent::GraphicsSceneMousePress:
       
   426         mHideControlsTimeout.stop();
       
   427         // stop the postcapture timer
       
   428         mPostcaptureTimer.stop();
       
   429         break;
       
   430     default:
       
   431         break;
       
   432     }
       
   433 
       
   434     return eventWasConsumed;
       
   435 }
       
   436 
       
   437 /*!
       
   438 * Paint event.
       
   439 * Used for performance tracing (snapshot latency).
       
   440 */
       
   441 bool CxuiPostcaptureView::event(QEvent *event)
       
   442 {
       
   443     bool processed(HbView::event(event));
       
   444     if (event && event->type() == QEvent::Paint) {
       
   445         OstTrace0(camerax_performance, CXUIPOSTCAPTUREVIEW_SNAPSHOT_DRAW, "msg: e_CX_SHOT_TO_SNAPSHOT 0");
       
   446     }
       
   447     return processed;
       
   448 }
       
   449 
       
   450 // ---------------------------------------------------------------------------
       
   451 // CxuiPostcaptureView::mousePressEvent
       
   452 //
       
   453 // ---------------------------------------------------------------------------
       
   454 //
       
   455 void CxuiPostcaptureView::mousePressEvent(QGraphicsSceneMouseEvent *event)
       
   456 {
       
   457 
       
   458     if (event->type() == QEvent::GraphicsSceneMousePress) {
       
   459         mPostcaptureTimer.stop();
       
   460         toggleControls();
       
   461         event->accept();
       
   462     }
       
   463 
       
   464 }
       
   465 
       
   466 // ---------------------------------------------------------------------------
       
   467 // CxuiPostcaptureView::showEvent
       
   468 //
       
   469 // ---------------------------------------------------------------------------
       
   470 //
       
   471 void CxuiPostcaptureView::showEvent(QShowEvent *event)
       
   472 {
       
   473     CX_DEBUG_ENTER_FUNCTION();
       
   474 
       
   475     QGraphicsWidget::showEvent(event);
       
   476 
       
   477     if (event->type() == QEvent::Show) {
       
   478         QCoreApplication::instance()->installEventFilter(this);
       
   479 
       
   480         updateSnapshotImage();
       
   481         showControls();
       
   482         startTimers();
       
   483         event->accept();
       
   484     }
       
   485 
       
   486     CX_DEBUG_EXIT_FUNCTION();
       
   487 }
       
   488 
       
   489 // ---------------------------------------------------------------------------
       
   490 // CxuiPostcaptureView::hideEvent
       
   491 //
       
   492 // ---------------------------------------------------------------------------
       
   493 //
       
   494 void CxuiPostcaptureView::hideEvent(QHideEvent *event)
       
   495 {
       
   496     CX_DEBUG_ENTER_FUNCTION();
       
   497 
       
   498     QGraphicsWidget::hideEvent(event);
       
   499 
       
   500     if (event->type() == QEvent::Hide) {
       
   501         // remove event filter to disable unnecessary actions
       
   502         QCoreApplication::instance()->removeEventFilter(this);
       
   503 
       
   504         stopTimers();
       
   505         // Hide controls to make sure title bar reacts to show()
       
   506         // when this view is reactivated.
       
   507         hideControls();
       
   508         event->accept();
       
   509     }
       
   510 
       
   511     CX_DEBUG_EXIT_FUNCTION();
       
   512 }
       
   513 
       
   514 /*! Shows toolbar.
       
   515     Toolbar that is shown is selected based on current mode.
       
   516  */
       
   517 void CxuiPostcaptureView::showToolbar(){
       
   518 
       
   519     CX_DEBUG_ENTER_FUNCTION();
       
   520 
       
   521     if (CxuiServiceProvider::isCameraEmbedded()) {
       
   522         mEmbeddedToolbar->setVisible(true);
       
   523         mStillToolbar->setVisible(false);
       
   524         mVideoToolbar->setVisible(false);
       
   525     } else {
       
   526         mEmbeddedToolbar->setVisible(false);
       
   527         if (mEngine->mode() == ImageMode) {
       
   528             mVideoToolbar->setVisible(false);
       
   529             mStillToolbar->setVisible(true);
       
   530             mStillToolbar->show();
       
   531         } else {
       
   532             mStillToolbar->setVisible(false);
       
   533             mVideoToolbar->setVisible(true);
       
   534             mVideoToolbar->show();
       
   535         }
       
   536     }
       
   537 
       
   538     CX_DEBUG_EXIT_FUNCTION();
       
   539 }
       
   540 
       
   541 /*!
       
   542     Creates black background item. If snapshot smaller than the screen size,
       
   543     background is visible.
       
   544  */
       
   545 void CxuiPostcaptureView::createBackground()
       
   546 {
       
   547     CX_DEBUG_ENTER_FUNCTION();
       
   548 
       
   549     if (!mBackgroundItem) {
       
   550         mBackgroundItem = new QGraphicsRectItem(this);
       
   551         QBrush blackBrush = QBrush(Qt::black);
       
   552         mBackgroundItem->setBrush(blackBrush);
       
   553         mBackgroundItem->setRect(mMainWindow->sceneRect());
       
   554     }
       
   555 
       
   556     CX_DEBUG_EXIT_FUNCTION();
       
   557 }
       
   558 
       
   559 // ---------------------------------------------------------------------------
       
   560 // CxuiPostcaptureView::setImage
       
   561 //
       
   562 // ---------------------------------------------------------------------------
       
   563 //
       
   564 void CxuiPostcaptureView::updateSnapshotImage()
       
   565 {
       
   566     CX_DEBUG_ENTER_FUNCTION();
       
   567 
       
   568     QPixmap snapshot;
       
   569 
       
   570     if (mEngine->mode() == ImageMode) {
       
   571         if( mEngine->stillCaptureControl().imageCount() > 0 ) {
       
   572             snapshot = mEngine->stillCaptureControl()[0].snapshot();
       
   573         }
       
   574     } else {
       
   575         snapshot = mEngine->videoCaptureControl().snapshot();
       
   576     }
       
   577 
       
   578     if (mImageLabel) {
       
   579         mImageLabel->setIcon(HbIcon(QIcon(snapshot)));
       
   580     } else {
       
   581         // do nothing
       
   582     }
       
   583 
       
   584     CX_DEBUG_EXIT_FUNCTION();
       
   585 }
       
   586 
       
   587 /*!
       
   588     Launches "Not supported yet" notification.
       
   589  */
       
   590 void CxuiPostcaptureView::launchNotSupportedNotification()
       
   591 {
       
   592     CX_DEBUG_ENTER_FUNCTION();
       
   593 
       
   594     // Instantiate a popup
       
   595     HbNotificationDialog note;
       
   596     note.setTitle("Notification");
       
   597     note.setText("Not supported yet");
       
   598     note.exec();
       
   599 
       
   600     CX_DEBUG_EXIT_FUNCTION();
       
   601 }
       
   602 
       
   603 /* !
       
   604  * gets the filename of the current file
       
   605  */
       
   606 QString CxuiPostcaptureView::getCurrentFilename()
       
   607 {
       
   608     CX_DEBUG_ENTER_FUNCTION();
       
   609 
       
   610     QString filename;
       
   611 
       
   612     if (mEngine->mode() == Cxe::VideoMode) {
       
   613         filename = mEngine->videoCaptureControl().filename();
       
   614     } else {
       
   615         //!@todo Currently only gets index 0 from the still capture control.
       
   616         CxeStillCaptureControl& stillCaptureControl = mEngine->stillCaptureControl();
       
   617         if (stillCaptureControl.imageCount()) {
       
   618             filename = stillCaptureControl[0].filename();
       
   619         }
       
   620     }
       
   621     CX_DEBUG((filename.toAscii()));
       
   622 
       
   623     CX_DEBUG_EXIT_FUNCTION();
       
   624 
       
   625     return filename;
       
   626 }
       
   627 
       
   628 /*!
       
   629     Launches the Photos applications as a separate process
       
   630 */
       
   631 void CxuiPostcaptureView::launchPhotosApp()
       
   632 {
       
   633     QProcess::startDetached(PhotosAppExe);
       
   634 }
       
   635 
       
   636 /*!
       
   637     Sends current capture to client app and closes camera
       
   638 */
       
   639 void CxuiPostcaptureView::select()
       
   640 {
       
   641     CxuiServiceProvider *serviceProvider = CxuiServiceProvider::instance();
       
   642     if (!serviceProvider) {
       
   643         return;
       
   644     }
       
   645 
       
   646     QString filename = getCurrentFilename();
       
   647     serviceProvider->sendFilenameToClientAndExit(filename);
       
   648 }
       
   649 
       
   650 /*!
       
   651     Launches the Videos applications as a separate process
       
   652 */
       
   653 void CxuiPostcaptureView::launchVideosApp()
       
   654 {
       
   655     //Releasing cameda device in order to free
       
   656     //graphical memory
       
   657     releaseCamera();
       
   658     QProcess::startDetached(VideosAppExe);
       
   659 }
       
   660 
       
   661 /*!
       
   662     Handle cases when we loose focus
       
   663 */
       
   664 void CxuiPostcaptureView::handleFocusLost()
       
   665 {
       
   666     CX_DEBUG_ENTER_FUNCTION();
       
   667 
       
   668     // we have lost focus
       
   669     releaseCamera();
       
   670     stopTimers();
       
   671     hideControls();
       
   672 
       
   673     CX_DEBUG_EXIT_FUNCTION();
       
   674 }
       
   675 
       
   676 
       
   677 void CxuiPostcaptureView::startTimers()
       
   678 {
       
   679     CX_DEBUG_ENTER_FUNCTION();
       
   680 
       
   681     // we start timers only once in a given postcapture view session
       
   682     if (!mTimersStarted) {
       
   683         int postCaptureTimeout = 0;
       
   684         QString settingId;
       
   685 
       
   686         if (mEngine->mode() == ImageMode) {
       
   687             settingId = CxeSettingIds::STILL_SHOWCAPTURED;
       
   688         } else {
       
   689             settingId = CxeSettingIds::VIDEO_SHOWCAPTURED;
       
   690         }
       
   691 
       
   692         if (!CxuiServiceProvider::isCameraEmbedded()) {
       
   693             CxeError::Id err = mEngine->settings().get(settingId, postCaptureTimeout);
       
   694 
       
   695             if (postCaptureTimeout > 0 && err == CxeError::None) {
       
   696                 mPostcaptureTimer.start(postCaptureTimeout);
       
   697             } else {
       
   698                 // do nothing
       
   699             }
       
   700         }
       
   701 
       
   702         // start the hide control timer.
       
   703         mHideControlsTimeout.start(CXUI_HIDE_CONTROLS_TIMEOUT);
       
   704 
       
   705         //! @todo Temporarily disabling release timer because of
       
   706         // graphics memory problems related to releasing and reserving again.
       
   707         // mReleaseCameraTimer.start(CXUI_RELEASE_CAMERA_TIMEOUT);
       
   708         // mStopViewfinderTimer.start(CXUI_STOP_VIEWFINDER_TIMEOUT);
       
   709 
       
   710         // we make sure that timers are started only once in a given postcaptureview session
       
   711         mTimersStarted = true;
       
   712     }
       
   713 
       
   714     // show controls when we get back focus
       
   715     showControls();
       
   716 
       
   717     CX_DEBUG_EXIT_FUNCTION();
       
   718 }
       
   719 
       
   720 void CxuiPostcaptureView::stopTimers()
       
   721 {
       
   722     CX_DEBUG_ENTER_FUNCTION();
       
   723 
       
   724     // stop all the timers
       
   725     mHideControlsTimeout.stop();
       
   726     mReleaseCameraTimer.stop();
       
   727     mPostcaptureTimer.stop();
       
   728     mStopViewfinderTimer.stop();
       
   729 
       
   730     mTimersStarted = false;
       
   731 
       
   732     CX_DEBUG_EXIT_FUNCTION();
       
   733 }
       
   734 
       
   735 // end of file