28 #include <hblabel.h> |
27 #include <hblabel.h> |
29 #include <hbmainwindow.h> |
28 #include <hbmainwindow.h> |
30 #include <hbtoolbar.h> |
29 #include <hbtoolbar.h> |
31 #include <hbaction.h> |
30 #include <hbaction.h> |
32 #include <hbmessagebox.h> |
31 #include <hbmessagebox.h> |
33 #include <hbnotificationdialog.h> |
32 #include <hbactivitymanager.h> |
34 |
33 |
35 #include <shareui.h> |
34 #include <shareui.h> |
|
35 #include <thumbnailmanager_qt.h> |
36 |
36 |
37 #include "cxeviewfindercontrol.h" |
37 #include "cxeviewfindercontrol.h" |
38 #include "cxuienums.h" |
38 #include "cxuienums.h" |
39 #include "cxuipostcaptureview.h" |
39 #include "cxuipostcaptureview.h" |
40 #include "cxeengine.h" |
40 #include "cxeengine.h" |
41 #include "cxecameradevicecontrol.h" |
41 #include "cxecameradevicecontrol.h" |
42 #include "cxestillcapturecontrol.h" |
42 #include "cxestillcapturecontrol.h" |
43 #include "cxeviewfindercontrol.h" |
|
44 #include "cxevideocapturecontrol.h" |
43 #include "cxevideocapturecontrol.h" |
45 #include "cxestillimage.h" |
44 #include "cxestillimage.h" |
46 #include "cxutils.h" |
45 #include "cxutils.h" |
47 #include "cxefeaturemanager.h" |
46 #include "cxefeaturemanager.h" |
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 // CONSTANTS |
63 |
63 const int CXUI_HIDE_CONTROLS_TIMEOUT = 6000; // 6 seconds |
64 namespace { |
64 const QString PhotosAppExe = "photos.exe"; |
65 const QString FILENAME_KEY = "filename"; |
65 const QString VideosAppExe = "videoplayer.exe"; |
66 const int CXUI_STOP_VIEWFINDER_TIMEOUT = 5000; // 5 seconds |
66 |
67 const int CXUI_RELEASE_CAMERA_TIMEOUT = 60000; // 60 seconds |
67 //!@todo Temporarily disabled. |
68 } |
68 //const int CXUI_STOP_VIEWFINDER_TIMEOUT = 5000; // 5 seconds |
69 |
69 //const int CXUI_RELEASE_CAMERA_TIMEOUT = 10000; // 10 seconds |
70 |
70 |
71 /*! |
71 // --------------------------------------------------------------------------- |
72 * Constructor. |
72 // CxuiPostcaptureView::CxuiPostcaptureView |
73 */ |
73 // |
|
74 // --------------------------------------------------------------------------- |
|
75 // |
|
76 CxuiPostcaptureView::CxuiPostcaptureView(QGraphicsItem *parent) : |
74 CxuiPostcaptureView::CxuiPostcaptureView(QGraphicsItem *parent) : |
77 HbView(parent), |
75 CxuiView(parent), |
78 mMainWindow(NULL), |
|
79 mEngine(NULL), |
|
80 mStillToolbar(NULL), |
76 mStillToolbar(NULL), |
81 mVideoToolbar(NULL), |
77 mVideoToolbar(NULL), |
82 mEmbeddedToolbar(NULL), |
78 mEmbeddedToolbar(NULL), |
83 mBackgroundItem(NULL), |
79 mBackgroundItem(NULL), |
84 mImageLabel(NULL), |
80 mImageLabel(NULL), |
85 mHideControlsTimeout(this), |
81 mShareUi(NULL), |
86 mStopViewfinderTimer(this), |
82 mStopViewfinderTimer(this), |
87 mReleaseCameraTimer(this), |
83 mReleaseCameraTimer(this), |
88 mPostcaptureTimer(this), |
84 mPostcaptureTimer(this), |
89 mTimersStarted(false) |
85 mTimersStarted(false), |
|
86 mDeleteNoteOpen(false), |
|
87 mFilename(QString::null), |
|
88 mThumbnailManager(NULL) |
90 { |
89 { |
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 CX_DEBUG_EXIT_FUNCTION(); |
103 delete mThumbnailManager; |
107 } |
104 delete mShareUi; |
108 |
105 CX_DEBUG_EXIT_FUNCTION(); |
109 // --------------------------------------------------------------------------- |
106 } |
110 // CxuiPostcaptureView::construct |
107 |
111 // |
108 /*! |
112 // --------------------------------------------------------------------------- |
109 * Second phase construction. |
113 // |
110 */ |
114 void CxuiPostcaptureView::construct(HbMainWindow *mainwindow, CxeEngine *engine, |
111 void CxuiPostcaptureView::construct(HbMainWindow *mainwindow, CxeEngine *engine, |
115 CxuiDocumentLoader *documentLoader) |
112 CxuiDocumentLoader *documentLoader, |
116 { |
113 CxuiCaptureKeyHandler *keyHandler, |
117 CX_DEBUG_ENTER_FUNCTION(); |
114 HbActivityManager *activityManager) |
118 |
115 { |
119 mMainWindow = mainwindow; |
116 Q_UNUSED(keyHandler); |
120 mEngine = engine; |
117 CX_DEBUG_ENTER_FUNCTION(); |
121 mDocumentLoader = documentLoader; |
118 |
|
119 CxuiView::construct(mainwindow, engine, documentLoader, NULL, activityManager); |
122 |
120 |
123 // set back action to go back to pre-capture |
121 // set back action to go back to pre-capture |
124 HbAction *backAction = new HbAction(Hb::BackNaviAction, this); |
122 HbAction *backAction = new HbAction(Hb::BackNaviAction, this); |
125 connect(backAction, SIGNAL(triggered()), this, SLOT(goToPrecaptureView())); |
123 connect(backAction, SIGNAL(triggered()), this, SLOT(goToPrecaptureView())); |
126 setNavigationAction(backAction); |
124 setNavigationAction(backAction); |
175 |
175 |
176 QCoreApplication::instance()->installEventFilter(this); |
176 QCoreApplication::instance()->installEventFilter(this); |
177 CX_DEBUG_EXIT_FUNCTION(); |
177 CX_DEBUG_EXIT_FUNCTION(); |
178 } |
178 } |
179 |
179 |
180 // --------------------------------------------------------------------------- |
180 /*! |
181 // CxuiPostcaptureView::handleCaptureKeyPressed |
181 * Handle pressing capture key. |
182 // |
182 */ |
183 // --------------------------------------------------------------------------- |
|
184 // |
|
185 void CxuiPostcaptureView::handleCaptureKeyPressed() |
183 void CxuiPostcaptureView::handleCaptureKeyPressed() |
186 { |
184 { |
187 CX_DEBUG_ENTER_FUNCTION(); |
185 CX_DEBUG_ENTER_FUNCTION(); |
188 |
186 |
189 goToPrecaptureView(); |
187 if (!mDeleteNoteOpen) { |
190 |
188 goToPrecaptureView(); |
191 CX_DEBUG_EXIT_FUNCTION(); |
189 } |
192 } |
190 |
193 |
191 CX_DEBUG_EXIT_FUNCTION(); |
194 // --------------------------------------------------------------------------- |
192 } |
195 // CxuiPostcaptureView::handleAutofocusKeyPressed |
193 |
196 // |
194 /*! |
197 // --------------------------------------------------------------------------- |
195 * Handle pressing auto focus key. |
198 // |
196 */ |
199 void CxuiPostcaptureView::handleAutofocusKeyPressed() |
197 void CxuiPostcaptureView::handleAutofocusKeyPressed() |
200 { |
198 { |
201 CX_DEBUG_ENTER_FUNCTION(); |
199 CX_DEBUG_ENTER_FUNCTION(); |
202 |
200 |
203 goToPrecaptureView(); |
201 if (!mDeleteNoteOpen) { |
|
202 goToPrecaptureView(); |
|
203 } |
204 |
204 |
205 CX_DEBUG_EXIT_FUNCTION(); |
205 CX_DEBUG_EXIT_FUNCTION(); |
206 } |
206 } |
207 |
207 |
208 /*! |
208 /*! |
209 Slot for starting video playing. |
209 Slot for starting video playing. |
210 */ |
210 */ |
211 void CxuiPostcaptureView::playVideo() |
211 void CxuiPostcaptureView::playVideo() |
212 { |
212 { |
213 |
213 CX_DEBUG_ENTER_FUNCTION(); |
214 launchNotSupportedNotification(); |
214 |
215 //! @todo needs an implementation |
215 stopTimers(); |
216 CX_DEBUG_IN_FUNCTION(); |
216 releaseCamera(); |
217 |
217 |
218 } |
218 QString videoFile(getCurrentFilename()); |
219 |
219 |
220 // --------------------------------------------------------------------------- |
220 XQAiwRequest *videoRequest = mAppManager.create( |
221 // CxuiPostcaptureView::showDeleteNote |
221 "com.nokia.symbian.IVideoView","playMedia(QString)", true); |
222 // |
222 |
223 // --------------------------------------------------------------------------- |
223 if (videoRequest) { |
224 // |
224 QVariantList fileList; |
|
225 fileList.append(QVariant(videoFile)); |
|
226 videoRequest->setArguments(fileList); |
|
227 |
|
228 CX_DEBUG(("CxuiPostcaptureView: sending request")); |
|
229 QVariant result; |
|
230 bool res = videoRequest->send(result); |
|
231 if (res) { |
|
232 CX_DEBUG(("CxuiPostcaptureView: request sent, received \"%s\"", |
|
233 result.toString().toAscii().constData())); |
|
234 } else { |
|
235 CX_DEBUG(("CxuiPostcaptureView: request sending failed, error=%d", |
|
236 videoRequest->lastError())); |
|
237 } |
|
238 delete videoRequest; |
|
239 videoRequest = NULL; |
|
240 } |
|
241 |
|
242 CX_DEBUG_EXIT_FUNCTION(); |
|
243 |
|
244 } |
|
245 |
|
246 /*! |
|
247 * Show delete query. |
|
248 */ |
225 void CxuiPostcaptureView::showDeleteNote() |
249 void CxuiPostcaptureView::showDeleteNote() |
226 { |
250 { |
227 CX_DEBUG_ENTER_FUNCTION(); |
251 CX_DEBUG_ENTER_FUNCTION(); |
228 |
252 |
229 hideControls(); |
253 hideControls(); |
230 |
254 |
231 if (mEngine->mode() == Cxe::VideoMode) { |
255 QString text(mEngine->mode() == Cxe::VideoMode |
232 HbMessageBox::question(hbTrId("txt_cam_other_delete_video_clip"), |
256 ? hbTrId("txt_cam_other_delete_video_clip") |
233 this, |
257 : hbTrId("txt_cam_other_delete_image")); |
234 SLOT(handleDeleteDialogClosed(HbAction*))); |
258 |
235 } else { |
259 HbMessageBox::question(text, |
236 HbMessageBox::question(hbTrId("txt_cam_other_delete_image"), |
260 this, |
237 this, |
261 SLOT(handleDeleteDialogClosed(int)), |
238 SLOT(handleDeleteDialogClosed(HbAction*))); |
262 HbMessageBox::Yes | HbMessageBox::No); |
239 } |
263 |
240 |
264 mDeleteNoteOpen = true; |
241 CX_DEBUG_EXIT_FUNCTION(); |
265 CX_DEBUG_EXIT_FUNCTION(); |
242 } |
266 } |
243 |
267 |
244 // --------------------------------------------------------------------------- |
268 /*! |
245 // CxuiPostcaptureView::handleDeleteDialogClosed |
269 * Handle closing delete query dialog. |
246 // |
270 * @param action HbMessageBox::Yes if user accepted the delete query, HbMessageBox::No if not. |
247 // --------------------------------------------------------------------------- |
271 */ |
248 // |
272 void CxuiPostcaptureView::handleDeleteDialogClosed(int action) |
249 void CxuiPostcaptureView::handleDeleteDialogClosed(HbAction *action) |
|
250 { |
273 { |
251 CX_DEBUG_ENTER_FUNCTION(); |
274 CX_DEBUG_ENTER_FUNCTION(); |
252 |
275 |
253 hideControls(); |
276 hideControls(); |
254 |
277 mDeleteNoteOpen = false; |
255 HbMessageBox *dlg = qobject_cast<HbMessageBox*>(sender()); |
278 |
256 |
279 // Check that user confirmed delete |
257 // check that it was "primary action" that closed the dialog |
280 if (action == HbMessageBox::Yes) { |
258 if (dlg && dlg->actions().at(0) == action) { |
|
259 // User confirmed delete |
|
260 QString filename = getCurrentFilename(); |
281 QString filename = getCurrentFilename(); |
261 QFileInfo fileInfo(filename); |
282 QFileInfo fileInfo(filename); |
262 if (fileInfo.exists()) { |
283 if (fileInfo.exists()) { |
263 //! @todo |
284 //! @todo |
264 // We can retry deletion if file deletion does'nt succeed, |
285 // We can retry deletion if file deletion does'nt succeed, |
265 // 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 |
266 // 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 |
267 // is being harvested by MdS etc. |
288 // is being harvested by MdS etc. |
268 QDir dir = fileInfo.absolutePath(); |
289 QDir dir = fileInfo.absolutePath(); |
269 bool ok = dir.remove(fileInfo.fileName()); |
290 bool ok = dir.remove(fileInfo.fileName()); |
270 CX_DEBUG(("Delete file [%s], status %d", fileInfo.fileName().toAscii().constData(), ok)); |
291 CX_DEBUG(("Delete file [%s], status %d", qPrintable(fileInfo.fileName()), ok)); |
271 |
292 |
272 // Go back to precapture view |
293 // Go back to precapture view |
273 goToPrecaptureView(); |
294 goToPrecaptureView(); |
274 } |
295 } |
275 } |
296 } |
342 mStopViewfinderTimer.stop(); |
355 mStopViewfinderTimer.stop(); |
343 |
356 |
344 CX_DEBUG_EXIT_FUNCTION(); |
357 CX_DEBUG_EXIT_FUNCTION(); |
345 } |
358 } |
346 |
359 |
347 // --------------------------------------------------------------------------- |
360 /*! |
348 // CxuiPostcaptureView::releaseCamera |
361 * Hides toolbar. |
349 // |
362 */ |
350 // --------------------------------------------------------------------------- |
363 void CxuiPostcaptureView::hideToolbar() |
351 // |
364 { |
352 void CxuiPostcaptureView::releaseCamera() |
365 CX_DEBUG_ENTER_FUNCTION(); |
353 { |
|
354 CX_DEBUG_ENTER_FUNCTION(); |
|
355 |
|
356 if (mMainWindow->currentView() == this) { |
|
357 mEngine->cameraDeviceControl().release(); |
|
358 } |
|
359 mReleaseCameraTimer.stop(); |
|
360 |
|
361 CX_DEBUG_EXIT_FUNCTION(); |
|
362 } |
|
363 |
|
364 // --------------------------------------------------------------------------- |
|
365 // CxuiPostcaptureView::hideControls |
|
366 // |
|
367 // --------------------------------------------------------------------------- |
|
368 // |
|
369 void CxuiPostcaptureView::hideControls() |
|
370 { |
|
371 CX_DEBUG_ENTER_FUNCTION(); |
|
372 |
|
373 if (mStillToolbar) { |
366 if (mStillToolbar) { |
374 mStillToolbar->hide(); |
367 mStillToolbar->hide(); |
375 } |
368 } |
376 if (mVideoToolbar) { |
369 if (mVideoToolbar) { |
377 mVideoToolbar->hide(); |
370 mVideoToolbar->hide(); |
378 } |
371 } |
379 if (mEmbeddedToolbar) { |
372 if (mEmbeddedToolbar) { |
380 mEmbeddedToolbar->hide(); |
373 mEmbeddedToolbar->hide(); |
381 } |
374 } |
382 |
375 CX_DEBUG_EXIT_FUNCTION(); |
383 hideItems(Hb::AllItems); |
376 } |
384 |
377 |
385 mControlsVisible = false; |
378 /*! |
386 |
379 * Handle events. |
387 // stop hiding control timer |
380 * Needed for restarting timers. |
388 mHideControlsTimeout.stop(); |
381 */ |
389 |
|
390 |
|
391 // give the keyboard focus back to the view |
|
392 // for the view to receive key events |
|
393 setFocus(); |
|
394 |
|
395 CX_DEBUG_EXIT_FUNCTION(); |
|
396 } |
|
397 |
|
398 // --------------------------------------------------------------------------- |
|
399 // CxuiPostcaptureView::showControls |
|
400 // |
|
401 // --------------------------------------------------------------------------- |
|
402 // |
|
403 void CxuiPostcaptureView::showControls() |
|
404 { |
|
405 CX_DEBUG_ENTER_FUNCTION(); |
|
406 |
|
407 showToolbar(); |
|
408 |
|
409 showItems(Hb::AllItems); |
|
410 |
|
411 mHideControlsTimeout.start(CXUI_HIDE_CONTROLS_TIMEOUT); |
|
412 mControlsVisible = true; |
|
413 |
|
414 CX_DEBUG_EXIT_FUNCTION(); |
|
415 } |
|
416 |
|
417 // --------------------------------------------------------------------------- |
|
418 // CxuiPostcaptureView::toggleControls |
|
419 // |
|
420 // --------------------------------------------------------------------------- |
|
421 // |
|
422 void CxuiPostcaptureView::toggleControls() |
|
423 { |
|
424 CX_DEBUG_ENTER_FUNCTION(); |
|
425 |
|
426 if (mControlsVisible) { |
|
427 hideControls(); |
|
428 } else { |
|
429 showControls(); |
|
430 } |
|
431 |
|
432 CX_DEBUG_EXIT_FUNCTION(); |
|
433 } |
|
434 |
|
435 // --------------------------------------------------------------------------- |
|
436 // CxuiPostcaptureView::eventFilter |
|
437 // |
|
438 // --------------------------------------------------------------------------- |
|
439 // |
|
440 bool CxuiPostcaptureView::eventFilter(QObject *object, QEvent *event) |
382 bool CxuiPostcaptureView::eventFilter(QObject *object, QEvent *event) |
441 { |
383 { |
442 Q_UNUSED(object) |
384 Q_UNUSED(object) |
443 bool eventWasConsumed = false; |
385 bool eventWasConsumed = false; |
444 |
386 |
463 * Paint method. |
405 * Paint method. |
464 * Used for performance tracing purposes. |
406 * Used for performance tracing purposes. |
465 */ |
407 */ |
466 void CxuiPostcaptureView::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) |
408 void CxuiPostcaptureView::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) |
467 { |
409 { |
468 OstTrace0(camerax_performance, CXUIPOSTCAPTUREVIEW_SNAPSHOT_DRAW, "msg: e_CX_SHOT_TO_SNAPSHOT 0"); |
410 OstTrace0(camerax_performance, CXUIPOSTCAPTUREVIEW_SNAPSHOT_DRAW, "msg: e_CX_SHOT_TO_SNAPSHOT 0"); |
469 QGraphicsWidget::paint(painter, option, widget); |
411 QGraphicsWidget::paint(painter, option, widget); |
470 } |
412 } |
471 |
413 |
472 // --------------------------------------------------------------------------- |
414 /*! |
473 // CxuiPostcaptureView::mousePressEvent |
415 * Restore view state from activity. |
474 // |
416 * @param activityId Activity id |
475 // --------------------------------------------------------------------------- |
417 * @param data Activity data |
476 // |
418 */ |
477 void CxuiPostcaptureView::mousePressEvent(QGraphicsSceneMouseEvent *event) |
419 void CxuiPostcaptureView::restoreActivity(const QString &activityId, const QVariant &data) |
478 { |
420 { |
479 //! @todo temporary workaround for title bar mouse event handling bug |
421 Q_UNUSED(activityId); |
480 if (event->type() == QEvent::GraphicsSceneMousePress && event->scenePos().y() > 70) { |
422 CX_DEBUG_ENTER_FUNCTION(); |
481 mPostcaptureTimer.stop(); |
423 |
482 toggleControls(); |
424 // get filename. if filename is not found (toString() returns empty string) |
483 event->accept(); |
425 // we will go back to pre-capture in updateSnapshotImage() |
484 } |
426 mFilename = data.toMap()[FILENAME_KEY].toString(); |
485 |
427 CX_DEBUG(("Got filename %s from activity", mFilename.toAscii().data())); |
486 } |
428 |
487 |
429 CX_DEBUG_EXIT_FUNCTION(); |
488 // --------------------------------------------------------------------------- |
430 } |
489 // CxuiPostcaptureView::showEvent |
431 |
490 // |
432 /*! |
491 // --------------------------------------------------------------------------- |
433 * Save view state to activity. |
492 // |
434 */ |
|
435 void CxuiPostcaptureView::saveActivity() |
|
436 { |
|
437 CX_DEBUG_ENTER_FUNCTION(); |
|
438 QVariantMap data; |
|
439 QVariantHash params; |
|
440 |
|
441 QString filename = getCurrentFilename(); |
|
442 CX_DEBUG(("Saving filename %s", filename.toAscii().data())); |
|
443 data.insert(FILENAME_KEY, filename); |
|
444 |
|
445 QImage img(mMainWindow->rect().size(), QImage::Format_ARGB32_Premultiplied); |
|
446 QPainter p(&img); |
|
447 mMainWindow->render(&p, mMainWindow->rect(), mMainWindow->rect()); |
|
448 |
|
449 QPixmap screenshot = QPixmap::fromImage(img); |
|
450 |
|
451 params.insert("screenshot", screenshot); |
|
452 if (mEngine->mode() == Cxe::ImageMode) { |
|
453 mActivityManager->removeActivity(CxuiActivityIds::STILL_POSTCAPTURE_ACTIVITY); |
|
454 mActivityManager->addActivity(CxuiActivityIds::STILL_POSTCAPTURE_ACTIVITY, data, params); |
|
455 } else { |
|
456 mActivityManager->removeActivity(CxuiActivityIds::VIDEO_POSTCAPTURE_ACTIVITY); |
|
457 mActivityManager->addActivity(CxuiActivityIds::VIDEO_POSTCAPTURE_ACTIVITY, data, params); |
|
458 } |
|
459 CX_DEBUG_EXIT_FUNCTION(); |
|
460 } |
|
461 |
|
462 /*! |
|
463 * Clear activity from activity manager. |
|
464 */ |
|
465 void CxuiPostcaptureView::clearActivity() |
|
466 { |
|
467 CX_DEBUG_ENTER_FUNCTION(); |
|
468 mActivityManager->removeActivity(CxuiActivityIds::STILL_POSTCAPTURE_ACTIVITY); |
|
469 mActivityManager->removeActivity(CxuiActivityIds::VIDEO_POSTCAPTURE_ACTIVITY); |
|
470 CX_DEBUG_EXIT_FUNCTION(); |
|
471 } |
|
472 |
|
473 /*! |
|
474 * Show event for this view. |
|
475 * Update snapshot and start timers. |
|
476 */ |
493 void CxuiPostcaptureView::showEvent(QShowEvent *event) |
477 void CxuiPostcaptureView::showEvent(QShowEvent *event) |
494 { |
478 { |
495 CX_DEBUG_ENTER_FUNCTION(); |
479 CX_DEBUG_ENTER_FUNCTION(); |
496 |
480 |
497 QGraphicsWidget::showEvent(event); |
481 QGraphicsWidget::showEvent(event); |
579 } |
562 } |
580 |
563 |
581 CX_DEBUG_EXIT_FUNCTION(); |
564 CX_DEBUG_EXIT_FUNCTION(); |
582 } |
565 } |
583 |
566 |
584 // --------------------------------------------------------------------------- |
567 /*! |
585 // CxuiPostcaptureView::setImage |
568 * Updates snapshot image. In normal case snapshot is retrieved from engine |
586 // |
569 * but if we are restoring camera to post-capture through activity, then |
587 // --------------------------------------------------------------------------- |
570 * we get snapshot from thumbnail manager. |
588 // |
571 */ |
589 void CxuiPostcaptureView::updateSnapshotImage() |
572 void CxuiPostcaptureView::updateSnapshotImage() |
590 { |
573 { |
591 CX_DEBUG_ENTER_FUNCTION(); |
574 CX_DEBUG_ENTER_FUNCTION(); |
592 |
575 |
593 QPixmap snapshot; |
576 if (!mFilename.isNull()) { |
594 |
577 CX_DEBUG(("CxuiPostcaptureView::updateSnapshot restoring activity")); |
595 if (mEngine->mode() == ImageMode) { |
578 // filename set, we are restoring activity |
596 if( mEngine->stillCaptureControl().imageCount() > 0 ) { |
579 if (QFile::exists(mFilename)) { |
597 snapshot = mEngine->stillCaptureControl()[0].snapshot(); |
580 CX_DEBUG(("Filename ok, requesting thumbnail from TNM")); |
|
581 if (!mThumbnailManager) { |
|
582 mThumbnailManager = new ThumbnailManager(); |
|
583 connect(mThumbnailManager, SIGNAL(thumbnailReady(QPixmap, void *, int, int)), |
|
584 this, SLOT(handleThumbnailReady(QPixmap, void*, int, int))); |
|
585 mThumbnailManager->setThumbnailSize(ThumbnailManager::ThumbnailLarge); |
|
586 } |
|
587 mThumbnailManager->getThumbnail(mFilename); |
|
588 CX_DEBUG(("Thumbnail requested")); |
|
589 |
|
590 } else { |
|
591 // file deleted |
|
592 CX_DEBUG(("File %s has been deleted, going back to pre-capture", mFilename.toAscii().data())); |
|
593 goToPrecaptureView(); |
598 } |
594 } |
599 } else { |
595 } else { |
600 snapshot = mEngine->videoCaptureControl().snapshot(); |
596 QPixmap snapshot; |
601 } |
597 if (mEngine->mode() == ImageMode) { |
602 |
598 if( mEngine->stillCaptureControl().imageCount() > 0 ) { |
603 if (mImageLabel) { |
599 snapshot = mEngine->stillCaptureControl()[0].snapshot(); |
604 mImageLabel->setIcon(HbIcon(QIcon(snapshot))); |
600 } |
605 } else { |
601 } else { |
606 // do nothing |
602 snapshot = mEngine->videoCaptureControl().snapshot(); |
607 } |
603 } |
608 |
604 if (mImageLabel) { |
609 CX_DEBUG_EXIT_FUNCTION(); |
605 mImageLabel->setIcon(HbIcon(QIcon(snapshot))); |
610 } |
606 } else { |
611 |
607 // do nothing |
612 /*! |
608 } |
613 Launches "Not supported yet" notification. |
609 } |
614 */ |
610 |
615 void CxuiPostcaptureView::launchNotSupportedNotification() |
|
616 { |
|
617 CX_DEBUG_ENTER_FUNCTION(); |
|
618 HbNotificationDialog::launchDialog("Notification", "Not supported yet"); |
|
619 CX_DEBUG_EXIT_FUNCTION(); |
611 CX_DEBUG_EXIT_FUNCTION(); |
620 } |
612 } |
621 |
613 |
622 /* ! |
614 /* ! |
623 * gets the filename of the current file |
615 * gets the filename of the current file |
624 */ |
616 */ |
625 QString CxuiPostcaptureView::getCurrentFilename() |
617 QString CxuiPostcaptureView::getCurrentFilename() |
626 { |
618 { |
627 CX_DEBUG_ENTER_FUNCTION(); |
619 CX_DEBUG_ENTER_FUNCTION(); |
628 |
620 |
|
621 if (!mFilename.isNull()) { |
|
622 // post-capture started by activity, engine doesn't contain correct |
|
623 // filename anymore so use the stored one |
|
624 CX_DEBUG(("Using filename saved in activity")); |
|
625 CX_DEBUG_EXIT_FUNCTION(); |
|
626 return mFilename; |
|
627 } |
|
628 |
|
629 CX_DEBUG(("Getting filename from engine")); |
629 QString filename; |
630 QString filename; |
630 |
631 |
631 if (mEngine->mode() == Cxe::VideoMode) { |
632 if (mEngine->mode() == Cxe::VideoMode) { |
632 filename = mEngine->videoCaptureControl().filename(); |
633 filename = mEngine->videoCaptureControl().filename(); |
633 } else { |
634 } else { |
665 QString filename = getCurrentFilename(); |
658 QString filename = getCurrentFilename(); |
666 serviceProvider->sendFilenameToClientAndExit(filename); |
659 serviceProvider->sendFilenameToClientAndExit(filename); |
667 } |
660 } |
668 |
661 |
669 /*! |
662 /*! |
670 Launches the Videos applications as a separate process |
663 * Handle exiting standby. |
671 */ |
664 */ |
672 void CxuiPostcaptureView::launchVideosApp() |
665 void CxuiPostcaptureView::exitStandby() |
673 { |
666 { |
674 //Releasing cameda device in order to free |
667 CX_DEBUG_ENTER_FUNCTION(); |
675 //graphical memory |
668 |
676 releaseCamera(); |
669 // Common functionality first. |
677 QProcess::startDetached(VideosAppExe); |
670 CxuiView::exitStandby(); |
678 } |
671 |
679 |
672 //!@note We should not start timers until we receive the ShowEvent |
680 /*! |
673 showControls(); |
681 Handle cases when we loose focus |
674 |
682 */ |
675 CX_DEBUG_EXIT_FUNCTION(); |
683 void CxuiPostcaptureView::handleFocusLost() |
676 } |
684 { |
677 |
685 CX_DEBUG_ENTER_FUNCTION(); |
678 /*! |
686 |
679 * Handle entering standby. |
687 // we have lost focus |
680 */ |
688 releaseCamera(); |
681 void CxuiPostcaptureView::enterStandby() |
|
682 { |
|
683 CX_DEBUG_ENTER_FUNCTION(); |
|
684 |
|
685 // Common functionality (release camera). |
|
686 CxuiView::enterStandby(); |
|
687 |
689 stopTimers(); |
688 stopTimers(); |
690 hideControls(); |
689 hideControls(); |
691 |
690 |
692 CX_DEBUG_EXIT_FUNCTION(); |
691 CX_DEBUG_EXIT_FUNCTION(); |
693 } |
692 } |
694 |
693 |
695 |
694 /*! |
|
695 * Handle thumbnail received from ThumbnailManager. |
|
696 * |
|
697 * @param thumbnail Thumbnail as QPixmap |
|
698 * @param clientData Not used |
|
699 * @param id Thumbnail manager request id |
|
700 * @param errorCode Error code |
|
701 */ |
|
702 void CxuiPostcaptureView::handleThumbnailReady(QPixmap thumbnail, void *clientData, int id, int errorCode) |
|
703 { |
|
704 CX_DEBUG_ENTER_FUNCTION(); |
|
705 |
|
706 Q_UNUSED(clientData); |
|
707 Q_UNUSED(id); |
|
708 |
|
709 if (thumbnail.isNull()) { |
|
710 CX_DEBUG(("Received null thumbnail from TNM, going to pre-capture. Error=%d", errorCode)); |
|
711 // null thumbnail, go to precapture |
|
712 goToPrecaptureView(); |
|
713 } else if (mImageLabel) { |
|
714 mImageLabel->setIcon(HbIcon(QIcon(thumbnail))); |
|
715 } |
|
716 |
|
717 CX_DEBUG_EXIT_FUNCTION(); |
|
718 } |
|
719 |
|
720 /*! |
|
721 Start the timers |
|
722 */ |
696 void CxuiPostcaptureView::startTimers() |
723 void CxuiPostcaptureView::startTimers() |
697 { |
724 { |
698 CX_DEBUG_ENTER_FUNCTION(); |
725 CX_DEBUG_ENTER_FUNCTION(); |
699 |
726 |
700 // we start timers only once in a given postcapture view session |
727 // we start timers only once in a given postcapture view session |
701 if (!mTimersStarted) { |
728 if(!mTimersStarted) { |
702 int postCaptureTimeout = 0; |
729 startPostcaptureTimer(); |
703 QString settingId; |
730 startReleaseTimers(); |
704 |
731 mTimersStarted = true; |
705 if (mEngine->mode() == ImageMode) { |
732 } |
706 settingId = CxeSettingIds::STILL_SHOWCAPTURED; |
733 |
|
734 CX_DEBUG_EXIT_FUNCTION(); |
|
735 } |
|
736 |
|
737 /*! |
|
738 Start the timer to return to pre-capture view |
|
739 */ |
|
740 void CxuiPostcaptureView::startPostcaptureTimer() |
|
741 { |
|
742 CX_DEBUG_ENTER_FUNCTION(); |
|
743 |
|
744 if (!mFilename.isNull()) { |
|
745 // restored from activity, don't do post-capture timeout |
|
746 CX_DEBUG_EXIT_FUNCTION(); |
|
747 return; |
|
748 } |
|
749 |
|
750 int postCaptureTimeout = 0; |
|
751 QString settingId; |
|
752 |
|
753 if (mEngine->mode() == ImageMode) { |
|
754 settingId = CxeSettingIds::STILL_SHOWCAPTURED; |
|
755 } else { |
|
756 settingId = CxeSettingIds::VIDEO_SHOWCAPTURED; |
|
757 } |
|
758 |
|
759 if (!CxuiServiceProvider::isCameraEmbedded()) { |
|
760 CxeError::Id err = mEngine->settings().get(settingId, postCaptureTimeout); |
|
761 |
|
762 if (postCaptureTimeout > 0 && err == CxeError::None) { |
|
763 mPostcaptureTimer.start(postCaptureTimeout); |
707 } else { |
764 } else { |
708 settingId = CxeSettingIds::VIDEO_SHOWCAPTURED; |
765 // do nothing |
709 } |
766 } |
710 |
767 } |
711 if (!CxuiServiceProvider::isCameraEmbedded()) { |
768 |
712 CxeError::Id err = mEngine->settings().get(settingId, postCaptureTimeout); |
769 CX_DEBUG_EXIT_FUNCTION(); |
713 |
770 } |
714 if (postCaptureTimeout > 0 && err == CxeError::None) { |
771 |
715 mPostcaptureTimer.start(postCaptureTimeout); |
772 /*! |
716 } else { |
773 Start the timers to stop viewfinder and release the camera |
717 // do nothing |
774 */ |
718 } |
775 void CxuiPostcaptureView::startReleaseTimers() |
719 } |
776 { |
720 |
777 CX_DEBUG_ENTER_FUNCTION(); |
721 // start the hide control timer. |
778 |
722 mHideControlsTimeout.start(CXUI_HIDE_CONTROLS_TIMEOUT); |
779 // Release camera and stop viewfinder if user stays in postcapture long enough. |
723 |
780 // Battery could otherwise drain fast. |
724 //! @todo Temporarily disabling release timer because of |
781 mReleaseCameraTimer.start(CXUI_RELEASE_CAMERA_TIMEOUT); |
725 // graphics memory problems related to releasing and reserving again. |
782 mStopViewfinderTimer.start(CXUI_STOP_VIEWFINDER_TIMEOUT); |
726 // mReleaseCameraTimer.start(CXUI_RELEASE_CAMERA_TIMEOUT); |
|
727 // mStopViewfinderTimer.start(CXUI_STOP_VIEWFINDER_TIMEOUT); |
|
728 |
|
729 // we make sure that timers are started only once in a given postcaptureview session |
|
730 mTimersStarted = true; |
|
731 } |
|
732 |
|
733 // show controls when we get back focus |
|
734 showControls(); |
|
735 |
783 |
736 CX_DEBUG_EXIT_FUNCTION(); |
784 CX_DEBUG_EXIT_FUNCTION(); |
737 } |
785 } |
738 |
786 |
739 void CxuiPostcaptureView::stopTimers() |
787 void CxuiPostcaptureView::stopTimers() |