26 #include <QGraphicsSceneMouseEvent> |
26 #include <QGraphicsSceneMouseEvent> |
27 #include <QTimer> |
27 #include <QTimer> |
28 #include <QGraphicsScene> |
28 #include <QGraphicsScene> |
29 #include <QCoreApplication> |
29 #include <QCoreApplication> |
30 #include <QtGlobal> |
30 #include <QtGlobal> |
|
31 #include <QGesture> |
|
32 #include <QGestureEvent> |
|
33 |
31 #include <hbnotificationdialog.h> |
34 #include <hbnotificationdialog.h> |
32 #include <hbnotificationdialog_p.h> |
35 #include <hbnotificationdialog_p.h> |
33 #include <hblabel.h> |
36 #include <hblabel.h> |
34 #include <hbmainwindow.h> |
37 #include <hbmainwindow.h> |
35 #include <hbwidgetsequentialshow_p.h> |
38 #include <hbwidgetsequentialshow_p.h> |
36 #include <hbdevicedialogserverstatus_p.h> |
39 #include <hbdevicedialogserverstatus_p.h> |
|
40 #include <hbtapgesture.h> |
|
41 #include <hbpangesture.h> |
37 |
42 |
38 #ifdef HB_EFFECTS |
43 #ifdef HB_EFFECTS |
39 #include "hbeffectinternal_p.h" |
44 #include "hbeffectinternal_p.h" |
40 #endif |
45 #endif |
41 |
46 |
146 setBackgroundFaded(false); |
151 setBackgroundFaded(false); |
147 setDismissPolicy(HbPopup::NoDismiss); |
152 setDismissPolicy(HbPopup::NoDismiss); |
148 setTimeout(HbPopup::StandardTimeout); |
153 setTimeout(HbPopup::StandardTimeout); |
149 d->setBackgroundStyle(); |
154 d->setBackgroundStyle(); |
150 |
155 |
|
156 grabGesture(Qt::PanGesture); |
|
157 grabGesture(Qt::TapGesture); |
|
158 |
151 #ifdef HB_EFFECTS |
159 #ifdef HB_EFFECTS |
152 HbEffectInternal::add(this, "notificationdialog_appear", "appear"); |
160 HbEffectInternal::add(this, "notificationdialog_appear", "appear"); |
153 HbEffectInternal::add(this, "notificationdialog_disappear", "disappear"); |
161 HbEffectInternal::add(this, "notificationdialog_disappear", "disappear"); |
154 #endif |
162 #endif |
155 } |
163 } |
203 } |
211 } |
204 |
212 |
205 /*! |
213 /*! |
206 Convenience method for using HbNotificationDialog. Shows a notification dialog with |
214 Convenience method for using HbNotificationDialog. Shows a notification dialog with |
207 the given parameters. The dialog is owned by NotificationDialog. |
215 the given parameters. The dialog is owned by NotificationDialog. |
208 \deprecated HbNotificationDialog::launchDialog(const HbIcon &icon, QGraphicsScene* scene) is deprecated. |
216 |
209 Showing only icon is not supported by the layout. Use other launchDialog-methods instead. |
217 \deprecated HbNotificationDialog::launchDialog(const HbIcon&, QGraphicsScene*) |
|
218 is deprecated. Showing only icon is not supported by the layout. Use other launchDialog-methods instead. |
210 */ |
219 */ |
211 void HbNotificationDialog::launchDialog(const HbIcon &icon, QGraphicsScene* scene) |
220 void HbNotificationDialog::launchDialog(const HbIcon &icon, QGraphicsScene* scene) |
212 { |
221 { |
213 HbNotificationDialog *self = new HbNotificationDialog(); |
222 HbNotificationDialog *self = new HbNotificationDialog(); |
214 if (scene) { |
223 if (scene) { |
347 d->content->setIcon( icon ); |
356 d->content->setIcon( icon ); |
348 d->setNotificationDialogContent(); |
357 d->setNotificationDialogContent(); |
349 } |
358 } |
350 |
359 |
351 /*! |
360 /*! |
352 \deprecated HbNotificationDialog::setWrapMode(int mode) |
361 \deprecated HbNotificationDialog::setWrapMode(int) |
353 is deprecated. Please use setTitleTextWrapping(Hb::TextWrapping wrapping) instead. |
362 is deprecated. Please use setTitleTextWrapping(Hb::TextWrapping wrapping) instead. |
354 |
|
355 Deprecated. |
|
356 */ |
363 */ |
357 void HbNotificationDialog::setWrapMode(int mode) |
364 void HbNotificationDialog::setWrapMode(int mode) |
358 { |
365 { |
359 if (mode == NoWrap) { |
366 if (mode == NoWrap) { |
360 setTitleTextWrapping(Hb::TextNoWrap); |
367 setTitleTextWrapping(Hb::TextNoWrap); |
446 HbNotificationDialog::HbNotificationDialog(HbNotificationDialogPrivate &dd, QGraphicsItem *parent) : |
451 HbNotificationDialog::HbNotificationDialog(HbNotificationDialogPrivate &dd, QGraphicsItem *parent) : |
447 HbDialog(dd, parent) |
452 HbDialog(dd, parent) |
448 { |
453 { |
449 } |
454 } |
450 |
455 |
451 /*! |
456 void HbNotificationDialog::gestureEvent(QGestureEvent *event) |
452 \reimp |
457 { |
453 */ |
458 Q_D(HbNotificationDialog); |
454 void HbNotificationDialog::mousePressEvent(QGraphicsSceneMouseEvent *event) |
459 if(HbTapGesture *tap = qobject_cast<HbTapGesture*>(event->gesture(Qt::TapGesture))) { |
455 { |
460 if(tap->state() == Qt::GestureStarted) { |
456 Q_D(HbNotificationDialog); |
461 d->stopTimeout(); |
457 d->pointerDownPoint = event->pos(); |
462 } else if(tap->state() == Qt::GestureFinished) { |
458 // "Pop-up is visible as long as the user holds the finger on top of it." |
463 if (d->isTouchActivating) { |
459 d->stopTimeout(); |
464 emit activated(); |
460 event->accept(); |
465 } |
461 } |
466 close(); |
462 |
|
463 /*! |
|
464 \reimp |
|
465 */ |
|
466 void HbNotificationDialog::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) |
|
467 { |
|
468 Q_D(HbNotificationDialog); |
|
469 // Touch release => Inactive or application specific functionality |
|
470 |
|
471 if (d->isTouchActivating) { |
|
472 QPointF point = event->pos() - d->pointerDownPoint; |
|
473 qreal manhattanLength = qAbs(point.x()) + qAbs(point.y()); |
|
474 if (manhattanLength < 20) |
|
475 { |
|
476 emit activated(); |
|
477 } |
467 } |
478 } |
468 } else if( HbPanGesture *pan = qobject_cast<HbPanGesture*>(event->gesture(Qt::PanGesture))) { |
479 close(); |
469 if(pan->state() == Qt::GestureFinished){ |
|
470 close(); |
|
471 } |
|
472 } |
480 } |
473 } |
481 |
474 |
482 // Widget is about to hide. Closing effect has ended, |
475 // Widget is about to hide. Closing effect has ended, |
483 void HbNotificationDialog::hideEvent(QHideEvent *event) |
476 void HbNotificationDialog::hideEvent(QHideEvent *event) |
484 { |
477 { |