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". |
59 #include "cxuiprecaptureviewTraces.h" |
59 #include "cxuiprecaptureviewTraces.h" |
60 #endif |
60 #endif |
61 #include "cxuiserviceprovider.h" |
61 #include "cxuiserviceprovider.h" |
62 #include "cxuizoomslider.h" |
62 #include "cxuizoomslider.h" |
63 |
63 |
64 |
|
65 // CONSTANTS |
|
66 const int CXUI_HIDE_CONTROLS_TIMEOUT = 6000; // 6 seconds |
|
67 const QString PhotosAppExe = "photos.exe"; |
|
68 const QString VideosAppExe = "videoplayer.exe"; |
|
69 |
|
70 using namespace CxUiLayout; |
64 using namespace CxUiLayout; |
71 using namespace CxUiSettings; |
65 using namespace CxUiSettings; |
72 using namespace CxUiInternal; |
66 using namespace CxUiInternal; |
73 |
67 |
74 |
68 |
77 // CxuiPrecaptureView::CxuiPrecaptureView |
71 // CxuiPrecaptureView::CxuiPrecaptureView |
78 // Constructor |
72 // Constructor |
79 // --------------------------------------------------------------------------- |
73 // --------------------------------------------------------------------------- |
80 // |
74 // |
81 CxuiPrecaptureView::CxuiPrecaptureView(QGraphicsItem *parent) : |
75 CxuiPrecaptureView::CxuiPrecaptureView(QGraphicsItem *parent) : |
82 HbView(parent), |
76 CxuiView(parent), |
83 mEngine(0), |
|
84 mViewfinder(0), |
77 mViewfinder(0), |
85 mMainWindow(0), |
|
86 mDocumentLoader(0), |
|
87 mDisplayHandler(0), |
78 mDisplayHandler(0), |
88 mControlsVisible(false), |
|
89 mHideControlsTimeout(this), |
|
90 mSlider(0), |
|
91 mToolBar(0), |
|
92 mSettingsGrid(0), |
79 mSettingsGrid(0), |
93 mZoomVisible(false), |
|
94 mWidgetsLoaded(false), |
80 mWidgetsLoaded(false), |
95 mSettingsDialog(NULL), |
81 mSettingsDialog(NULL), |
96 mSettingsDialogList(NULL), |
82 mSettingsDialogList(NULL), |
97 mKeyHandler(NULL), |
|
98 mQualityIcon(NULL), |
83 mQualityIcon(NULL), |
99 mIndicators(NULL), |
|
100 mSettingsDialogHeading(NULL), |
84 mSettingsDialogHeading(NULL), |
101 mSliderSettingsDialog(NULL), |
85 mSliderSettingsDialog(NULL), |
102 mSliderSettingsDialogHeading(NULL), |
86 mSliderSettingsDialogHeading(NULL), |
103 mSettingsSlider(NULL), |
87 mSettingsSlider(NULL), |
104 mSettingsInfo(NULL), |
88 mSettingsInfo(NULL), |
116 QCoreApplication::instance()->removeEventFilter(this); |
100 QCoreApplication::instance()->removeEventFilter(this); |
117 delete mSettingsGrid; |
101 delete mSettingsGrid; |
118 CX_DEBUG_EXIT_FUNCTION(); |
102 CX_DEBUG_EXIT_FUNCTION(); |
119 } |
103 } |
120 |
104 |
121 |
105 /** |
|
106 * CxuiPrecaptureView::construct |
|
107 * Construct-method handles initialisation tasks for this class. |
|
108 * @param mainwindow |
|
109 * @param engine |
|
110 * @param documentLoader |
|
111 * @param keyHandler |
|
112 */ |
122 void CxuiPrecaptureView::construct(HbMainWindow *mainWindow, CxeEngine *engine, |
113 void CxuiPrecaptureView::construct(HbMainWindow *mainWindow, CxeEngine *engine, |
123 CxuiDocumentLoader *documentLoader, |
114 CxuiDocumentLoader *documentLoader, |
124 CxuiCaptureKeyHandler * keyHandler) |
115 CxuiCaptureKeyHandler * keyHandler) |
125 { |
116 { |
126 CX_DEBUG_ENTER_FUNCTION(); |
117 CX_DEBUG_ENTER_FUNCTION(); |
127 OstTrace0( camerax_performance, CXUIPRECAPTUREVIEW_CONSTRUCT, "msg: e_CX_PRECAPVIEW_CONST 1" ); |
118 OstTrace0( camerax_performance, CXUIPRECAPTUREVIEW_CONSTRUCT, "msg: e_CX_PRECAPVIEW_CONST 1" ); |
128 |
119 |
129 CX_ASSERT_ALWAYS(mainWindow); |
120 CxuiView::construct(mainWindow, engine, documentLoader, keyHandler); |
130 CX_ASSERT_ALWAYS(engine); |
|
131 CX_ASSERT_ALWAYS(documentLoader); |
|
132 |
|
133 mMainWindow = mainWindow; |
|
134 mEngine = engine; |
|
135 mDocumentLoader = documentLoader; |
|
136 mKeyHandler = keyHandler; |
|
137 |
121 |
138 mSettingsInfo = new CxuiSettingsInfo(engine); |
122 mSettingsInfo = new CxuiSettingsInfo(engine); |
139 CX_DEBUG_ASSERT(mSettingsInfo); |
123 CX_DEBUG_ASSERT(mSettingsInfo); |
140 |
124 |
141 setContentFullScreen(true); |
125 setContentFullScreen(true); |
238 |
222 |
239 CX_DEBUG_EXIT_FUNCTION(); |
223 CX_DEBUG_EXIT_FUNCTION(); |
240 } |
224 } |
241 |
225 |
242 // --------------------------------------------------------------------------- |
226 // --------------------------------------------------------------------------- |
243 // CxuiPrecaptureView::hideControls |
|
244 // |
|
245 // --------------------------------------------------------------------------- |
|
246 // |
|
247 void CxuiPrecaptureView::hideControls() |
|
248 { |
|
249 CX_DEBUG_ENTER_FUNCTION(); |
|
250 |
|
251 hideItems(Hb::AllItems); |
|
252 hideZoom(); |
|
253 mControlsVisible = false; |
|
254 if (mHideControlsTimeout.isActive()) { |
|
255 mHideControlsTimeout.stop(); |
|
256 } |
|
257 hideToolbar(); |
|
258 |
|
259 // show indicators when controls are hidden |
|
260 showIndicators(); |
|
261 |
|
262 // give the keyboard focus back to the view |
|
263 // for the view to receive key events |
|
264 setFocus(); |
|
265 |
|
266 CX_DEBUG_EXIT_FUNCTION(); |
|
267 } |
|
268 |
|
269 // --------------------------------------------------------------------------- |
|
270 // CxuiPrecaptureView::hideToolbar |
|
271 // |
|
272 // --------------------------------------------------------------------------- |
|
273 // |
|
274 void CxuiPrecaptureView::hideToolbar() |
|
275 { |
|
276 CX_DEBUG_ENTER_FUNCTION(); |
|
277 if (mToolBar) { |
|
278 mToolBar->hide(); |
|
279 } |
|
280 CX_DEBUG_EXIT_FUNCTION(); |
|
281 } |
|
282 |
|
283 // --------------------------------------------------------------------------- |
|
284 // CxuiPrecaptureView::hideZoom |
|
285 // |
|
286 // --------------------------------------------------------------------------- |
|
287 // |
|
288 void CxuiPrecaptureView::hideZoom() |
|
289 { |
|
290 if (mSlider) { |
|
291 mSlider->hide(); |
|
292 } |
|
293 mZoomVisible = false; |
|
294 } |
|
295 |
|
296 // --------------------------------------------------------------------------- |
|
297 // CxuiPrecaptureView::showZoom |
|
298 // |
|
299 // --------------------------------------------------------------------------- |
|
300 // |
|
301 void CxuiPrecaptureView::showZoom() |
|
302 { |
|
303 CX_DEBUG_ENTER_FUNCTION(); |
|
304 if (mSlider) { |
|
305 |
|
306 // if maxVal has not been set yet, ask for new parameters from engine |
|
307 if (mSlider->maximum() <= 0) { |
|
308 |
|
309 // get the zoom range |
|
310 int min = mEngine->zoomControl().min(); |
|
311 int max = mEngine->zoomControl().max(); |
|
312 |
|
313 // only change values if they are acceptable and have changed |
|
314 if ((max - min > 0) && ((mSlider->maximum() != max) || (mSlider->minimum() != min))) { |
|
315 mSlider->setRange(min, max); |
|
316 } |
|
317 } |
|
318 |
|
319 // show zoom only if the slider has acceptable value |
|
320 if (mSlider->maximum() > 0) { |
|
321 mSlider->show(); |
|
322 } |
|
323 } |
|
324 |
|
325 mZoomVisible = true; |
|
326 CX_DEBUG_EXIT_FUNCTION(); |
|
327 } |
|
328 |
|
329 // --------------------------------------------------------------------------- |
|
330 // CxuiPrecaptureView::toggleZoom |
227 // CxuiPrecaptureView::toggleZoom |
331 // |
228 // |
332 // --------------------------------------------------------------------------- |
229 // --------------------------------------------------------------------------- |
333 // |
230 // |
334 void CxuiPrecaptureView::toggleZoom() |
231 void CxuiPrecaptureView::toggleZoom() |
336 if (mZoomVisible) { |
233 if (mZoomVisible) { |
337 hideZoom(); |
234 hideZoom(); |
338 } else { |
235 } else { |
339 showZoom(); |
236 showZoom(); |
340 } |
237 } |
341 } |
|
342 |
|
343 // --------------------------------------------------------------------------- |
|
344 // CxuiPrecaptureView::hideIndicators |
|
345 // |
|
346 // --------------------------------------------------------------------------- |
|
347 // |
|
348 void CxuiPrecaptureView::hideIndicators() |
|
349 { |
|
350 if (mIndicators) { |
|
351 mIndicators->hide(); |
|
352 } |
|
353 } |
|
354 |
|
355 // --------------------------------------------------------------------------- |
|
356 // CxuiPrecaptureView::showIndicators |
|
357 // |
|
358 // --------------------------------------------------------------------------- |
|
359 // |
|
360 void CxuiPrecaptureView::showIndicators() |
|
361 { |
|
362 if (mIndicators) { |
|
363 mIndicators->show(); |
|
364 } |
|
365 } |
|
366 |
|
367 // --------------------------------------------------------------------------- |
|
368 // CxuiPrecaptureView::showControls |
|
369 // |
|
370 // --------------------------------------------------------------------------- |
|
371 // |
|
372 void CxuiPrecaptureView::showControls() |
|
373 { |
|
374 if (mEngine) { |
|
375 bool videoCases = (mEngine->videoCaptureControl().state() == CxeVideoCaptureControl::Recording || |
|
376 mEngine->videoCaptureControl().state() == CxeVideoCaptureControl::Paused); |
|
377 |
|
378 if (mEngine->isEngineReady() || videoCases) { |
|
379 // show toolbar |
|
380 showToolbar(); |
|
381 // show zoom |
|
382 showZoom(); |
|
383 // show titlepane |
|
384 showItems(Hb::AllItems); |
|
385 |
|
386 // hide indicators when controls are shown |
|
387 hideIndicators(); |
|
388 |
|
389 mHideControlsTimeout.start(); |
|
390 mControlsVisible = true; |
|
391 } |
|
392 } |
|
393 } |
|
394 |
|
395 // --------------------------------------------------------------------------- |
|
396 // CxuiPrecaptureView::showToolbar |
|
397 // shows toolbar |
|
398 // --------------------------------------------------------------------------- |
|
399 // |
|
400 void CxuiPrecaptureView::showToolbar() |
|
401 { |
|
402 |
|
403 CX_DEBUG_ENTER_FUNCTION(); |
|
404 |
|
405 // toolbar pointer is missing if widgets for the view have not been loaded |
|
406 // from the DocML |
|
407 if (mToolBar) { |
|
408 mToolBar->show(); |
|
409 } |
|
410 |
|
411 CX_DEBUG_EXIT_FUNCTION(); |
|
412 } |
238 } |
413 |
239 |
414 |
240 |
415 /* |
241 /* |
416 * Event filter which filters tool bar mouse events and |
242 * Event filter which filters tool bar mouse events and |
577 { |
399 { |
578 CX_DEBUG_ENTER_FUNCTION(); |
400 CX_DEBUG_ENTER_FUNCTION(); |
579 if (mHideControlsTimeout.isActive()) { |
401 if (mHideControlsTimeout.isActive()) { |
580 mHideControlsTimeout.stop(); |
402 mHideControlsTimeout.stop(); |
581 } |
403 } |
582 CX_DEBUG_EXIT_FUNCTION(); |
|
583 } |
|
584 |
|
585 // --------------------------------------------------------------------------- |
|
586 // CxuiPrecaptureView::releaseCamera |
|
587 // --------------------------------------------------------------------------- |
|
588 void CxuiPrecaptureView::releaseCamera() |
|
589 { |
|
590 CX_DEBUG_ENTER_FUNCTION(); |
|
591 mEngine->cameraDeviceControl().release(); |
|
592 CX_DEBUG_EXIT_FUNCTION(); |
404 CX_DEBUG_EXIT_FUNCTION(); |
593 } |
405 } |
594 |
406 |
595 |
407 |
596 // --------------------------------------------------------------------------- |
408 // --------------------------------------------------------------------------- |
687 mSettingsDialog->setStarterAction(NULL); |
499 mSettingsDialog->setStarterAction(NULL); |
688 } |
500 } |
689 if (mSliderSettingsDialog) { |
501 if (mSliderSettingsDialog) { |
690 mSliderSettingsDialog->setStarterAction(NULL); |
502 mSliderSettingsDialog->setStarterAction(NULL); |
691 } |
503 } |
|
504 |
|
505 // Dialog will be deleted automatically when closed |
|
506 // The pointers may become invalid at any time |
|
507 mSettingsDialog = NULL; |
|
508 mSettingsDialogList = NULL; |
|
509 mSettingsDialogHeading = NULL; |
|
510 |
|
511 mSliderSettingsDialog = NULL; |
|
512 mSliderSettingsDialogHeading = NULL; |
|
513 mSettingsSlider = NULL; |
692 } |
514 } |
693 |
515 |
694 |
516 |
695 |
517 |
696 /*! |
518 /*! |
794 connect(mSettingsDialog, SIGNAL(aboutToClose()), mSettingsDialogList, SLOT(handleClose())); |
616 connect(mSettingsDialog, SIGNAL(aboutToClose()), mSettingsDialogList, SLOT(handleClose())); |
795 } |
617 } |
796 |
618 |
797 // Adjust position and show the dialog. |
619 // Adjust position and show the dialog. |
798 mSettingsDialog->setPreferredPos(getDialogPosition(), HbPopup::BottomRightCorner); |
620 mSettingsDialog->setPreferredPos(getDialogPosition(), HbPopup::BottomRightCorner); |
|
621 mSettingsDialog->setAttribute(Qt::WA_DeleteOnClose, true); |
799 mSettingsDialog->show(); |
622 mSettingsDialog->show(); |
|
623 |
800 } |
624 } |
801 } else { |
625 } else { |
802 launchNotSupportedNotification(); |
626 launchNotSupportedNotification(); |
803 } |
627 } |
804 |
628 |
905 } |
729 } |
906 |
730 |
907 // Adjust position and show the dialog. |
731 // Adjust position and show the dialog. |
908 mSliderSettingsDialog->setFrameType(HbPopup::Weak); |
732 mSliderSettingsDialog->setFrameType(HbPopup::Weak); |
909 mSliderSettingsDialog->setPreferredPos(getDialogPosition(), HbPopup::BottomRightCorner); |
733 mSliderSettingsDialog->setPreferredPos(getDialogPosition(), HbPopup::BottomRightCorner); |
|
734 mSliderSettingsDialog->setAttribute(Qt::WA_DeleteOnClose, true); |
910 mSliderSettingsDialog->show(); |
735 mSliderSettingsDialog->show(); |
|
736 |
911 } |
737 } |
912 } else { |
738 } else { |
913 launchNotSupportedNotification(); |
739 launchNotSupportedNotification(); |
914 } |
740 } |
915 |
741 |
916 CX_DEBUG_EXIT_FUNCTION(); |
|
917 } |
|
918 |
|
919 void CxuiPrecaptureView::launchPhotosApp() |
|
920 { |
|
921 QProcess::startDetached(PhotosAppExe); |
|
922 } |
|
923 |
|
924 /*! |
|
925 * Launching Videos application as a separate process |
|
926 */ |
|
927 void CxuiPrecaptureView::launchVideosApp() |
|
928 { |
|
929 //Releasing cameda device in order to free |
|
930 //graphical memory |
|
931 releaseCamera(); |
|
932 QProcess::startDetached(VideosAppExe); |
|
933 } |
|
934 |
|
935 /*! |
|
936 * Show "not supported" notification. |
|
937 */ |
|
938 void CxuiPrecaptureView::launchNotSupportedNotification() |
|
939 { |
|
940 CX_DEBUG_ENTER_FUNCTION(); |
|
941 HbNotificationDialog::launchDialog("Notification", "Not supported yet"); |
|
942 CX_DEBUG_EXIT_FUNCTION(); |
742 CX_DEBUG_EXIT_FUNCTION(); |
943 } |
743 } |
944 |
744 |
945 /*! |
745 /*! |
946 * Show "Disk full" notification. |
746 * Show "Disk full" notification. |
1013 CX_DEBUG_EXIT_FUNCTION(); |
813 CX_DEBUG_EXIT_FUNCTION(); |
1014 return showPostcapture != 0; // 0 == no postcapture |
814 return showPostcapture != 0; // 0 == no postcapture |
1015 } |
815 } |
1016 |
816 |
1017 /*! |
817 /*! |
1018 * Adding zoom buttons to the slider |
|
1019 * \param slider Pointer to the slider object, where the buttons will be added |
|
1020 */ |
|
1021 void CxuiPrecaptureView::addIncreaseDecreaseButtons(CxuiZoomSlider *slider) |
|
1022 { |
|
1023 // get current slider elements |
|
1024 QList<QVariant> elements = slider->sliderElements(); |
|
1025 |
|
1026 // add increase and decrease elements to the slider |
|
1027 elements << HbSlider::IncreaseElement << HbSlider::DecreaseElement; |
|
1028 slider->setSliderElements(elements); |
|
1029 |
|
1030 // set icons for the increase and decrease element |
|
1031 slider->setElementIcon(HbSlider::DecreaseElement , HbIcon("qtg_mono_minus")); |
|
1032 slider->setElementIcon(HbSlider::IncreaseElement , HbIcon("qtg_mono_plus")); |
|
1033 } |
|
1034 |
|
1035 |
|
1036 /*! |
|
1037 * Function can be used to create a graphics item and setting it as a background |
|
1038 * item for HbWidget. graphicName refers to system wide graphic name. Given graphic |
|
1039 * can consist of one, three or nine pieces. Nine piece graphics are used by default. |
|
1040 * See HbFrameDrawer documentation for graphic naming. |
|
1041 */ |
|
1042 void CxuiPrecaptureView::createWidgetBackgroundGraphic(HbWidget *widget, |
|
1043 const QString &graphicName, |
|
1044 HbFrameDrawer::FrameType frameType) |
|
1045 { |
|
1046 if (widget) { |
|
1047 HbFrameDrawer *drawer = new HbFrameDrawer(graphicName, frameType); |
|
1048 |
|
1049 if (drawer) { |
|
1050 HbFrameItem *backgroundItem = new HbFrameItem(drawer, widget); |
|
1051 if (backgroundItem) { |
|
1052 // set item to fill the whole widget |
|
1053 backgroundItem->setGeometry(QRectF(QPointF(0, 0), widget->size())); |
|
1054 backgroundItem->setZValue(0); |
|
1055 widget->setBackgroundItem(backgroundItem); |
|
1056 } |
|
1057 } |
|
1058 } |
|
1059 } |
|
1060 |
|
1061 /*! |
|
1062 * Returns dialogs bottom right corner |
818 * Returns dialogs bottom right corner |
1063 */ |
819 */ |
1064 QPointF CxuiPrecaptureView::getDialogPosition() |
820 QPointF CxuiPrecaptureView::getDialogPosition() |
1065 { |
821 { |
1066 HbStyle *style = new HbStyle(); |
822 HbStyle *style = new HbStyle(); |