29 #include <hbtoolbarextension.h> |
29 #include <hbtoolbarextension.h> |
30 #include <hbtoolbutton.h> |
30 #include <hbtoolbutton.h> |
31 #include <hbdeviceprofile.h> // HbDeviceProfile |
31 #include <hbdeviceprofile.h> // HbDeviceProfile |
32 #include <hbmenu.h> |
32 #include <hbmenu.h> |
33 #include <hbicon.h> |
33 #include <hbicon.h> |
|
34 #include <hbactivitymanager.h> |
34 |
35 |
35 #include "cxuiselftimer.h" |
36 #include "cxuiselftimer.h" |
36 #include "cxeengine.h" |
37 #include "cxeengine.h" |
37 #include "cxeviewfindercontrol.h" |
38 #include "cxeviewfindercontrol.h" |
38 #include "cxecameradevicecontrol.h" |
39 #include "cxecameradevicecontrol.h" |
80 { |
81 { |
81 CX_DEBUG_IN_FUNCTION(); |
82 CX_DEBUG_IN_FUNCTION(); |
82 delete mSelfTimer; |
83 delete mSelfTimer; |
83 } |
84 } |
84 |
85 |
|
86 /*! |
|
87 * Construct-method handles initialisation tasks for this class. Needs to be called |
|
88 * before the instance of this class is used. |
|
89 * @param mainwindow |
|
90 * @param engine |
|
91 * @param documentLoader |
|
92 * @param keyHandler |
|
93 */ |
85 void CxuiStillPrecaptureView::construct(HbMainWindow *mainwindow, CxeEngine *engine, |
94 void CxuiStillPrecaptureView::construct(HbMainWindow *mainwindow, CxeEngine *engine, |
86 CxuiDocumentLoader *documentLoader, |
95 CxuiDocumentLoader *documentLoader, |
87 CxuiCaptureKeyHandler *keyHandler) |
96 CxuiCaptureKeyHandler *keyHandler, |
|
97 HbActivityManager *activityManager) |
88 { |
98 { |
89 CX_DEBUG_ENTER_FUNCTION(); |
99 CX_DEBUG_ENTER_FUNCTION(); |
90 OstTrace0( camerax_performance, CXUISTILLPRECAPTUREVIEW_CONSTRUCT, "msg: e_CX_STILLPRECAPVIEW_CONSTRUCT 1" ); |
100 OstTrace0( camerax_performance, CXUISTILLPRECAPTUREVIEW_CONSTRUCT, "msg: e_CX_STILLPRECAPVIEW_CONSTRUCT 1" ); |
91 |
101 |
92 // constuct base class |
102 // constuct base class |
93 CxuiPrecaptureView::construct(mainwindow, engine, documentLoader, keyHandler); |
103 CxuiPrecaptureView::construct(mainwindow, engine, documentLoader, keyHandler, activityManager); |
94 |
104 |
95 connect(&mEngine->autoFocusControl(), SIGNAL(stateChanged(CxeAutoFocusControl::State,CxeError::Id)), |
105 connect(&mEngine->autoFocusControl(), SIGNAL(stateChanged(CxeAutoFocusControl::State,CxeError::Id)), |
96 this, SLOT(handleAutoFocusStateChanged(CxeAutoFocusControl::State,CxeError::Id))); |
106 this, SLOT(handleAutoFocusStateChanged(CxeAutoFocusControl::State,CxeError::Id))); |
97 connect(&mEngine->stillCaptureControl(), SIGNAL(snapshotReady(CxeError::Id, const QPixmap&, int)), |
107 connect(&mEngine->stillCaptureControl(), SIGNAL(snapshotReady(CxeError::Id, const QImage&, int)), |
98 this, SLOT(handleSnapshot(CxeError::Id))); |
108 this, SLOT(handleSnapshot(CxeError::Id))); |
99 connect(&mEngine->stillCaptureControl(), SIGNAL(stateChanged(CxeStillCaptureControl::State, CxeError::Id)), |
109 connect(&mEngine->stillCaptureControl(), SIGNAL(stateChanged(CxeStillCaptureControl::State, CxeError::Id)), |
100 this, SLOT(handleStillCaptureStateChanged(CxeStillCaptureControl::State, CxeError::Id))); |
110 this, SLOT(handleStillCaptureStateChanged(CxeStillCaptureControl::State, CxeError::Id))); |
101 connect(&mEngine->viewfinderControl(), SIGNAL(stateChanged(CxeViewfinderControl::State, CxeError::Id)), |
111 connect(&mEngine->viewfinderControl(), SIGNAL(stateChanged(CxeViewfinderControl::State, CxeError::Id)), |
102 this, SLOT(handleViewfinderStateChanged(CxeViewfinderControl::State, CxeError::Id))); |
112 this, SLOT(handleViewfinderStateChanged(CxeViewfinderControl::State, CxeError::Id))); |
109 hideControls(); |
119 hideControls(); |
110 |
120 |
111 mSelfTimer = new CxuiSelfTimer(mEngine->settings()); |
121 mSelfTimer = new CxuiSelfTimer(mEngine->settings()); |
112 connect(mSelfTimer, SIGNAL(timerFinished()), this, SLOT(focusAndCapture())); |
122 connect(mSelfTimer, SIGNAL(timerFinished()), this, SLOT(focusAndCapture())); |
113 |
123 |
|
124 int value = Cxe::GeoTaggingDisclaimerDisabled; |
|
125 mEngine->settings().get(CxeSettingIds::GEOTAGGING_DISCLAIMER, value); |
|
126 if(value == Cxe::GeoTaggingDisclaimerEnabled) { |
|
127 launchGeoTaggingDisclaimerDialog(); |
|
128 } |
|
129 |
114 OstTrace0( camerax_performance, DUP1_CXUISTILLPRECAPTUREVIEW_CONSTRUCT, "msg: e_CX_STILLPRECAPVIEW_CONSTRUCT 0" ); |
130 OstTrace0( camerax_performance, DUP1_CXUISTILLPRECAPTUREVIEW_CONSTRUCT, "msg: e_CX_STILLPRECAPVIEW_CONSTRUCT 0" ); |
115 CX_DEBUG_EXIT_FUNCTION(); |
131 CX_DEBUG_EXIT_FUNCTION(); |
116 } |
132 } |
117 |
133 |
|
134 /*! |
|
135 * Loads default widgets in layouts xml. |
|
136 */ |
118 void CxuiStillPrecaptureView::loadDefaultWidgets() |
137 void CxuiStillPrecaptureView::loadDefaultWidgets() |
119 { |
138 { |
120 CX_DEBUG_ENTER_FUNCTION(); |
139 CX_DEBUG_ENTER_FUNCTION(); |
121 CX_DEBUG_ASSERT(mDocumentLoader); |
140 CX_DEBUG_ASSERT(mDocumentLoader); |
122 |
141 |
128 |
147 |
129 widget = mDocumentLoader->findWidget(STILL_PRE_CAPTURE_QUALITY_ICON); |
148 widget = mDocumentLoader->findWidget(STILL_PRE_CAPTURE_QUALITY_ICON); |
130 mQualityIcon = qobject_cast<HbLabel *>(widget); |
149 mQualityIcon = qobject_cast<HbLabel *>(widget); |
131 CX_DEBUG_ASSERT(mQualityIcon); |
150 CX_DEBUG_ASSERT(mQualityIcon); |
132 |
151 |
|
152 widget = mDocumentLoader->findWidget(STILL_PRE_CAPTURE_GEOTAGGING_INDICATOR_ICON); |
|
153 mGeoTaggingIndicatorIcon = qobject_cast<HbLabel *>(widget); |
|
154 CX_DEBUG_ASSERT(mGeoTaggingIndicatorIcon); |
|
155 |
133 widget = mDocumentLoader->findWidget(STILL_PRE_CAPTURE_FACE_TRACKING_ICON); |
156 widget = mDocumentLoader->findWidget(STILL_PRE_CAPTURE_FACE_TRACKING_ICON); |
134 mFaceTrackingIcon = qobject_cast<HbLabel *>(widget); |
157 mFaceTrackingIcon = qobject_cast<HbLabel *>(widget); |
135 CX_DEBUG_ASSERT(mFaceTrackingIcon); |
158 CX_DEBUG_ASSERT(mFaceTrackingIcon); |
136 |
159 |
137 widget = mDocumentLoader->findWidget(STILL_PRE_CAPTURE_INDICATOR_CONTAINER); |
160 widget = mDocumentLoader->findWidget(STILL_PRE_CAPTURE_INDICATOR_CONTAINER); |
259 updateSceneIcon(sceneId); |
285 updateSceneIcon(sceneId); |
260 } |
286 } |
261 |
287 |
262 hideControls(); |
288 hideControls(); |
263 |
289 |
|
290 // View is ready. Needed for startup performance automated testing. |
|
291 emit viewReady(); |
|
292 |
264 OstTrace0( camerax_performance, DUP1_CXUISTILLPRECAPTUREVIEW_LOADWIDGETS, "msg: e_CX_STILLPRECAPTUREVIEW_LOADWIDGETS 0" ); |
293 OstTrace0( camerax_performance, DUP1_CXUISTILLPRECAPTUREVIEW_LOADWIDGETS, "msg: e_CX_STILLPRECAPTUREVIEW_LOADWIDGETS 0" ); |
|
294 CX_DEBUG_EXIT_FUNCTION(); |
|
295 } |
|
296 |
|
297 /*! |
|
298 * Restore view state from activity. |
|
299 */ |
|
300 void CxuiStillPrecaptureView::restoreActivity(const QString &activityId, const QVariant &data) |
|
301 { |
|
302 Q_UNUSED(activityId); |
|
303 Q_UNUSED(data); |
|
304 |
|
305 CX_DEBUG_ENTER_FUNCTION(); |
|
306 // no need to restore any state |
|
307 CX_DEBUG_EXIT_FUNCTION(); |
|
308 } |
|
309 |
|
310 /*! |
|
311 * Save view state to activity. |
|
312 */ |
|
313 void CxuiStillPrecaptureView::saveActivity() |
|
314 { |
|
315 CX_DEBUG_ENTER_FUNCTION(); |
|
316 QVariantMap data; |
|
317 QVariantHash params; |
|
318 //@todo: add pre-capture icon as screenshot |
|
319 mActivityManager->removeActivity(CxuiActivityIds::STILL_PRECAPTURE_ACTIVITY); |
|
320 mActivityManager->addActivity(CxuiActivityIds::STILL_PRECAPTURE_ACTIVITY, data, params); |
|
321 CX_DEBUG_EXIT_FUNCTION(); |
|
322 } |
|
323 |
|
324 /*! |
|
325 * Clear activity from activity manager. |
|
326 */ |
|
327 void CxuiStillPrecaptureView::clearActivity() |
|
328 { |
|
329 CX_DEBUG_ENTER_FUNCTION(); |
|
330 mActivityManager->removeActivity(CxuiActivityIds::STILL_PRECAPTURE_ACTIVITY); |
265 CX_DEBUG_EXIT_FUNCTION(); |
331 CX_DEBUG_EXIT_FUNCTION(); |
266 } |
332 } |
267 |
333 |
268 /*! |
334 /*! |
269 * Initializing settings grid |
335 * Initializing settings grid |
306 |
372 |
307 connect(mCaptureKeyHandler, SIGNAL(autofocusKeyPressed()), mSettingsGrid, SLOT(close())); |
373 connect(mCaptureKeyHandler, SIGNAL(autofocusKeyPressed()), mSettingsGrid, SLOT(close())); |
308 } |
374 } |
309 } |
375 } |
310 |
376 |
|
377 /** |
|
378 * Get if postcapture view should be shown or not. |
|
379 * Postcapture view may be shown for a predefined time or |
|
380 * until user dismisses it, or it may be completely disabled. |
|
381 */ |
|
382 bool CxuiStillPrecaptureView::isPostcaptureOn() const |
|
383 { |
|
384 CX_DEBUG_ENTER_FUNCTION(); |
|
385 if (CxuiServiceProvider::isCameraEmbedded()) { |
|
386 // always show post capture in embedded mode |
|
387 CX_DEBUG_EXIT_FUNCTION(); |
|
388 return true; |
|
389 } |
|
390 |
|
391 // Read the value from settings. Ignoring reading error. |
|
392 // On error (missing settings) default to "postcapture on". |
|
393 int showPostcapture(-1); |
|
394 if(mEngine) { |
|
395 mEngine->settings().get(CxeSettingIds::STILL_SHOWCAPTURED, showPostcapture); |
|
396 } |
|
397 |
|
398 CX_DEBUG_EXIT_FUNCTION(); |
|
399 return showPostcapture != 0; // 0 == no postcapture |
|
400 } |
|
401 |
|
402 /*! |
|
403 * Update the scene mode icon. |
|
404 * @param sceneId The new scene id. |
|
405 */ |
|
406 void CxuiStillPrecaptureView::updateSceneIcon(const QString& sceneId) |
|
407 { |
|
408 CX_DEBUG_ENTER_FUNCTION(); |
|
409 |
|
410 if (mEngine->mode() == Cxe::ImageMode) { |
|
411 CX_DEBUG(("CxuiStillPrecaptureView - scene: %s", sceneId.toAscii().constData())); |
|
412 |
|
413 // No need to update icon, if widgets are not even loaded yet. |
|
414 // We'll update the icon once the widgets are loaded. |
|
415 if (mWidgetsLoaded) { |
|
416 |
|
417 QString iconObjectName = STILL_PRE_CAPTURE_SCENE_MODE_ACTION; |
|
418 QString icon = getSettingItemIcon(CxeSettingIds::IMAGE_SCENE, sceneId); |
|
419 |
|
420 CX_DEBUG(("CxuiStillPrecaptureView - icon: %s", icon.toAscii().constData())); |
|
421 |
|
422 if (mDocumentLoader) { |
|
423 QObject *obj = mDocumentLoader->findObject(iconObjectName); |
|
424 CX_DEBUG_ASSERT(obj); |
|
425 qobject_cast<HbAction *>(obj)->setIcon(HbIcon(icon)); |
|
426 } |
|
427 } else { |
|
428 CX_DEBUG(("CxuiStillPrecaptureView - widgets not loaded yet, ignored!")); |
|
429 } |
|
430 } |
|
431 CX_DEBUG_EXIT_FUNCTION(); |
|
432 } |
|
433 |
|
434 /*! |
|
435 Update the quality indicator |
|
436 */ |
|
437 void CxuiStillPrecaptureView::updateQualityIcon() |
|
438 { |
|
439 CX_DEBUG_ENTER_FUNCTION(); |
|
440 |
|
441 if (mQualityIcon && mEngine) { |
|
442 QString icon = ""; |
|
443 int currentValue = -1; |
|
444 |
|
445 mEngine->settings().get(CxeSettingIds::IMAGE_QUALITY, currentValue); |
|
446 icon = getSettingItemIcon(CxeSettingIds::IMAGE_QUALITY, currentValue); |
|
447 |
|
448 mQualityIcon->setIcon(HbIcon(icon)); |
|
449 } |
|
450 |
|
451 CX_DEBUG_EXIT_FUNCTION(); |
|
452 } |
311 |
453 |
312 void CxuiStillPrecaptureView::handleSnapshot(CxeError::Id error) |
454 void CxuiStillPrecaptureView::handleSnapshot(CxeError::Id error) |
313 { |
455 { |
314 CX_DEBUG_ENTER_FUNCTION(); |
456 CX_DEBUG_ENTER_FUNCTION(); |
315 |
457 |
596 |
739 |
597 /*! |
740 /*! |
598 * Handle change in viewfinder state. |
741 * Handle change in viewfinder state. |
599 */ |
742 */ |
600 void CxuiStillPrecaptureView::handleViewfinderStateChanged( |
743 void CxuiStillPrecaptureView::handleViewfinderStateChanged( |
601 CxeViewfinderControl::State newState, CxeError::Id /*error*/) |
744 CxeViewfinderControl::State newState, CxeError::Id error) |
602 { |
745 { |
603 CX_DEBUG_ENTER_FUNCTION(); |
746 CX_DEBUG_ENTER_FUNCTION(); |
|
747 // Call base class to get standby timer and display always visible when needed. |
|
748 CxuiPrecaptureView::handleVfStateChanged(newState, error); |
604 |
749 |
605 if (newState == CxeViewfinderControl::Running) { |
750 if (newState == CxeViewfinderControl::Running) { |
606 |
751 |
607 // the toolbar is created when the viewfinder is started the first time |
752 // the toolbar is created when the viewfinder is started the first time |
608 // in order to hide the delay caused by the creation |
753 // in order to hide the delay caused by the creation |
634 capture(); |
779 capture(); |
635 } |
780 } |
636 } |
781 } |
637 } |
782 } |
638 |
783 |
|
784 /*! |
|
785 * Signal used to reset mCapturePending after a short timeout. If the image |
|
786 * cannot be captured within a given time of the key press, it is better to cancel |
|
787 * the whole operation. |
|
788 */ |
639 void CxuiStillPrecaptureView::resetCapturePendingFlag() |
789 void CxuiStillPrecaptureView::resetCapturePendingFlag() |
640 { |
790 { |
641 CX_DEBUG_IN_FUNCTION(); |
791 CX_DEBUG_IN_FUNCTION(); |
642 |
792 |
643 mCapturePending = false; |
793 mCapturePending = false; |
644 } |
|
645 |
|
646 /*! |
|
647 * Slot to handle application being sent to background. |
|
648 */ |
|
649 void CxuiStillPrecaptureView::handleFocusLost() |
|
650 { |
|
651 CX_DEBUG_ENTER_FUNCTION(); |
|
652 |
|
653 if (mSelfTimer && mSelfTimer->isOngoing()) { |
|
654 // If self-timer is running, stop and reset the delay now. |
|
655 mSelfTimer->reset(); |
|
656 } |
|
657 |
|
658 // Release camera as we are going to background. |
|
659 // If taking image is just ongoing, it will be cancelled by engine. |
|
660 releaseCamera(); |
|
661 |
|
662 CX_DEBUG_EXIT_FUNCTION(); |
|
663 } |
794 } |
664 |
795 |
665 /* |
796 /* |
666 Slot for handling scene mode change |
797 Slot for handling scene mode change |
667 \param scene QVariantMap containing settings related to the new scene mode |
798 \param scene QVariantMap containing settings related to the new scene mode |
684 int flashMode(Cxe::FlashAuto); |
815 int flashMode(Cxe::FlashAuto); |
685 mEngine->settings().get(CxeSettingIds::FLASH_MODE, flashMode); |
816 mEngine->settings().get(CxeSettingIds::FLASH_MODE, flashMode); |
686 handleSettingValueChanged(CxeSettingIds::FLASH_MODE, QVariant(flashMode)); |
817 handleSettingValueChanged(CxeSettingIds::FLASH_MODE, QVariant(flashMode)); |
687 } |
818 } |
688 } |
819 } |
|
820 |
|
821 CX_DEBUG_EXIT_FUNCTION(); |
|
822 } |
|
823 |
|
824 /*! |
|
825 * Enter standby mode. |
|
826 */ |
|
827 void CxuiStillPrecaptureView::enterStandby() |
|
828 { |
|
829 CX_DEBUG_ENTER_FUNCTION(); |
|
830 |
|
831 if (mSelfTimer && mSelfTimer->isOngoing()) { |
|
832 // If self-timer is running, stop and reset the delay now. |
|
833 mSelfTimer->reset(); |
|
834 } |
|
835 |
|
836 // Base class handles releasing camera. |
|
837 CxuiPrecaptureView::enterStandby(); |
689 |
838 |
690 CX_DEBUG_EXIT_FUNCTION(); |
839 CX_DEBUG_EXIT_FUNCTION(); |
691 } |
840 } |
692 |
841 |
693 /* |
842 /* |