Kinetic scroll zoom.
svn path=/trunk/KDE/kdelibs/; revision=1094768
This commit is contained in:
parent
dc3e921b36
commit
bb79950031
@ -32,7 +32,6 @@ using namespace Plasma;
|
||||
AnimableGraphicsWebView::AnimableGraphicsWebView(QGraphicsItem * parent)
|
||||
: KGraphicsWebView(parent)
|
||||
{
|
||||
grabGesture(Qt::PinchGesture);
|
||||
m_dragToScroll = false;
|
||||
}
|
||||
|
||||
@ -73,6 +72,16 @@ QPointF AnimableGraphicsWebView::scrollPosition() const
|
||||
}
|
||||
}
|
||||
|
||||
qreal AnimableGraphicsWebView::zoom() const
|
||||
{
|
||||
return KGraphicsWebView::zoomFactor();
|
||||
}
|
||||
|
||||
void AnimableGraphicsWebView::setZoom(const qreal zoom)
|
||||
{
|
||||
KGraphicsWebView::setZoomFactor(zoom);
|
||||
}
|
||||
|
||||
QRectF AnimableGraphicsWebView::viewportGeometry() const
|
||||
{
|
||||
QRectF result;
|
||||
@ -155,23 +164,5 @@ 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);
|
||||
}
|
||||
|
||||
void 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"
|
||||
|
||||
|
@ -29,8 +29,6 @@
|
||||
|
||||
#include <kgraphicswebview.h>
|
||||
|
||||
class QGestureEvent;
|
||||
|
||||
namespace Plasma
|
||||
{
|
||||
|
||||
@ -38,6 +36,7 @@ class AnimableGraphicsWebView : public KGraphicsWebView
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(qreal zoomFactor READ zoom WRITE setZoom)
|
||||
Q_PROPERTY(QPointF scrollPosition READ scrollPosition WRITE setScrollPosition)
|
||||
Q_PROPERTY(QSizeF contentsSize READ contentsSize)
|
||||
Q_PROPERTY(QRectF viewportGeometry READ viewportGeometry)
|
||||
@ -51,16 +50,16 @@ public:
|
||||
QRectF viewportGeometry() const;
|
||||
void setDragToScroll(bool enable);
|
||||
bool dragToScroll() const;
|
||||
qreal zoom() const;
|
||||
void setZoom(const qreal zoom);
|
||||
|
||||
protected:
|
||||
bool event(QEvent * event);
|
||||
void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
|
||||
void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
||||
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
|
||||
void wheelEvent(QGraphicsSceneWheelEvent *event);
|
||||
|
||||
private:
|
||||
void gestureEvent(QGestureEvent *event);
|
||||
bool m_dragToScroll;
|
||||
QPointF m_lastScrollPosition;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user