diff --git a/private/animablegraphicswebview.cpp b/private/animablegraphicswebview.cpp index 5f1aafbda..a1cded468 100644 --- a/private/animablegraphicswebview.cpp +++ b/private/animablegraphicswebview.cpp @@ -21,6 +21,8 @@ #include "animablegraphicswebview_p.h" #include +#include +#include #include #include @@ -152,5 +154,23 @@ void AnimableGraphicsWebView::wheelEvent(QGraphicsSceneWheelEvent *event) event->setAccepted(!m_dragToScroll); } +bool AnimableGraphicsWebView::event(QEvent * event) +{ + if (event->type() == QEvent::Gesture) { + gestureEvent(static_cast(event)); + return true; + } + + return KGraphicsWebView::event(event); +} + +bool AnimableGraphicsWebView::gestureEvent(QGestureEvent *event) +{ + if (QGesture *pinch = event->gesture(Qt::PinchGesture)){ + QPinchGesture *pinchGesture = static_cast(pinch); + setZoomFactor(zoomFactor() * pinchGesture->scaleFactor()); + } +} + #include "animablegraphicswebview_p.moc" diff --git a/private/animablegraphicswebview_p.h b/private/animablegraphicswebview_p.h index f585b64c8..2e323ac85 100644 --- a/private/animablegraphicswebview_p.h +++ b/private/animablegraphicswebview_p.h @@ -29,6 +29,8 @@ #include +class QGestureEvent; + namespace Plasma { @@ -51,12 +53,14 @@ public: bool dragToScroll() const; protected: + bool event(QEvent * event); void mouseMoveEvent(QGraphicsSceneMouseEvent *event); void mousePressEvent(QGraphicsSceneMouseEvent *event); void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); void wheelEvent(QGraphicsSceneWheelEvent *event); private: + bool gestureEvent(QGestureEvent *event); bool m_dragToScroll; QPointF m_lastScrollPosition; };