summaryrefslogtreecommitdiffstats
path: root/src/declarative
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2009-12-11 04:22:44 (GMT)
committerMartin Jones <martin.jones@nokia.com>2009-12-11 04:22:44 (GMT)
commit167578b865bf53a88ff699a67bce0f17912807d5 (patch)
treee61f196f0b6ee054dbb6e1da3edf6c4778fad52b /src/declarative
parent950a09098252c0607376170d7909ef33a4f264ab (diff)
downloadQt-167578b865bf53a88ff699a67bce0f17912807d5.zip
Qt-167578b865bf53a88ff699a67bce0f17912807d5.tar.gz
Qt-167578b865bf53a88ff699a67bce0f17912807d5.tar.bz2
Use QApplication::startDragDistance() for dragging threshold.
Diffstat (limited to 'src/declarative')
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsflickable.cpp12
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsmouseregion.cpp8
-rw-r--r--src/declarative/graphicsitems/qmlgraphicspathview.cpp4
3 files changed, 9 insertions, 15 deletions
diff --git a/src/declarative/graphicsitems/qmlgraphicsflickable.cpp b/src/declarative/graphicsitems/qmlgraphicsflickable.cpp
index eebc231..f3f138b 100644
--- a/src/declarative/graphicsitems/qmlgraphicsflickable.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicsflickable.cpp
@@ -49,12 +49,8 @@
QT_BEGIN_NAMESPACE
-// These are highly device dependant.
-// DragThreshold determines how far the "mouse" must move before
-// we begin a drag.
// FlickThreshold determines how far the "mouse" must have moved
// before we perform a flick.
-static const int DragThreshold = 8;
static const int FlickThreshold = 20;
// Really slow flicks can be annoying.
@@ -647,7 +643,7 @@ void QmlGraphicsFlickablePrivate::handleMouseMoveEvent(QGraphicsSceneMouseEvent
if (q->yflick()) {
int dy = int(event->pos().y() - pressPos.y());
- if (qAbs(dy) > DragThreshold || QmlGraphicsItemPrivate::elapsed(pressTime) > 200) {
+ if (qAbs(dy) > QApplication::startDragDistance() || QmlGraphicsItemPrivate::elapsed(pressTime) > 200) {
qreal newY = dy + pressY;
const qreal minY = q->minYExtent();
const qreal maxY = q->maxYExtent();
@@ -667,14 +663,14 @@ void QmlGraphicsFlickablePrivate::handleMouseMoveEvent(QGraphicsSceneMouseEvent
_moveY.setValue(newY);
moved = true;
}
- if (qAbs(dy) > DragThreshold)
+ if (qAbs(dy) > QApplication::startDragDistance())
stealMouse = true;
}
}
if (q->xflick()) {
int dx = int(event->pos().x() - pressPos.x());
- if (qAbs(dx) > DragThreshold || QmlGraphicsItemPrivate::elapsed(pressTime) > 200) {
+ if (qAbs(dx) > QApplication::startDragDistance() || QmlGraphicsItemPrivate::elapsed(pressTime) > 200) {
qreal newX = dx + pressX;
const qreal minX = q->minXExtent();
const qreal maxX = q->maxXExtent();
@@ -695,7 +691,7 @@ void QmlGraphicsFlickablePrivate::handleMouseMoveEvent(QGraphicsSceneMouseEvent
moved = true;
}
- if (qAbs(dx) > DragThreshold)
+ if (qAbs(dx) > QApplication::startDragDistance())
stealMouse = true;
}
}
diff --git a/src/declarative/graphicsitems/qmlgraphicsmouseregion.cpp b/src/declarative/graphicsitems/qmlgraphicsmouseregion.cpp
index f788077..bd21e7a 100644
--- a/src/declarative/graphicsitems/qmlgraphicsmouseregion.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicsmouseregion.cpp
@@ -47,7 +47,6 @@
#include <QGraphicsSceneMouseEvent>
QT_BEGIN_NAMESPACE
-static const qreal DragThreshold = 5;
static const int PressAndHoldDelay = 800;
QML_DEFINE_TYPE(Qt,4,6,Drag,QmlGraphicsDrag)
@@ -396,13 +395,14 @@ void QmlGraphicsMouseRegion::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
curLocalPos = event->scenePos();
}
+ const int dragThreshold = QApplication::startDragDistance();
qreal dx = qAbs(curLocalPos.x() - startLocalPos.x());
qreal dy = qAbs(curLocalPos.y() - startLocalPos.y());
- if ((d->dragX && !(dx < DragThreshold)) || (d->dragY && !(dy < DragThreshold)))
+ if ((d->dragX && !(dx < dragThreshold)) || (d->dragY && !(dy < dragThreshold)))
d->dragged = true;
if (!keepMouseGrab()) {
- if ((!d->dragY && dy < DragThreshold && d->dragX && dx > DragThreshold)
- || (!d->dragX && dx < DragThreshold && d->dragY && dy > DragThreshold)
+ if ((!d->dragY && dy < dragThreshold && d->dragX && dx > dragThreshold)
+ || (!d->dragX && dx < dragThreshold && d->dragY && dy > dragThreshold)
|| (d->dragX && d->dragY)) {
setKeepMouseGrab(true);
}
diff --git a/src/declarative/graphicsitems/qmlgraphicspathview.cpp b/src/declarative/graphicsitems/qmlgraphicspathview.cpp
index 705462a..b9c9e05 100644
--- a/src/declarative/graphicsitems/qmlgraphicspathview.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicspathview.cpp
@@ -52,8 +52,6 @@
#include <math.h>
-static const int FlickThreshold = 5;
-
QT_BEGIN_NAMESPACE
QML_DEFINE_TYPE(Qt,4,6,PathView,QmlGraphicsPathView)
@@ -412,7 +410,7 @@ void QmlGraphicsPathView::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
if (!d->stealMouse) {
QPointF delta = event->pos() - d->startPoint;
- if (qAbs(delta.x()) > FlickThreshold && qAbs(delta.y()) > FlickThreshold)
+ if (qAbs(delta.x()) > QApplication::startDragDistance() && qAbs(delta.y()) > QApplication::startDragDistance())
d->stealMouse = true;
}