diff options
author | Jan Arve Saether <jan-arve.saether@qt.io> | 2016-12-07 14:19:54 +0100 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2016-12-07 19:30:51 +0000 |
commit | 558bb0e3bbbd3eaca52b02946374f2106c3a3872 (patch) | |
tree | 9a3dfbba9b8888b032f12eae49ee7ae9e0a25462 /src/quick/items/qquickwindow_p.h | |
parent | 48591ce7dc00ec2c00ec3983a9572398fbd794b8 (diff) |
QQuickWindowPrivate::dragOverThreshold(): ignore zero velocity threshold
Previously, this would trigger a drag even if the touch point was quite
steady, since a rather steady finger could report a very small velocity
(usually between 0 and 1).
Change so that it will ignore velocity if it's not positive.
At the same time convert it to a template function since we want to also
use this for QQuickEventPoint later on.
Change-Id: Ibb2210813707399ae84e3422718c995897891060
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'src/quick/items/qquickwindow_p.h')
-rw-r--r-- | src/quick/items/qquickwindow_p.h | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/quick/items/qquickwindow_p.h b/src/quick/items/qquickwindow_p.h index 32a6939868..829fe53458 100644 --- a/src/quick/items/qquickwindow_p.h +++ b/src/quick/items/qquickwindow_p.h @@ -66,6 +66,8 @@ #include <qopenglcontext.h> #include <QtGui/qopenglframebufferobject.h> #include <QtGui/qevent.h> +#include <QtGui/qstylehints.h> +#include <QtGui/qguiapplication.h> QT_BEGIN_NAMESPACE @@ -270,7 +272,19 @@ public: static bool defaultAlphaBuffer; static bool dragOverThreshold(qreal d, Qt::Axis axis, QMouseEvent *event, int startDragThreshold = -1); - static bool dragOverThreshold(qreal d, Qt::Axis axis, const QTouchEvent::TouchPoint *tp, int startDragThreshold = -1); + + template <typename TEventPoint> + static bool dragOverThreshold(qreal d, Qt::Axis axis, const TEventPoint *p, int startDragThreshold = -1) + { + QStyleHints *styleHints = qApp->styleHints(); + bool overThreshold = qAbs(d) > (startDragThreshold >= 0 ? startDragThreshold : styleHints->startDragDistance()); + const bool dragVelocityLimitAvailable = (styleHints->startDragVelocity() > 0); + if (!overThreshold && dragVelocityLimitAvailable) { + qreal velocity = axis == Qt::XAxis ? p->velocity().x() : p->velocity().y(); + overThreshold |= qAbs(velocity) > styleHints->startDragVelocity(); + } + return overThreshold; + } // data property static void data_append(QQmlListProperty<QObject> *, QObject *); |