camerauis/cameraxui/cxui/src/cxuipostcaptureview.cpp
changeset 42 feebad15db8c
parent 41 67457b2ffb33
child 46 c826656d6714
equal deleted inserted replaced
41:67457b2ffb33 42:feebad15db8c
    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 
    35 #include <shareui.h>
    34 #include <shareui.h>
    36 #include <thumbnailmanager_qt.h>
    35 #include <thumbnailmanager_qt.h>
    37 
    36 
    48 #include "cxuidocumentloader.h"
    47 #include "cxuidocumentloader.h"
    49 #include "cxesettings.h"
    48 #include "cxesettings.h"
    50 #include "cxenamespace.h"
    49 #include "cxenamespace.h"
    51 #include "cxuiserviceprovider.h"
    50 #include "cxuiserviceprovider.h"
    52 
    51 
       
    52 #ifdef Q_OS_SYMBIAN
    53 #include "OstTraceDefinitions.h"
    53 #include "OstTraceDefinitions.h"
    54 #ifdef OST_TRACE_COMPILER_IN_USE
    54 #ifdef OST_TRACE_COMPILER_IN_USE
    55 #include "cxuipostcaptureviewTraces.h"
    55 #include "cxuipostcaptureviewTraces.h"
    56 #endif
    56 #endif
       
    57 #endif //Q_OS_SYMBIAN
    57 
    58 
    58 
    59 
    59 using namespace CxUiLayout;
    60 using namespace CxUiLayout;
    60 using namespace Cxe;
    61 using namespace Cxe;
    61 
    62 
    62 
    63 
    63 namespace {
    64 namespace {
    64     const QString FILENAME_KEY = "filename";
    65     const QString FILENAME_KEY = "filename";
    65     const int CXUI_STOP_VIEWFINDER_TIMEOUT = 5000; //  5 seconds
    66     const int CXUI_STOP_VIEWFINDER_TIMEOUT = 5000; //  5 seconds
    66     const int CXUI_RELEASE_CAMERA_TIMEOUT = 60000; // 60 seconds
    67     const int CXUI_RELEASE_CAMERA_TIMEOUT = 60000; // 60 seconds
    67 };
    68 }
    68 
    69 
    69 
    70 
    70 // ---------------------------------------------------------------------------
    71 /*!
    71 // CxuiPostcaptureView::CxuiPostcaptureView
    72 * Constructor.
    72 //
    73 */
    73 // ---------------------------------------------------------------------------
       
    74 //
       
    75 CxuiPostcaptureView::CxuiPostcaptureView(QGraphicsItem *parent) :
    74 CxuiPostcaptureView::CxuiPostcaptureView(QGraphicsItem *parent) :
    76     CxuiView(parent),
    75     CxuiView(parent),
    77     mStillToolbar(NULL),
    76     mStillToolbar(NULL),
    78     mVideoToolbar(NULL),
    77     mVideoToolbar(NULL),
    79     mEmbeddedToolbar(NULL),
    78     mEmbeddedToolbar(NULL),
    91     CX_DEBUG_IN_FUNCTION();
    90     CX_DEBUG_IN_FUNCTION();
    92 
    91 
    93     CX_DEBUG_EXIT_FUNCTION();
    92     CX_DEBUG_EXIT_FUNCTION();
    94 }
    93 }
    95 
    94 
    96 // ---------------------------------------------------------------------------
    95 /*!
    97 // CxuiPostcaptureView::~CxuiPostcaptureView
    96 * Destructor.
    98 //
    97 */
    99 // ---------------------------------------------------------------------------
       
   100 //
       
   101 CxuiPostcaptureView::~CxuiPostcaptureView()
    98 CxuiPostcaptureView::~CxuiPostcaptureView()
   102 {
    99 {
   103     CX_DEBUG_ENTER_FUNCTION();
   100     CX_DEBUG_ENTER_FUNCTION();
   104     QCoreApplication::instance()->removeEventFilter(this);
   101     QCoreApplication::instance()->removeEventFilter(this);
   105     stopTimers();
   102     stopTimers();
   106     delete mThumbnailManager;
   103     delete mThumbnailManager;
   107     delete mShareUi;
   104     delete mShareUi;
   108     CX_DEBUG_EXIT_FUNCTION();
   105     CX_DEBUG_EXIT_FUNCTION();
   109 }
   106 }
   110 
   107 
   111 // ---------------------------------------------------------------------------
   108 /*!
   112 // CxuiPostcaptureView::construct
   109 * Second phase construction.
   113 //
   110 */
   114 // ---------------------------------------------------------------------------
       
   115 //
       
   116 void CxuiPostcaptureView::construct(HbMainWindow *mainwindow, CxeEngine *engine,
   111 void CxuiPostcaptureView::construct(HbMainWindow *mainwindow, CxeEngine *engine,
   117                                     CxuiDocumentLoader *documentLoader,
   112                                     CxuiDocumentLoader *documentLoader,
   118                                     CxuiCaptureKeyHandler *keyHandler,
   113                                     CxuiCaptureKeyHandler *keyHandler,
   119                                     HbActivityManager *activityManager)
   114                                     HbActivityManager *activityManager)
   120 {
   115 {
       
   116     Q_UNUSED(keyHandler);
   121     CX_DEBUG_ENTER_FUNCTION();
   117     CX_DEBUG_ENTER_FUNCTION();
   122 
   118 
   123     CxuiView::construct(mainwindow, engine, documentLoader, NULL, activityManager);
   119     CxuiView::construct(mainwindow, engine, documentLoader, NULL, activityManager);
   124 
   120 
   125     // set back action to go back to pre-capture
   121     // set back action to go back to pre-capture
   179 
   175 
   180     QCoreApplication::instance()->installEventFilter(this);
   176     QCoreApplication::instance()->installEventFilter(this);
   181     CX_DEBUG_EXIT_FUNCTION();
   177     CX_DEBUG_EXIT_FUNCTION();
   182 }
   178 }
   183 
   179 
   184 // ---------------------------------------------------------------------------
   180 /*!
   185 // CxuiPostcaptureView::handleCaptureKeyPressed
   181 * Handle pressing capture key.
   186 //
   182 */
   187 // ---------------------------------------------------------------------------
       
   188 //
       
   189 void CxuiPostcaptureView::handleCaptureKeyPressed()
   183 void CxuiPostcaptureView::handleCaptureKeyPressed()
   190 {
   184 {
   191     CX_DEBUG_ENTER_FUNCTION();
   185     CX_DEBUG_ENTER_FUNCTION();
   192 
   186 
   193     if (!mDeleteNoteOpen) {
   187     if (!mDeleteNoteOpen) {
   195     }
   189     }
   196 
   190 
   197     CX_DEBUG_EXIT_FUNCTION();
   191     CX_DEBUG_EXIT_FUNCTION();
   198 }
   192 }
   199 
   193 
   200 // ---------------------------------------------------------------------------
   194 /*!
   201 // CxuiPostcaptureView::handleAutofocusKeyPressed
   195 * Handle pressing auto focus key.
   202 //
   196 */
   203 // ---------------------------------------------------------------------------
       
   204 //
       
   205 void CxuiPostcaptureView::handleAutofocusKeyPressed()
   197 void CxuiPostcaptureView::handleAutofocusKeyPressed()
   206 {
   198 {
   207     CX_DEBUG_ENTER_FUNCTION();
   199     CX_DEBUG_ENTER_FUNCTION();
   208 
   200 
   209     if (!mDeleteNoteOpen) {
   201     if (!mDeleteNoteOpen) {
   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
       
   294     if (dlg && dlg->actions().at(0) == action) {
       
   295         // User confirmed delete
       
   296         QString filename = getCurrentFilename();
   281         QString filename = getCurrentFilename();
   297         QFileInfo fileInfo(filename);
   282         QFileInfo fileInfo(filename);
   298         if (fileInfo.exists()) {
   283         if (fileInfo.exists()) {
   299             //! @todo
   284             //! @todo
   300             // We can retry deletion if file deletion does'nt succeed,
   285             // We can retry deletion if file deletion does'nt succeed,
   301             // but this is left out for the time being since the user
   286             // 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
   287             // can't delete it so early that it's not saved yet or
   303             // is being harvested by MdS etc.
   288             // is being harvested by MdS etc.
   304             QDir dir = fileInfo.absolutePath();
   289             QDir dir = fileInfo.absolutePath();
   305             bool ok = dir.remove(fileInfo.fileName());
   290             bool ok = dir.remove(fileInfo.fileName());
   306             CX_DEBUG(("Delete file [%s], status %d", fileInfo.fileName().toAscii().constData(), ok));
   291             CX_DEBUG(("Delete file [%s], status %d", qPrintable(fileInfo.fileName()), ok));
   307 
   292 
   308             // Go back to precapture view
   293             // Go back to precapture view
   309             goToPrecaptureView();
   294             goToPrecaptureView();
   310         }
   295         }
   311     }
   296     }
   331     mShareUi->send(filelist, true);
   316     mShareUi->send(filelist, true);
   332 
   317 
   333     CX_DEBUG_EXIT_FUNCTION();
   318     CX_DEBUG_EXIT_FUNCTION();
   334 }
   319 }
   335 
   320 
   336 // ---------------------------------------------------------------------------
   321 /*!
   337 // CxuiPostcaptureView::goToPrecaptureView
   322 * Go to pre-capture view.
   338 //
   323 */
   339 // ---------------------------------------------------------------------------
       
   340 //
       
   341 void CxuiPostcaptureView::goToPrecaptureView()
   324 void CxuiPostcaptureView::goToPrecaptureView()
   342 {
   325 {
   343     CX_DEBUG_ENTER_FUNCTION();
   326     CX_DEBUG_ENTER_FUNCTION();
   344 
   327 
   345     // Cannot return to pre-capture while stopping in video mode
   328     // Cannot return to pre-capture while stopping in video mode
   357     }
   340     }
   358 
   341 
   359     CX_DEBUG_EXIT_FUNCTION();
   342     CX_DEBUG_EXIT_FUNCTION();
   360 }
   343 }
   361 
   344 
   362 // ---------------------------------------------------------------------------
   345 /*!
   363 // CxuiPostcaptureView::stopViewfinder
   346 * Stop viewfinder.
   364 //
   347 */
   365 // ---------------------------------------------------------------------------
       
   366 //
       
   367 void CxuiPostcaptureView::stopViewfinder()
   348 void CxuiPostcaptureView::stopViewfinder()
   368 {
   349 {
   369     CX_DEBUG_ENTER_FUNCTION();
   350     CX_DEBUG_ENTER_FUNCTION();
   370 
   351 
   371     if (mMainWindow->currentView() == this) {
   352     if (mMainWindow->currentView() == this) {
   392         mEmbeddedToolbar->hide();
   373         mEmbeddedToolbar->hide();
   393     }
   374     }
   394     CX_DEBUG_EXIT_FUNCTION();
   375     CX_DEBUG_EXIT_FUNCTION();
   395 }
   376 }
   396 
   377 
   397 // ---------------------------------------------------------------------------
   378 /*!
   398 // CxuiPostcaptureView::eventFilter
   379 * Handle events.
   399 //
   380 * Needed for restarting timers.
   400 // ---------------------------------------------------------------------------
   381 */
   401 //
       
   402 bool CxuiPostcaptureView::eventFilter(QObject *object, QEvent *event)
   382 bool CxuiPostcaptureView::eventFilter(QObject *object, QEvent *event)
   403 {
   383 {
   404     Q_UNUSED(object)
   384     Q_UNUSED(object)
   405     bool eventWasConsumed = false;
   385     bool eventWasConsumed = false;
   406 
   386 
   436  * @param activityId Activity id
   416  * @param activityId Activity id
   437  * @param data Activity data
   417  * @param data Activity data
   438  */
   418  */
   439 void CxuiPostcaptureView::restoreActivity(const QString &activityId, const QVariant &data)
   419 void CxuiPostcaptureView::restoreActivity(const QString &activityId, const QVariant &data)
   440 {
   420 {
       
   421     Q_UNUSED(activityId);
   441     CX_DEBUG_ENTER_FUNCTION();
   422     CX_DEBUG_ENTER_FUNCTION();
   442 
   423 
   443     // get filename. if filename is not found (toString() returns empty string)
   424     // get filename. if filename is not found (toString() returns empty string)
   444     // we will go back to pre-capture in updateSnapshotImage()
   425     // we will go back to pre-capture in updateSnapshotImage()
   445     mFilename = data.toMap()[FILENAME_KEY].toString();
   426     mFilename = data.toMap()[FILENAME_KEY].toString();
   487     mActivityManager->removeActivity(CxuiActivityIds::STILL_POSTCAPTURE_ACTIVITY);
   468     mActivityManager->removeActivity(CxuiActivityIds::STILL_POSTCAPTURE_ACTIVITY);
   488     mActivityManager->removeActivity(CxuiActivityIds::VIDEO_POSTCAPTURE_ACTIVITY);
   469     mActivityManager->removeActivity(CxuiActivityIds::VIDEO_POSTCAPTURE_ACTIVITY);
   489     CX_DEBUG_EXIT_FUNCTION();
   470     CX_DEBUG_EXIT_FUNCTION();
   490 }
   471 }
   491 
   472 
   492 // ---------------------------------------------------------------------------
   473 /*!
   493 // CxuiPostcaptureView::showEvent
   474 * Show event for this view.
   494 //
   475 * Update snapshot and start timers.
   495 // ---------------------------------------------------------------------------
   476 */
   496 //
       
   497 void CxuiPostcaptureView::showEvent(QShowEvent *event)
   477 void CxuiPostcaptureView::showEvent(QShowEvent *event)
   498 {
   478 {
   499     CX_DEBUG_ENTER_FUNCTION();
   479     CX_DEBUG_ENTER_FUNCTION();
   500 
   480 
   501     QGraphicsWidget::showEvent(event);
   481     QGraphicsWidget::showEvent(event);
   510     }
   490     }
   511 
   491 
   512     CX_DEBUG_EXIT_FUNCTION();
   492     CX_DEBUG_EXIT_FUNCTION();
   513 }
   493 }
   514 
   494 
   515 // ---------------------------------------------------------------------------
   495 /*!
   516 // CxuiPostcaptureView::hideEvent
   496 * Hide event.
   517 //
   497 * Release snapshot and stop timers.
   518 // ---------------------------------------------------------------------------
   498 */
   519 //
       
   520 void CxuiPostcaptureView::hideEvent(QHideEvent *event)
   499 void CxuiPostcaptureView::hideEvent(QHideEvent *event)
   521 {
   500 {
   522     CX_DEBUG_ENTER_FUNCTION();
   501     CX_DEBUG_ENTER_FUNCTION();
   523 
   502 
   524     QGraphicsWidget::hideEvent(event);
   503     QGraphicsWidget::hideEvent(event);