camerauis/cameraxui/cxui/src/cxuipostcaptureview.cpp
changeset 48 42ba2d16bf40
parent 37 64817133cd1d
child 63 415ff50d2eca
equal deleted inserted replaced
37:64817133cd1d 48:42ba2d16bf40
    27 #include <hblabel.h>
    27 #include <hblabel.h>
    28 #include <hbmainwindow.h>
    28 #include <hbmainwindow.h>
    29 #include <hbtoolbar.h>
    29 #include <hbtoolbar.h>
    30 #include <hbaction.h>
    30 #include <hbaction.h>
    31 #include <hbmessagebox.h>
    31 #include <hbmessagebox.h>
    32 #include <hbnotificationdialog.h>
       
    33 #include <hbactivitymanager.h>
    32 #include <hbactivitymanager.h>
    34 
    33 
       
    34 #include <xqaiwdecl.h>
    35 #include <shareui.h>
    35 #include <shareui.h>
    36 #include <thumbnailmanager_qt.h>
    36 #include <thumbnailmanager_qt.h>
    37 
    37 
    38 #include "cxeviewfindercontrol.h"
    38 #include "cxeviewfindercontrol.h"
    39 #include "cxuienums.h"
    39 #include "cxuienums.h"
    48 #include "cxuidocumentloader.h"
    48 #include "cxuidocumentloader.h"
    49 #include "cxesettings.h"
    49 #include "cxesettings.h"
    50 #include "cxenamespace.h"
    50 #include "cxenamespace.h"
    51 #include "cxuiserviceprovider.h"
    51 #include "cxuiserviceprovider.h"
    52 
    52 
       
    53 #ifdef Q_OS_SYMBIAN
    53 #include "OstTraceDefinitions.h"
    54 #include "OstTraceDefinitions.h"
    54 #ifdef OST_TRACE_COMPILER_IN_USE
    55 #ifdef OST_TRACE_COMPILER_IN_USE
    55 #include "cxuipostcaptureviewTraces.h"
    56 #include "cxuipostcaptureviewTraces.h"
    56 #endif
    57 #endif
       
    58 #endif //Q_OS_SYMBIAN
    57 
    59 
    58 
    60 
    59 using namespace CxUiLayout;
    61 using namespace CxUiLayout;
    60 using namespace Cxe;
    62 using namespace Cxe;
    61 
    63 
    62 
    64 
    63 namespace {
    65 namespace {
    64     const QString FILENAME_KEY = "filename";
    66     const QString FILENAME_KEY = "filename";
    65     const int CXUI_STOP_VIEWFINDER_TIMEOUT = 5000; //  5 seconds
    67     const int CXUI_STOP_VIEWFINDER_TIMEOUT = 5000; //  5 seconds
    66     const int CXUI_RELEASE_CAMERA_TIMEOUT = 60000; // 60 seconds
    68     const int CXUI_RELEASE_CAMERA_TIMEOUT = 60000; // 60 seconds
    67 };
    69 }
    68 
    70 
    69 
    71 
    70 // ---------------------------------------------------------------------------
    72 /*!
    71 // CxuiPostcaptureView::CxuiPostcaptureView
    73 * Constructor.
    72 //
    74 */
    73 // ---------------------------------------------------------------------------
       
    74 //
       
    75 CxuiPostcaptureView::CxuiPostcaptureView(QGraphicsItem *parent) :
    75 CxuiPostcaptureView::CxuiPostcaptureView(QGraphicsItem *parent) :
    76     CxuiView(parent),
    76     CxuiView(parent),
    77     mStillToolbar(NULL),
    77     mStillToolbar(NULL),
    78     mVideoToolbar(NULL),
    78     mVideoToolbar(NULL),
    79     mEmbeddedToolbar(NULL),
    79     mEmbeddedToolbar(NULL),
    91     CX_DEBUG_IN_FUNCTION();
    91     CX_DEBUG_IN_FUNCTION();
    92 
    92 
    93     CX_DEBUG_EXIT_FUNCTION();
    93     CX_DEBUG_EXIT_FUNCTION();
    94 }
    94 }
    95 
    95 
    96 // ---------------------------------------------------------------------------
    96 /*!
    97 // CxuiPostcaptureView::~CxuiPostcaptureView
    97 * Destructor.
    98 //
    98 */
    99 // ---------------------------------------------------------------------------
       
   100 //
       
   101 CxuiPostcaptureView::~CxuiPostcaptureView()
    99 CxuiPostcaptureView::~CxuiPostcaptureView()
   102 {
   100 {
   103     CX_DEBUG_ENTER_FUNCTION();
   101     CX_DEBUG_ENTER_FUNCTION();
   104     QCoreApplication::instance()->removeEventFilter(this);
   102     QCoreApplication::instance()->removeEventFilter(this);
   105     stopTimers();
   103     stopTimers();
   106     delete mThumbnailManager;
   104     delete mThumbnailManager;
   107     delete mShareUi;
   105     delete mShareUi;
   108     CX_DEBUG_EXIT_FUNCTION();
   106     CX_DEBUG_EXIT_FUNCTION();
   109 }
   107 }
   110 
   108 
   111 // ---------------------------------------------------------------------------
   109 /*!
   112 // CxuiPostcaptureView::construct
   110 * Second phase construction.
   113 //
   111 */
   114 // ---------------------------------------------------------------------------
       
   115 //
       
   116 void CxuiPostcaptureView::construct(HbMainWindow *mainwindow, CxeEngine *engine,
   112 void CxuiPostcaptureView::construct(HbMainWindow *mainwindow, CxeEngine *engine,
   117                                     CxuiDocumentLoader *documentLoader,
   113                                     CxuiDocumentLoader *documentLoader,
   118                                     CxuiCaptureKeyHandler *keyHandler,
   114                                     CxuiCaptureKeyHandler *keyHandler,
   119                                     HbActivityManager *activityManager)
   115                                     HbActivityManager *activityManager)
   120 {
   116 {
       
   117     Q_UNUSED(keyHandler);
   121     CX_DEBUG_ENTER_FUNCTION();
   118     CX_DEBUG_ENTER_FUNCTION();
   122 
   119 
   123     CxuiView::construct(mainwindow, engine, documentLoader, NULL, activityManager);
   120     CxuiView::construct(mainwindow, engine, documentLoader, NULL, activityManager);
   124 
   121 
   125     // set back action to go back to pre-capture
   122     // set back action to go back to pre-capture
   179 
   176 
   180     QCoreApplication::instance()->installEventFilter(this);
   177     QCoreApplication::instance()->installEventFilter(this);
   181     CX_DEBUG_EXIT_FUNCTION();
   178     CX_DEBUG_EXIT_FUNCTION();
   182 }
   179 }
   183 
   180 
   184 // ---------------------------------------------------------------------------
   181 /*!
   185 // CxuiPostcaptureView::handleCaptureKeyPressed
   182 * Handle pressing capture key.
   186 //
   183 */
   187 // ---------------------------------------------------------------------------
       
   188 //
       
   189 void CxuiPostcaptureView::handleCaptureKeyPressed()
   184 void CxuiPostcaptureView::handleCaptureKeyPressed()
   190 {
   185 {
   191     CX_DEBUG_ENTER_FUNCTION();
   186     CX_DEBUG_ENTER_FUNCTION();
   192 
   187 
   193     if (!mDeleteNoteOpen) {
   188     if (!mDeleteNoteOpen) {
   195     }
   190     }
   196 
   191 
   197     CX_DEBUG_EXIT_FUNCTION();
   192     CX_DEBUG_EXIT_FUNCTION();
   198 }
   193 }
   199 
   194 
   200 // ---------------------------------------------------------------------------
   195 /*!
   201 // CxuiPostcaptureView::handleAutofocusKeyPressed
   196 * Handle pressing auto focus key.
   202 //
   197 */
   203 // ---------------------------------------------------------------------------
       
   204 //
       
   205 void CxuiPostcaptureView::handleAutofocusKeyPressed()
   198 void CxuiPostcaptureView::handleAutofocusKeyPressed()
   206 {
   199 {
   207     CX_DEBUG_ENTER_FUNCTION();
   200     CX_DEBUG_ENTER_FUNCTION();
   208 
   201 
   209     if (!mDeleteNoteOpen) {
   202     if (!mDeleteNoteOpen) {
   223     stopTimers();
   216     stopTimers();
   224     releaseCamera();
   217     releaseCamera();
   225 
   218 
   226     QString videoFile(getCurrentFilename());
   219     QString videoFile(getCurrentFilename());
   227 
   220 
   228     XQAiwRequest *videoRequest = mAppManager.create(
   221     XQAiwRequest *videoRequest = mAppManager.create(XQI_VIDEO_PLAY, XQOP_VIDEO_PLAY, true);
   229         "com.nokia.symbian.IVideoView","playMedia(QString)", true);
       
   230 
   222 
   231     if (videoRequest) {
   223     if (videoRequest) {
   232         QVariantList fileList;
   224         QVariantList fileList;
   233         fileList.append(QVariant(videoFile));
   225         fileList.append(QVariant(videoFile));
   234         videoRequest->setArguments(fileList);
   226         videoRequest->setArguments(fileList);
   236         CX_DEBUG(("CxuiPostcaptureView: sending request"));
   228         CX_DEBUG(("CxuiPostcaptureView: sending request"));
   237         QVariant result;
   229         QVariant result;
   238         bool res = videoRequest->send(result);
   230         bool res = videoRequest->send(result);
   239         if (res) {
   231         if (res) {
   240             CX_DEBUG(("CxuiPostcaptureView: request sent, received \"%s\"",
   232             CX_DEBUG(("CxuiPostcaptureView: request sent, received \"%s\"",
   241                       result.toString().toAscii().constData()));
   233                       qPrintable(result.toString())));
   242         } else {
   234         } else {
   243             CX_DEBUG(("CxuiPostcaptureView: request sending failed, error=%d",
   235             CX_DEBUG(("CxuiPostcaptureView: request sending failed, error=%d",
   244                       videoRequest->lastError()));
   236                       videoRequest->lastError()));
   245         }
   237         }
   246         delete videoRequest;
   238         delete videoRequest;
   249 
   241 
   250     CX_DEBUG_EXIT_FUNCTION();
   242     CX_DEBUG_EXIT_FUNCTION();
   251 
   243 
   252 }
   244 }
   253 
   245 
   254 // ---------------------------------------------------------------------------
   246 /*!
   255 // CxuiPostcaptureView::showDeleteNote
   247 * Show delete query.
   256 //
   248 */
   257 // ---------------------------------------------------------------------------
       
   258 //
       
   259 void CxuiPostcaptureView::showDeleteNote()
   249 void CxuiPostcaptureView::showDeleteNote()
   260 {
   250 {
   261     CX_DEBUG_ENTER_FUNCTION();
   251     CX_DEBUG_ENTER_FUNCTION();
   262 
   252 
   263     hideControls();
   253     hideControls();
   264 
   254 
   265     if (mEngine->mode() == Cxe::VideoMode) {
   255     QString text(mEngine->mode() == Cxe::VideoMode
   266         HbMessageBox::question(hbTrId("txt_cam_other_delete_video_clip"),
   256                ? hbTrId("txt_cam_other_delete_video_clip")
   267                                this,
   257                : hbTrId("txt_cam_other_delete_image"));
   268                                SLOT(handleDeleteDialogClosed(HbAction*)));
   258 
   269     } else {
   259     HbMessageBox::question(text,
   270         HbMessageBox::question(hbTrId("txt_cam_other_delete_image"),
   260                            this,
   271                                this,
   261                            SLOT(handleDeleteDialogClosed(int)),
   272                                SLOT(handleDeleteDialogClosed(HbAction*)));
   262                            HbMessageBox::Yes | HbMessageBox::No);
   273     }
       
   274 
   263 
   275     mDeleteNoteOpen = true;
   264     mDeleteNoteOpen = true;
   276     CX_DEBUG_EXIT_FUNCTION();
   265     CX_DEBUG_EXIT_FUNCTION();
   277 }
   266 }
   278 
   267 
   279 // ---------------------------------------------------------------------------
   268 /*!
   280 // CxuiPostcaptureView::handleDeleteDialogClosed
   269 * Handle closing delete query dialog.
   281 //
   270 * @param action HbMessageBox::Yes if user accepted the delete query, HbMessageBox::No if not.
   282 // ---------------------------------------------------------------------------
   271 */
   283 //
   272 void CxuiPostcaptureView::handleDeleteDialogClosed(int action)
   284 void CxuiPostcaptureView::handleDeleteDialogClosed(HbAction *action)
       
   285 {
   273 {
   286     CX_DEBUG_ENTER_FUNCTION();
   274     CX_DEBUG_ENTER_FUNCTION();
   287 
   275 
   288     hideControls();
   276     hideControls();
   289     mDeleteNoteOpen = false;
   277     mDeleteNoteOpen = false;
   290 
   278 
   291     HbMessageBox *dlg = qobject_cast<HbMessageBox*>(sender());
   279     // Check that user confirmed delete
   292 
   280     if (action == HbMessageBox::Yes) {
   293     // check that it was "primary action" that closed the dialog
   281         QFileInfo fileInfo(getCurrentFilename());
   294     if (dlg && dlg->actions().at(0) == action) {
       
   295         // User confirmed delete
       
   296         QString filename = getCurrentFilename();
       
   297         QFileInfo fileInfo(filename);
       
   298         if (fileInfo.exists()) {
   282         if (fileInfo.exists()) {
   299             //! @todo
   283             //! @todo
   300             // We can retry deletion if file deletion does'nt succeed,
   284             // We can retry deletion if file deletion does'nt succeed,
   301             // but this is left out for the time being since the user
   285             // but this is left out for the time being since the user
   302             // can't delete it so early that it's not saved yet or
   286             // can't delete it so early that it's not saved yet or
   303             // is being harvested by MdS etc.
   287             // is being harvested by MdS etc.
   304             QDir dir = fileInfo.absolutePath();
   288             QDir dir = fileInfo.absolutePath();
   305             bool ok = dir.remove(fileInfo.fileName());
   289             bool ok = dir.remove(fileInfo.fileName());
   306             CX_DEBUG(("Delete file [%s], status %d", fileInfo.fileName().toAscii().constData(), ok));
   290             CX_DEBUG(("Delete file [%s], status %d", qPrintable(fileInfo.fileName()), ok));
   307 
   291 
   308             // Go back to precapture view
   292             // Go back to precapture view
   309             goToPrecaptureView();
   293             goToPrecaptureView();
   310         }
   294         }
   311     }
   295     }
   331     mShareUi->send(filelist, true);
   315     mShareUi->send(filelist, true);
   332 
   316 
   333     CX_DEBUG_EXIT_FUNCTION();
   317     CX_DEBUG_EXIT_FUNCTION();
   334 }
   318 }
   335 
   319 
   336 // ---------------------------------------------------------------------------
   320 /*!
   337 // CxuiPostcaptureView::goToPrecaptureView
   321 * Go to pre-capture view.
   338 //
   322 */
   339 // ---------------------------------------------------------------------------
       
   340 //
       
   341 void CxuiPostcaptureView::goToPrecaptureView()
   323 void CxuiPostcaptureView::goToPrecaptureView()
   342 {
   324 {
   343     CX_DEBUG_ENTER_FUNCTION();
   325     CX_DEBUG_ENTER_FUNCTION();
   344 
   326 
   345     // Cannot return to pre-capture while stopping in video mode
   327     // Cannot return to pre-capture while stopping in video mode
   357     }
   339     }
   358 
   340 
   359     CX_DEBUG_EXIT_FUNCTION();
   341     CX_DEBUG_EXIT_FUNCTION();
   360 }
   342 }
   361 
   343 
   362 // ---------------------------------------------------------------------------
   344 /*!
   363 // CxuiPostcaptureView::stopViewfinder
   345 * Stop viewfinder.
   364 //
   346 */
   365 // ---------------------------------------------------------------------------
       
   366 //
       
   367 void CxuiPostcaptureView::stopViewfinder()
   347 void CxuiPostcaptureView::stopViewfinder()
   368 {
   348 {
   369     CX_DEBUG_ENTER_FUNCTION();
   349     CX_DEBUG_ENTER_FUNCTION();
   370 
   350 
   371     if (mMainWindow->currentView() == this) {
   351     if (mMainWindow->currentView() == this) {
   392         mEmbeddedToolbar->hide();
   372         mEmbeddedToolbar->hide();
   393     }
   373     }
   394     CX_DEBUG_EXIT_FUNCTION();
   374     CX_DEBUG_EXIT_FUNCTION();
   395 }
   375 }
   396 
   376 
   397 // ---------------------------------------------------------------------------
   377 /*!
   398 // CxuiPostcaptureView::eventFilter
   378 * Handle events.
   399 //
   379 * Needed for restarting timers.
   400 // ---------------------------------------------------------------------------
   380 */
   401 //
       
   402 bool CxuiPostcaptureView::eventFilter(QObject *object, QEvent *event)
   381 bool CxuiPostcaptureView::eventFilter(QObject *object, QEvent *event)
   403 {
   382 {
   404     Q_UNUSED(object)
   383     Q_UNUSED(object)
   405     bool eventWasConsumed = false;
   384     bool eventWasConsumed = false;
   406 
   385 
   425 * Paint method.
   404 * Paint method.
   426 * Used for performance tracing purposes.
   405 * Used for performance tracing purposes.
   427 */
   406 */
   428 void CxuiPostcaptureView::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
   407 void CxuiPostcaptureView::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
   429 {
   408 {
   430     OstTrace0(camerax_performance, CXUIPOSTCAPTUREVIEW_SNAPSHOT_DRAW, "msg: e_CX_SHOT_TO_SNAPSHOT 0");
   409     // Performance trace for checking shot to snapshot time.
       
   410     // Guard that we actually have the snapshot set before outputting the trace.
       
   411     if (mImageLabel && !mImageLabel->icon().isNull()) {
       
   412         OstTrace0(camerax_performance, CXUIPOSTCAPTUREVIEW_SNAPSHOT_DRAW, "msg: e_CX_SHOT_TO_SNAPSHOT 0");
       
   413     }
       
   414 
   431     QGraphicsWidget::paint(painter, option, widget);
   415     QGraphicsWidget::paint(painter, option, widget);
   432 }
   416 }
   433 
   417 
   434 /*!
   418 /*!
   435  * Restore view state from activity.
   419  * Restore view state from activity.
   436  * @param activityId Activity id
   420  * @param activityId Activity id
   437  * @param data Activity data
   421  * @param data Activity data
   438  */
   422  */
   439 void CxuiPostcaptureView::restoreActivity(const QString &activityId, const QVariant &data)
   423 void CxuiPostcaptureView::restoreActivity(const QString &activityId, const QVariant &data)
   440 {
   424 {
       
   425     Q_UNUSED(activityId);
   441     CX_DEBUG_ENTER_FUNCTION();
   426     CX_DEBUG_ENTER_FUNCTION();
   442 
   427 
   443     // get filename. if filename is not found (toString() returns empty string)
   428     // get filename. if filename is not found (toString() returns empty string)
   444     // we will go back to pre-capture in updateSnapshotImage()
   429     // we will go back to pre-capture in updateSnapshotImage()
   445     mFilename = data.toMap()[FILENAME_KEY].toString();
   430     mFilename = data.toMap()[FILENAME_KEY].toString();
   446     CX_DEBUG(("Got filename %s from activity", mFilename.toAscii().data()));
   431     CX_DEBUG(("Got filename [%s] from activity", qPrintable(mFilename)));
   447 
   432 
   448     CX_DEBUG_EXIT_FUNCTION();
   433     CX_DEBUG_EXIT_FUNCTION();
   449 }
   434 }
   450 
   435 
   451 /*!
   436 /*!
   456     CX_DEBUG_ENTER_FUNCTION();
   441     CX_DEBUG_ENTER_FUNCTION();
   457     QVariantMap data;
   442     QVariantMap data;
   458     QVariantHash params;
   443     QVariantHash params;
   459 
   444 
   460     QString filename = getCurrentFilename();
   445     QString filename = getCurrentFilename();
   461     CX_DEBUG(("Saving filename %s", filename.toAscii().data()));
   446     CX_DEBUG(("Saving filename [%s]", qPrintable(filename)));
   462     data.insert(FILENAME_KEY, filename);
   447     data.insert(FILENAME_KEY, filename);
   463 
   448 
   464     QImage img(mMainWindow->rect().size(), QImage::Format_ARGB32_Premultiplied);
   449     QImage img(mMainWindow->rect().size(), QImage::Format_ARGB32_Premultiplied);
   465     QPainter p(&img);
   450     QPainter p(&img);
   466     mMainWindow->render(&p, mMainWindow->rect(), mMainWindow->rect());
   451     mMainWindow->render(&p, mMainWindow->rect(), mMainWindow->rect());
   487     mActivityManager->removeActivity(CxuiActivityIds::STILL_POSTCAPTURE_ACTIVITY);
   472     mActivityManager->removeActivity(CxuiActivityIds::STILL_POSTCAPTURE_ACTIVITY);
   488     mActivityManager->removeActivity(CxuiActivityIds::VIDEO_POSTCAPTURE_ACTIVITY);
   473     mActivityManager->removeActivity(CxuiActivityIds::VIDEO_POSTCAPTURE_ACTIVITY);
   489     CX_DEBUG_EXIT_FUNCTION();
   474     CX_DEBUG_EXIT_FUNCTION();
   490 }
   475 }
   491 
   476 
   492 // ---------------------------------------------------------------------------
   477 /*!
   493 // CxuiPostcaptureView::showEvent
   478 * Show event for this view.
   494 //
   479 * Update snapshot and start timers.
   495 // ---------------------------------------------------------------------------
   480 */
   496 //
       
   497 void CxuiPostcaptureView::showEvent(QShowEvent *event)
   481 void CxuiPostcaptureView::showEvent(QShowEvent *event)
   498 {
   482 {
   499     CX_DEBUG_ENTER_FUNCTION();
   483     CX_DEBUG_ENTER_FUNCTION();
   500 
   484 
   501     QGraphicsWidget::showEvent(event);
   485     QGraphicsWidget::showEvent(event);
   502 
   486 
   503     if (event->type() == QEvent::Show) {
   487     if (event->type() == QEvent::Show) {
   504         QCoreApplication::instance()->installEventFilter(this);
   488         QCoreApplication::instance()->installEventFilter(this);
   505 
   489 
       
   490         // Update snapshot for current file.
       
   491         // If the current file does not exist anymore, return to pre-capture view.
   506         updateSnapshotImage();
   492         updateSnapshotImage();
   507         showControls();
   493 
   508         startTimers();
   494         // If the image / video has been deleted, control returned to pre-capture view.
       
   495         // No point to start timers or show controls then.
       
   496         if (mMainWindow->currentView() == this) {
       
   497             showControls();
       
   498             startTimers();
       
   499         }
       
   500 
   509         event->accept();
   501         event->accept();
   510     }
   502     }
   511 
   503 
   512     CX_DEBUG_EXIT_FUNCTION();
   504     CX_DEBUG_EXIT_FUNCTION();
   513 }
   505 }
   514 
   506 
   515 // ---------------------------------------------------------------------------
   507 /*!
   516 // CxuiPostcaptureView::hideEvent
   508 * Hide event.
   517 //
   509 * Release snapshot and stop timers.
   518 // ---------------------------------------------------------------------------
   510 */
   519 //
       
   520 void CxuiPostcaptureView::hideEvent(QHideEvent *event)
   511 void CxuiPostcaptureView::hideEvent(QHideEvent *event)
   521 {
   512 {
   522     CX_DEBUG_ENTER_FUNCTION();
   513     CX_DEBUG_ENTER_FUNCTION();
   523 
   514 
   524     QGraphicsWidget::hideEvent(event);
   515     QGraphicsWidget::hideEvent(event);
   592  */
   583  */
   593 void CxuiPostcaptureView::updateSnapshotImage()
   584 void CxuiPostcaptureView::updateSnapshotImage()
   594 {
   585 {
   595     CX_DEBUG_ENTER_FUNCTION();
   586     CX_DEBUG_ENTER_FUNCTION();
   596 
   587 
   597     if (!mFilename.isNull()) {
   588     if (isFileDeleted()) {
   598         CX_DEBUG(("CxuiPostcaptureView::updateSnapshot restoring activity"));
   589         // File deleted, go to pre-capture view.
       
   590         CX_DEBUG(("File has been deleted, going back to pre-capture"));
       
   591         goToPrecaptureView();
       
   592 
       
   593     } else if (!mFilename.isNull()) {
   599         // filename set, we are restoring activity
   594         // filename set, we are restoring activity
   600         if (QFile::exists(mFilename)) {
   595         if (!mThumbnailManager) {
   601             CX_DEBUG(("Filename ok, requesting thumbnail from TNM"));
   596             mThumbnailManager = new ThumbnailManager();
   602             if (!mThumbnailManager) {
   597             connect(mThumbnailManager, SIGNAL(thumbnailReady(QPixmap, void *, int, int)),
   603                 mThumbnailManager = new ThumbnailManager();
   598                     this, SLOT(handleThumbnailReady(QPixmap)));
   604                 connect(mThumbnailManager, SIGNAL(thumbnailReady(QPixmap, void *, int, int)),
   599             mThumbnailManager->setThumbnailSize(ThumbnailManager::ThumbnailLarge);
   605                                                 this, SLOT(handleThumbnailReady(QPixmap, void*, int, int)));
       
   606                 mThumbnailManager->setThumbnailSize(ThumbnailManager::ThumbnailLarge);
       
   607             }
       
   608             mThumbnailManager->getThumbnail(mFilename);
       
   609             CX_DEBUG(("Thumbnail requested"));
       
   610 
       
   611         } else {
       
   612             // file deleted
       
   613             CX_DEBUG(("File %s has been deleted, going back to pre-capture", mFilename.toAscii().data()));
       
   614             goToPrecaptureView();
       
   615         }
   600         }
       
   601         mThumbnailManager->getThumbnail(mFilename);
       
   602         CX_DEBUG(("Thumbnail requested"));
       
   603 
   616     } else {
   604     } else {
       
   605         // Normal use of post-capture view
   617         QPixmap snapshot;
   606         QPixmap snapshot;
   618         if (mEngine->mode() == ImageMode) {
   607         if (mEngine->mode() == ImageMode) {
   619             if( mEngine->stillCaptureControl().imageCount() > 0 ) {
   608 
       
   609             if (mEngine->stillCaptureControl().imageCount() > 0) {
   620                 snapshot = mEngine->stillCaptureControl()[0].snapshot();
   610                 snapshot = mEngine->stillCaptureControl()[0].snapshot();
   621             }
   611             }
   622         } else {
   612         } else {
   623             snapshot = mEngine->videoCaptureControl().snapshot();
   613             snapshot = mEngine->videoCaptureControl().snapshot();
   624         }
   614         }
   625         if (mImageLabel) {
   615 
   626                 mImageLabel->setIcon(HbIcon(QIcon(snapshot)));
   616         // Update the snapshot image
   627             } else {
   617         handleThumbnailReady(snapshot);
   628                 // do nothing
   618     }
       
   619 
       
   620     CX_DEBUG_EXIT_FUNCTION();
       
   621 }
       
   622 
       
   623 /*!
       
   624 * Check if the file we show this post-capture view for is deleted.
       
   625 * This can happen e.g. if we send camera to background and delete
       
   626 * the file in other application. When used as activity, we may also
       
   627 * get the name of already deleted file as activity parameter.
       
   628 * @return True if the current file is deleted, false if not.
       
   629 */
       
   630 bool CxuiPostcaptureView::isFileDeleted()
       
   631 {
       
   632     CX_DEBUG_ENTER_FUNCTION();
       
   633 
       
   634     bool deleted(false);
       
   635 
       
   636     // Check how we entered this view.
       
   637     if (mFilename.isNull()) {
       
   638         CX_DEBUG(("Checking engine filename"));
       
   639         // Normally entered post-capture view.
       
   640         if (mEngine->mode() == ImageMode) {
       
   641             // Check that the image have been saved already.
       
   642             // If not, it cannot have been deleted in that case.
       
   643             CxeStillImage &image(mEngine->stillCaptureControl()[0]);
       
   644             CX_DEBUG(("Image filename [%s]", qPrintable(image.filename())));
       
   645             CX_DEBUG(("Image file saved: %d exists: %d", image.saved(), QFile::exists(image.filename())));
       
   646             deleted = image.saved() && !QFile::exists(image.filename());
       
   647         } else {
       
   648             // Check that video has been stopped fully.
       
   649             // If it's still stopping, QFile may not work.
       
   650             CX_DEBUG(("Video filename [%s]", qPrintable(mEngine->videoCaptureControl().filename())));
       
   651             deleted = mEngine->videoCaptureControl().state() != CxeVideoCaptureControl::Stopping
       
   652                    && !QFile::exists(mEngine->videoCaptureControl().filename());
   629         }
   653         }
   630     }
   654     } else {
   631 
   655         // Started as activity, check the filename given when restoring activity.
   632     CX_DEBUG_EXIT_FUNCTION();
   656         CX_DEBUG(("Checking filename saved in activity"));
       
   657         deleted = !QFile::exists(mFilename);
       
   658     }
       
   659 
       
   660     CX_DEBUG_EXIT_FUNCTION();
       
   661     return deleted;
   633 }
   662 }
   634 
   663 
   635 /* !
   664 /* !
   636  * gets the filename of the current file
   665  * gets the filename of the current file
   637  */
   666  */
   638 QString CxuiPostcaptureView::getCurrentFilename()
   667 QString CxuiPostcaptureView::getCurrentFilename()
   639 {
   668 {
   640     CX_DEBUG_ENTER_FUNCTION();
   669     CX_DEBUG_ENTER_FUNCTION();
       
   670     QString filename;
   641 
   671 
   642     if (!mFilename.isNull()) {
   672     if (!mFilename.isNull()) {
   643         // post-capture started by activity, engine doesn't contain correct
   673         // post-capture started by activity, engine doesn't contain correct
   644         // filename anymore so use the stored one
   674         // filename anymore so use the stored one
   645         CX_DEBUG(("Using filename saved in activity"));
   675         CX_DEBUG(("Using filename saved in activity"));
   646         CX_DEBUG_EXIT_FUNCTION();
   676         filename = mFilename;
   647         return mFilename;
       
   648     }
       
   649 
       
   650     CX_DEBUG(("Getting filename from engine"));
       
   651     QString filename;
       
   652 
       
   653     if (mEngine->mode() == Cxe::VideoMode) {
       
   654         filename = mEngine->videoCaptureControl().filename();
       
   655     } else {
   677     } else {
   656         //!@todo Currently only gets index 0 from the still capture control.
   678         CX_DEBUG(("Getting filename from engine"));
   657         CxeStillCaptureControl& stillCaptureControl = mEngine->stillCaptureControl();
   679         if (mEngine->mode() == Cxe::VideoMode) {
   658         if (stillCaptureControl.imageCount()) {
   680             filename = mEngine->videoCaptureControl().filename();
   659             filename = stillCaptureControl[0].filename();
   681         } else {
       
   682             //!@todo Currently only gets index 0 from the still capture control.
       
   683             CxeStillCaptureControl& stillCaptureControl = mEngine->stillCaptureControl();
       
   684             if (stillCaptureControl.imageCount() > 0) {
       
   685                 filename = stillCaptureControl[0].filename();
       
   686             }
   660         }
   687         }
   661     }
   688     }
   662     CX_DEBUG((filename.toAscii()));
   689 
   663 
   690     CX_DEBUG(("Got filename [%s]", qPrintable(filename)));
   664     CX_DEBUG_EXIT_FUNCTION();
   691     CX_DEBUG_EXIT_FUNCTION();
   665 
   692 
   666     return filename;
   693     return filename;
   667 }
   694 }
   668 
   695 
   688     CX_DEBUG_ENTER_FUNCTION();
   715     CX_DEBUG_ENTER_FUNCTION();
   689 
   716 
   690     // Common functionality first.
   717     // Common functionality first.
   691     CxuiView::exitStandby();
   718     CxuiView::exitStandby();
   692 
   719 
   693     //!@note We should not start timers until we receive the ShowEvent
   720     // Update snapshot and check the current file is not deleted.
   694     showControls();
   721     updateSnapshotImage();
       
   722 
       
   723     if (mMainWindow->currentView() == this) {
       
   724         showControls();
       
   725     }
   695 
   726 
   696     CX_DEBUG_EXIT_FUNCTION();
   727     CX_DEBUG_EXIT_FUNCTION();
   697 }
   728 }
   698 
   729 
   699 /*!
   730 /*!
   714 
   745 
   715 /*!
   746 /*!
   716  * Handle thumbnail received from ThumbnailManager.
   747  * Handle thumbnail received from ThumbnailManager.
   717  *
   748  *
   718  * @param thumbnail Thumbnail as QPixmap
   749  * @param thumbnail Thumbnail as QPixmap
   719  * @param clientData Not used
   750  */
   720  * @param id Thumbnail manager request id
   751 void CxuiPostcaptureView::handleThumbnailReady(QPixmap thumbnail)
   721  * @param errorCode Error code
   752 {
   722  */
   753     CX_DEBUG_ENTER_FUNCTION();
   723 void CxuiPostcaptureView::handleThumbnailReady(QPixmap thumbnail, void *clientData, int id, int errorCode)
       
   724 {
       
   725     CX_DEBUG_ENTER_FUNCTION();
       
   726 
       
   727     Q_UNUSED(clientData);
       
   728     Q_UNUSED(id);
       
   729 
   754 
   730     if (thumbnail.isNull()) {
   755     if (thumbnail.isNull()) {
   731         CX_DEBUG(("Received null thumbnail from TNM, going to pre-capture. Error=%d", errorCode));
   756         CX_DEBUG(("[WARNING] Received null thumbnail from TNM, going to pre-capture."));
   732         // null thumbnail, go to precapture
   757         // null thumbnail, go to precapture
   733         goToPrecaptureView();
   758         goToPrecaptureView();
   734     } else if (mImageLabel) {
   759     } else if (mImageLabel) {
   735         mImageLabel->setIcon(HbIcon(QIcon(thumbnail)));
   760         mImageLabel->setIcon(HbIcon(QIcon(thumbnail)));
   736     }
   761     }
   776     } else {
   801     } else {
   777         settingId = CxeSettingIds::VIDEO_SHOWCAPTURED;
   802         settingId = CxeSettingIds::VIDEO_SHOWCAPTURED;
   778     }
   803     }
   779 
   804 
   780     if (!CxuiServiceProvider::isCameraEmbedded()) {
   805     if (!CxuiServiceProvider::isCameraEmbedded()) {
   781         CxeError::Id err = mEngine->settings().get(settingId, postCaptureTimeout);
   806         postCaptureTimeout = mEngine->settings().get<int>(settingId, 0);
   782 
   807 
   783         if (postCaptureTimeout > 0 && err == CxeError::None) {
   808         if (postCaptureTimeout > 0) {
   784             mPostcaptureTimer.start(postCaptureTimeout);
   809             mPostcaptureTimer.start(postCaptureTimeout);
   785         } else {
   810         } else {
   786             // do nothing
   811             // do nothing
   787         }
   812         }
   788     }
   813     }