1 /* |
1 /* |
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
2 * Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). |
3 * All rights reserved. |
3 * All rights reserved. |
4 * This component and the accompanying materials are made available |
4 * This component and the accompanying materials are made available |
5 * under the terms of "Eclipse Public License v1.0" |
5 * under the terms of "Eclipse Public License v1.0" |
6 * which accompanies this distribution, and is available |
6 * which accompanies this distribution, and is available |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
57 |
57 |
58 |
58 |
59 using namespace CxUiLayout; |
59 using namespace CxUiLayout; |
60 using namespace Cxe; |
60 using namespace Cxe; |
61 |
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 |
62 |
67 //!@todo Temporarily disabled. |
63 //!@todo Temporarily disabled. |
68 //const int CXUI_STOP_VIEWFINDER_TIMEOUT = 5000; // 5 seconds |
64 //const int CXUI_STOP_VIEWFINDER_TIMEOUT = 5000; // 5 seconds |
69 //const int CXUI_RELEASE_CAMERA_TIMEOUT = 10000; // 10 seconds |
65 //const int CXUI_RELEASE_CAMERA_TIMEOUT = 10000; // 10 seconds |
70 |
66 |
72 // CxuiPostcaptureView::CxuiPostcaptureView |
68 // CxuiPostcaptureView::CxuiPostcaptureView |
73 // |
69 // |
74 // --------------------------------------------------------------------------- |
70 // --------------------------------------------------------------------------- |
75 // |
71 // |
76 CxuiPostcaptureView::CxuiPostcaptureView(QGraphicsItem *parent) : |
72 CxuiPostcaptureView::CxuiPostcaptureView(QGraphicsItem *parent) : |
77 HbView(parent), |
73 CxuiView(parent), |
78 mMainWindow(NULL), |
|
79 mEngine(NULL), |
|
80 mStillToolbar(NULL), |
74 mStillToolbar(NULL), |
81 mVideoToolbar(NULL), |
75 mVideoToolbar(NULL), |
82 mEmbeddedToolbar(NULL), |
76 mEmbeddedToolbar(NULL), |
83 mBackgroundItem(NULL), |
77 mBackgroundItem(NULL), |
84 mImageLabel(NULL), |
78 mImageLabel(NULL), |
85 mHideControlsTimeout(this), |
|
86 mStopViewfinderTimer(this), |
79 mStopViewfinderTimer(this), |
87 mReleaseCameraTimer(this), |
80 mReleaseCameraTimer(this), |
88 mPostcaptureTimer(this), |
81 mPostcaptureTimer(this), |
89 mTimersStarted(false) |
82 mTimersStarted(false), |
|
83 mDeleteNoteOpen(false) |
90 { |
84 { |
91 CX_DEBUG_IN_FUNCTION(); |
85 CX_DEBUG_IN_FUNCTION(); |
92 |
86 |
93 CX_DEBUG_EXIT_FUNCTION(); |
87 CX_DEBUG_EXIT_FUNCTION(); |
94 } |
88 } |
114 void CxuiPostcaptureView::construct(HbMainWindow *mainwindow, CxeEngine *engine, |
108 void CxuiPostcaptureView::construct(HbMainWindow *mainwindow, CxeEngine *engine, |
115 CxuiDocumentLoader *documentLoader) |
109 CxuiDocumentLoader *documentLoader) |
116 { |
110 { |
117 CX_DEBUG_ENTER_FUNCTION(); |
111 CX_DEBUG_ENTER_FUNCTION(); |
118 |
112 |
119 mMainWindow = mainwindow; |
113 CxuiView::construct(mainwindow, engine, documentLoader, NULL); |
120 mEngine = engine; |
|
121 mDocumentLoader = documentLoader; |
|
122 |
114 |
123 // set back action to go back to pre-capture |
115 // set back action to go back to pre-capture |
124 HbAction *backAction = new HbAction(Hb::BackNaviAction, this); |
116 HbAction *backAction = new HbAction(Hb::BackNaviAction, this); |
125 connect(backAction, SIGNAL(triggered()), this, SLOT(goToPrecaptureView())); |
117 connect(backAction, SIGNAL(triggered()), this, SLOT(goToPrecaptureView())); |
126 setNavigationAction(backAction); |
118 setNavigationAction(backAction); |
236 HbMessageBox::question(hbTrId("txt_cam_other_delete_image"), |
232 HbMessageBox::question(hbTrId("txt_cam_other_delete_image"), |
237 this, |
233 this, |
238 SLOT(handleDeleteDialogClosed(HbAction*))); |
234 SLOT(handleDeleteDialogClosed(HbAction*))); |
239 } |
235 } |
240 |
236 |
|
237 mDeleteNoteOpen = true; |
241 CX_DEBUG_EXIT_FUNCTION(); |
238 CX_DEBUG_EXIT_FUNCTION(); |
242 } |
239 } |
243 |
240 |
244 // --------------------------------------------------------------------------- |
241 // --------------------------------------------------------------------------- |
245 // CxuiPostcaptureView::handleDeleteDialogClosed |
242 // CxuiPostcaptureView::handleDeleteDialogClosed |
249 void CxuiPostcaptureView::handleDeleteDialogClosed(HbAction *action) |
246 void CxuiPostcaptureView::handleDeleteDialogClosed(HbAction *action) |
250 { |
247 { |
251 CX_DEBUG_ENTER_FUNCTION(); |
248 CX_DEBUG_ENTER_FUNCTION(); |
252 |
249 |
253 hideControls(); |
250 hideControls(); |
|
251 mDeleteNoteOpen = false; |
254 |
252 |
255 HbMessageBox *dlg = qobject_cast<HbMessageBox*>(sender()); |
253 HbMessageBox *dlg = qobject_cast<HbMessageBox*>(sender()); |
256 |
254 |
257 // check that it was "primary action" that closed the dialog |
255 // check that it was "primary action" that closed the dialog |
258 if (dlg && dlg->actions().at(0) == action) { |
256 if (dlg && dlg->actions().at(0) == action) { |
342 mStopViewfinderTimer.stop(); |
340 mStopViewfinderTimer.stop(); |
343 |
341 |
344 CX_DEBUG_EXIT_FUNCTION(); |
342 CX_DEBUG_EXIT_FUNCTION(); |
345 } |
343 } |
346 |
344 |
347 // --------------------------------------------------------------------------- |
345 /*! |
348 // CxuiPostcaptureView::releaseCamera |
346 * Hides toolbar. |
349 // |
347 */ |
350 // --------------------------------------------------------------------------- |
348 void CxuiPostcaptureView::hideToolbar() |
351 // |
349 { |
352 void CxuiPostcaptureView::releaseCamera() |
350 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) { |
351 if (mStillToolbar) { |
374 mStillToolbar->hide(); |
352 mStillToolbar->hide(); |
375 } |
353 } |
376 if (mVideoToolbar) { |
354 if (mVideoToolbar) { |
377 mVideoToolbar->hide(); |
355 mVideoToolbar->hide(); |
378 } |
356 } |
379 if (mEmbeddedToolbar) { |
357 if (mEmbeddedToolbar) { |
380 mEmbeddedToolbar->hide(); |
358 mEmbeddedToolbar->hide(); |
381 } |
359 } |
382 |
|
383 hideItems(Hb::AllItems); |
|
384 |
|
385 mControlsVisible = false; |
|
386 |
|
387 // stop hiding control timer |
|
388 mHideControlsTimeout.stop(); |
|
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(); |
360 CX_DEBUG_EXIT_FUNCTION(); |
433 } |
361 } |
434 |
362 |
435 // --------------------------------------------------------------------------- |
363 // --------------------------------------------------------------------------- |
436 // CxuiPostcaptureView::eventFilter |
364 // CxuiPostcaptureView::eventFilter |
665 QString filename = getCurrentFilename(); |
575 QString filename = getCurrentFilename(); |
666 serviceProvider->sendFilenameToClientAndExit(filename); |
576 serviceProvider->sendFilenameToClientAndExit(filename); |
667 } |
577 } |
668 |
578 |
669 /*! |
579 /*! |
670 Launches the Videos applications as a separate process |
580 Handle cases when we gain focus |
671 */ |
581 */ |
672 void CxuiPostcaptureView::launchVideosApp() |
582 void CxuiPostcaptureView::handleFocusGained() |
673 { |
583 { |
674 //Releasing cameda device in order to free |
584 CX_DEBUG_ENTER_FUNCTION(); |
675 //graphical memory |
585 |
676 releaseCamera(); |
586 //Note: We should not start timers until we receive the ShowEvent |
677 QProcess::startDetached(VideosAppExe); |
587 showControls(); |
|
588 |
|
589 CX_DEBUG_EXIT_FUNCTION(); |
678 } |
590 } |
679 |
591 |
680 /*! |
592 /*! |
681 Handle cases when we loose focus |
593 Handle cases when we loose focus |
682 */ |
594 */ |
690 hideControls(); |
602 hideControls(); |
691 |
603 |
692 CX_DEBUG_EXIT_FUNCTION(); |
604 CX_DEBUG_EXIT_FUNCTION(); |
693 } |
605 } |
694 |
606 |
695 |
607 /*! |
|
608 Start the timers |
|
609 */ |
696 void CxuiPostcaptureView::startTimers() |
610 void CxuiPostcaptureView::startTimers() |
697 { |
611 { |
698 CX_DEBUG_ENTER_FUNCTION(); |
612 CX_DEBUG_ENTER_FUNCTION(); |
699 |
613 |
700 // we start timers only once in a given postcapture view session |
614 // we start timers only once in a given postcapture view session |
701 if (!mTimersStarted) { |
615 if(!mTimersStarted) { |
702 int postCaptureTimeout = 0; |
616 startPostcaptureTimer(); |
703 QString settingId; |
617 startReleaseTimers(); |
704 |
618 mTimersStarted = true; |
705 if (mEngine->mode() == ImageMode) { |
619 } |
706 settingId = CxeSettingIds::STILL_SHOWCAPTURED; |
620 |
|
621 CX_DEBUG_EXIT_FUNCTION(); |
|
622 } |
|
623 |
|
624 /*! |
|
625 Start the timer to return to pre-capture view |
|
626 */ |
|
627 void CxuiPostcaptureView::startPostcaptureTimer() |
|
628 { |
|
629 CX_DEBUG_ENTER_FUNCTION(); |
|
630 |
|
631 int postCaptureTimeout = 0; |
|
632 QString settingId; |
|
633 |
|
634 if (mEngine->mode() == ImageMode) { |
|
635 settingId = CxeSettingIds::STILL_SHOWCAPTURED; |
|
636 } else { |
|
637 settingId = CxeSettingIds::VIDEO_SHOWCAPTURED; |
|
638 } |
|
639 |
|
640 if (!CxuiServiceProvider::isCameraEmbedded()) { |
|
641 CxeError::Id err = mEngine->settings().get(settingId, postCaptureTimeout); |
|
642 |
|
643 if (postCaptureTimeout > 0 && err == CxeError::None) { |
|
644 mPostcaptureTimer.start(postCaptureTimeout); |
707 } else { |
645 } else { |
708 settingId = CxeSettingIds::VIDEO_SHOWCAPTURED; |
646 // do nothing |
709 } |
647 } |
710 |
648 } |
711 if (!CxuiServiceProvider::isCameraEmbedded()) { |
649 |
712 CxeError::Id err = mEngine->settings().get(settingId, postCaptureTimeout); |
650 CX_DEBUG_EXIT_FUNCTION(); |
713 |
651 } |
714 if (postCaptureTimeout > 0 && err == CxeError::None) { |
652 |
715 mPostcaptureTimer.start(postCaptureTimeout); |
653 /*! |
716 } else { |
654 Start the timers to stop viewfinder and release the camera |
717 // do nothing |
655 */ |
718 } |
656 void CxuiPostcaptureView::startReleaseTimers() |
719 } |
657 { |
720 |
658 CX_DEBUG_ENTER_FUNCTION(); |
721 // start the hide control timer. |
659 |
722 mHideControlsTimeout.start(CXUI_HIDE_CONTROLS_TIMEOUT); |
660 // Todo Note: Temporarily disabling release timer because of |
723 |
661 // graphics memory problems related to releasing and reserving again. |
724 //! @todo Temporarily disabling release timer because of |
662 // mReleaseCameraTimer.start(CXUI_RELEASE_CAMERA_TIMEOUT); |
725 // graphics memory problems related to releasing and reserving again. |
663 // 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 |
664 |
736 CX_DEBUG_EXIT_FUNCTION(); |
665 CX_DEBUG_EXIT_FUNCTION(); |
737 } |
666 } |
738 |
667 |
739 void CxuiPostcaptureView::stopTimers() |
668 void CxuiPostcaptureView::stopTimers() |