Added support to pinch multitouch gesture.

svn path=/trunk/KDE/kdelibs/; revision=1094411
This commit is contained in:
Davide Bettio 2010-02-22 18:14:59 +00:00
parent acc4b9ce1f
commit ae50fe2e25
2 changed files with 24 additions and 0 deletions

View File

@ -21,6 +21,8 @@
#include "animablegraphicswebview_p.h"
#include <QtGui/QApplication>
#include <QGestureEvent>
#include <QPinchGesture>
#include <QtWebKit/QWebFrame>
#include <kwebpage.h>
@ -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<QGestureEvent*>(event));
return true;
}
return KGraphicsWebView::event(event);
}
bool AnimableGraphicsWebView::gestureEvent(QGestureEvent *event)
{
if (QGesture *pinch = event->gesture(Qt::PinchGesture)){
QPinchGesture *pinchGesture = static_cast<QPinchGesture *>(pinch);
setZoomFactor(zoomFactor() * pinchGesture->scaleFactor());
}
}
#include "animablegraphicswebview_p.moc"

View File

@ -29,6 +29,8 @@
#include <kgraphicswebview.h>
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;
};