30 #include <hbtoolbar.h> |
30 #include <hbtoolbar.h> |
31 #include <hbaction.h> |
31 #include <hbaction.h> |
32 #include <hbmessagebox.h> |
32 #include <hbmessagebox.h> |
33 #include <hbnotificationdialog.h> |
33 #include <hbnotificationdialog.h> |
34 |
34 |
35 #include <shareuidialog.h> |
35 #include <shareui.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" |
134 mImageLabel = qobject_cast<HbLabel *>(widget); |
134 mImageLabel = qobject_cast<HbLabel *>(widget); |
135 CX_DEBUG_ASSERT(mImageLabel); |
135 CX_DEBUG_ASSERT(mImageLabel); |
136 |
136 |
137 // get toolbar pointers from the documentloader |
137 // get toolbar pointers from the documentloader |
138 widget = mDocumentLoader->findWidget(STILL_POST_CAPTURE_TOOLBAR); |
138 widget = mDocumentLoader->findWidget(STILL_POST_CAPTURE_TOOLBAR); |
|
139 // This resize is a workaround to get toolbar shown correctly. |
|
140 widget->resize(60, 300); |
139 mStillToolbar = qobject_cast<HbToolBar *> (widget); |
141 mStillToolbar = qobject_cast<HbToolBar *> (widget); |
140 CX_DEBUG_ASSERT(mStillToolbar); |
142 CX_DEBUG_ASSERT(mStillToolbar); |
141 |
143 |
142 widget = mDocumentLoader->findWidget(VIDEO_POST_CAPTURE_TOOLBAR); |
144 widget = mDocumentLoader->findWidget(VIDEO_POST_CAPTURE_TOOLBAR); |
|
145 // This resize is a workaround to get toolbar shown correctly. |
|
146 widget->resize(60, 300); |
143 mVideoToolbar = qobject_cast<HbToolBar *> (widget); |
147 mVideoToolbar = qobject_cast<HbToolBar *> (widget); |
144 CX_DEBUG_ASSERT(mVideoToolbar); |
148 CX_DEBUG_ASSERT(mVideoToolbar); |
145 |
149 |
146 widget = mDocumentLoader->findWidget(EMBEDDED_POST_CAPTURE_TOOLBAR); |
150 widget = mDocumentLoader->findWidget(EMBEDDED_POST_CAPTURE_TOOLBAR); |
|
151 // This resize is a workaround to get toolbar shown correctly. |
|
152 widget->resize(60, 300); |
147 mEmbeddedToolbar = qobject_cast<HbToolBar *> (widget); |
153 mEmbeddedToolbar = qobject_cast<HbToolBar *> (widget); |
148 CX_DEBUG_ASSERT(mEmbeddedToolbar); |
154 CX_DEBUG_ASSERT(mEmbeddedToolbar); |
149 |
155 |
150 mStopViewfinderTimer.setSingleShot(true); |
156 mStopViewfinderTimer.setSingleShot(true); |
151 connect(&mStopViewfinderTimer, SIGNAL(timeout()), |
157 connect(&mStopViewfinderTimer, SIGNAL(timeout()), |
202 /*! |
208 /*! |
203 Slot for starting video playing. |
209 Slot for starting video playing. |
204 */ |
210 */ |
205 void CxuiPostcaptureView::playVideo() |
211 void CxuiPostcaptureView::playVideo() |
206 { |
212 { |
|
213 |
207 launchNotSupportedNotification(); |
214 launchNotSupportedNotification(); |
208 //! @todo needs an implementation |
215 //! @todo needs an implementation |
209 CX_DEBUG_IN_FUNCTION(); |
216 CX_DEBUG_IN_FUNCTION(); |
|
217 |
210 } |
218 } |
211 |
219 |
212 // --------------------------------------------------------------------------- |
220 // --------------------------------------------------------------------------- |
213 // CxuiPostcaptureView::showDeleteNote |
221 // CxuiPostcaptureView::showDeleteNote |
214 // |
222 // |
216 // |
224 // |
217 void CxuiPostcaptureView::showDeleteNote() |
225 void CxuiPostcaptureView::showDeleteNote() |
218 { |
226 { |
219 CX_DEBUG_ENTER_FUNCTION(); |
227 CX_DEBUG_ENTER_FUNCTION(); |
220 |
228 |
221 QString filename = getCurrentFilename(); |
|
222 bool ret = false; |
|
223 |
|
224 hideControls(); |
229 hideControls(); |
225 |
230 |
226 if (mEngine->mode() == Cxe::VideoMode) { |
231 if (mEngine->mode() == Cxe::VideoMode) { |
227 ret = HbMessageBox::question(hbTrId("txt_cam_other_delete_video_clip")); |
232 HbMessageBox::question(hbTrId("txt_cam_other_delete_video_clip"), |
|
233 this, |
|
234 SLOT(handleDeleteDialogClosed(HbAction*))); |
228 } else { |
235 } else { |
229 ret = HbMessageBox::question(hbTrId("txt_cam_other_delete_image")); |
236 HbMessageBox::question(hbTrId("txt_cam_other_delete_image"), |
230 } |
237 this, |
231 |
238 SLOT(handleDeleteDialogClosed(HbAction*))); |
232 if (ret) { |
239 } |
|
240 |
|
241 CX_DEBUG_EXIT_FUNCTION(); |
|
242 } |
|
243 |
|
244 // --------------------------------------------------------------------------- |
|
245 // CxuiPostcaptureView::handleDeleteDialogClosed |
|
246 // |
|
247 // --------------------------------------------------------------------------- |
|
248 // |
|
249 void CxuiPostcaptureView::handleDeleteDialogClosed(HbAction *action) |
|
250 { |
|
251 CX_DEBUG_ENTER_FUNCTION(); |
|
252 |
|
253 hideControls(); |
|
254 |
|
255 HbMessageBox *dlg = qobject_cast<HbMessageBox*>(sender()); |
|
256 |
|
257 // check that it was "primary action" that closed the dialog |
|
258 if (dlg && dlg->actions().at(0) == action) { |
|
259 // User confirmed delete |
|
260 QString filename = getCurrentFilename(); |
233 QFileInfo fileInfo(filename); |
261 QFileInfo fileInfo(filename); |
234 if (fileInfo.exists()) { |
262 if (fileInfo.exists()) { |
235 //! @todo |
263 //! @todo |
236 // We can retry deletion if file deletion does'nt succeed, |
264 // We can retry deletion if file deletion does'nt succeed, |
237 // but this is left out for the time being since the user |
265 // but this is left out for the time being since the user |
244 // Go back to precapture view |
272 // Go back to precapture view |
245 goToPrecaptureView(); |
273 goToPrecaptureView(); |
246 } |
274 } |
247 } |
275 } |
248 |
276 |
249 CX_DEBUG_EXIT_FUNCTION(); |
277 CX_DEBUG_EXIT_FUNCTION(); |
250 } |
278 } |
251 |
|
252 |
279 |
253 |
280 |
254 /*! |
281 /*! |
255 Slot for handling image/video sharing. |
282 Slot for handling image/video sharing. |
256 */ |
283 */ |
257 void CxuiPostcaptureView::launchShare() |
284 void CxuiPostcaptureView::launchShare() |
258 { |
285 { |
259 CX_DEBUG_ENTER_FUNCTION(); |
286 CX_DEBUG_ENTER_FUNCTION(); |
260 |
287 |
261 stopTimers(); |
288 stopTimers(); |
262 stopViewfinder(); |
|
263 releaseCamera(); |
289 releaseCamera(); |
264 |
290 |
265 QString filename = getCurrentFilename(); |
291 QString filename = getCurrentFilename(); |
266 |
292 |
267 QVariantList filelist; |
293 QStringList filelist; |
268 filelist.append(QVariant(filename)); |
294 filelist.append(filename); |
269 |
295 |
270 ShareUi dialog; |
296 ShareUi dialog; |
271 dialog.init(filelist, true); |
297 dialog.send(filelist, true); |
272 |
298 |
273 showControls(); |
299 showControls(); |
274 |
300 |
275 CX_DEBUG_EXIT_FUNCTION(); |
301 CX_DEBUG_EXIT_FUNCTION(); |
276 } |
302 } |
277 |
303 |
278 // --------------------------------------------------------------------------- |
304 // --------------------------------------------------------------------------- |
279 // CxuiPostcaptureView::goToPrecaptureView |
305 // CxuiPostcaptureView::goToPrecaptureView |
282 // |
308 // |
283 void CxuiPostcaptureView::goToPrecaptureView() |
309 void CxuiPostcaptureView::goToPrecaptureView() |
284 { |
310 { |
285 CX_DEBUG_ENTER_FUNCTION(); |
311 CX_DEBUG_ENTER_FUNCTION(); |
286 |
312 |
287 // Cannot return to post-capture while stopping in video mode |
313 // Cannot return to pre-capture while stopping in video mode |
288 if (mEngine->mode() != Cxe::VideoMode || |
314 if (mEngine->mode() != Cxe::VideoMode || |
289 mEngine->videoCaptureControl().state() != CxeVideoCaptureControl::Stopping) { |
315 mEngine->videoCaptureControl().state() != CxeVideoCaptureControl::Stopping) { |
290 stopTimers(); |
316 stopTimers(); |
|
317 // Re-enabling starting timers the next time we enter post capture view. |
|
318 mTimersStarted = false; |
|
319 |
291 // Make sure engine prepares for new image/video if necessary |
320 // Make sure engine prepares for new image/video if necessary |
292 mEngine->initMode(mEngine->mode()); |
321 mEngine->initMode(mEngine->mode()); |
293 |
|
294 // enables starting of timers in postcaptureview |
|
295 mTimersStarted = false; |
|
296 |
322 |
297 // Switch to pre-capture view |
323 // Switch to pre-capture view |
298 emit changeToPrecaptureView(); |
324 emit changeToPrecaptureView(); |
299 } |
325 } |
300 |
326 |
412 // --------------------------------------------------------------------------- |
438 // --------------------------------------------------------------------------- |
413 // |
439 // |
414 bool CxuiPostcaptureView::eventFilter(QObject *object, QEvent *event) |
440 bool CxuiPostcaptureView::eventFilter(QObject *object, QEvent *event) |
415 { |
441 { |
416 Q_UNUSED(object) |
442 Q_UNUSED(object) |
417 |
|
418 bool eventWasConsumed = false; |
443 bool eventWasConsumed = false; |
419 |
444 |
420 switch (event->type()) |
445 switch (event->type()) |
421 { |
446 { |
422 case QEvent::GraphicsSceneMouseRelease: |
447 case QEvent::GraphicsSceneMouseRelease: |
433 |
458 |
434 return eventWasConsumed; |
459 return eventWasConsumed; |
435 } |
460 } |
436 |
461 |
437 /*! |
462 /*! |
438 * Paint event. |
463 * Paint method. |
439 * Used for performance tracing (snapshot latency). |
464 * Used for performance tracing purposes. |
440 */ |
465 */ |
441 bool CxuiPostcaptureView::event(QEvent *event) |
466 void CxuiPostcaptureView::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) |
442 { |
467 { |
443 bool processed(HbView::event(event)); |
|
444 if (event && event->type() == QEvent::Paint) { |
|
445 OstTrace0(camerax_performance, CXUIPOSTCAPTUREVIEW_SNAPSHOT_DRAW, "msg: e_CX_SHOT_TO_SNAPSHOT 0"); |
468 OstTrace0(camerax_performance, CXUIPOSTCAPTUREVIEW_SNAPSHOT_DRAW, "msg: e_CX_SHOT_TO_SNAPSHOT 0"); |
446 } |
469 QGraphicsWidget::paint(painter, option, widget); |
447 return processed; |
|
448 } |
470 } |
449 |
471 |
450 // --------------------------------------------------------------------------- |
472 // --------------------------------------------------------------------------- |
451 // CxuiPostcaptureView::mousePressEvent |
473 // CxuiPostcaptureView::mousePressEvent |
452 // |
474 // |
453 // --------------------------------------------------------------------------- |
475 // --------------------------------------------------------------------------- |
454 // |
476 // |
455 void CxuiPostcaptureView::mousePressEvent(QGraphicsSceneMouseEvent *event) |
477 void CxuiPostcaptureView::mousePressEvent(QGraphicsSceneMouseEvent *event) |
456 { |
478 { |
457 |
479 //! @todo temporary workaround for title bar mouse event handling bug |
458 if (event->type() == QEvent::GraphicsSceneMousePress) { |
480 if (event->type() == QEvent::GraphicsSceneMousePress && event->scenePos().y() > 70) { |
459 mPostcaptureTimer.stop(); |
481 mPostcaptureTimer.stop(); |
460 toggleControls(); |
482 toggleControls(); |
461 event->accept(); |
483 event->accept(); |
462 } |
484 } |
463 |
485 |
498 QGraphicsWidget::hideEvent(event); |
520 QGraphicsWidget::hideEvent(event); |
499 |
521 |
500 if (event->type() == QEvent::Hide) { |
522 if (event->type() == QEvent::Hide) { |
501 // remove event filter to disable unnecessary actions |
523 // remove event filter to disable unnecessary actions |
502 QCoreApplication::instance()->removeEventFilter(this); |
524 QCoreApplication::instance()->removeEventFilter(this); |
|
525 |
|
526 // Clear the snapshot. |
|
527 mImageLabel->setIcon(HbIcon()); |
503 |
528 |
504 stopTimers(); |
529 stopTimers(); |
505 // Hide controls to make sure title bar reacts to show() |
530 // Hide controls to make sure title bar reacts to show() |
506 // when this view is reactivated. |
531 // when this view is reactivated. |
507 hideControls(); |
532 hideControls(); |
588 Launches "Not supported yet" notification. |
613 Launches "Not supported yet" notification. |
589 */ |
614 */ |
590 void CxuiPostcaptureView::launchNotSupportedNotification() |
615 void CxuiPostcaptureView::launchNotSupportedNotification() |
591 { |
616 { |
592 CX_DEBUG_ENTER_FUNCTION(); |
617 CX_DEBUG_ENTER_FUNCTION(); |
593 |
618 HbNotificationDialog::launchDialog("Notification", "Not supported yet"); |
594 // Instantiate a popup |
|
595 HbNotificationDialog note; |
|
596 note.setTitle("Notification"); |
|
597 note.setText("Not supported yet"); |
|
598 note.exec(); |
|
599 |
|
600 CX_DEBUG_EXIT_FUNCTION(); |
619 CX_DEBUG_EXIT_FUNCTION(); |
601 } |
620 } |
602 |
621 |
603 /* ! |
622 /* ! |
604 * gets the filename of the current file |
623 * gets the filename of the current file |
725 mHideControlsTimeout.stop(); |
744 mHideControlsTimeout.stop(); |
726 mReleaseCameraTimer.stop(); |
745 mReleaseCameraTimer.stop(); |
727 mPostcaptureTimer.stop(); |
746 mPostcaptureTimer.stop(); |
728 mStopViewfinderTimer.stop(); |
747 mStopViewfinderTimer.stop(); |
729 |
748 |
730 mTimersStarted = false; |
749 // Note: mTimersStarted is intentionally not reset here. |
|
750 // Once the timers are stopped, they are not to be started again until |
|
751 // we come from precapture view again. |
|
752 // E.g. returning from background could otherwise restart the timers and |
|
753 // if post-capture timer would be on, user could be confused: camera |
|
754 // shows up with post-capture view, after couple seconds it disappears |
|
755 // and we return to pre-capture view. That's not what we want. |
731 |
756 |
732 CX_DEBUG_EXIT_FUNCTION(); |
757 CX_DEBUG_EXIT_FUNCTION(); |
733 } |
758 } |
734 |
759 |
735 // end of file |
760 // end of file |