aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items/qquickdrag.cpp
diff options
context:
space:
mode:
authorJens Bache-Wiig <jens.bache-wiig@digia.com>2013-08-22 17:20:52 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-09-13 17:51:48 +0200
commit406d6d33a6c0c5f99dfa31e2eb681b1fefcd5fe0 (patch)
treec365e466a5ba74a29ab1bc1f51aab6f407d105b9 /src/quick/items/qquickdrag.cpp
parentee6cc22ebd0ec236454bc2112fe5f82e31299143 (diff)
Expose drag threshold in MouseArea
In several cases such as for creating a Slider, it is useful to have a 0 pixel threshold in order to initiate a drag operation. We have previously hardcoded this to a platform dependent (usually 10 pixel) value for MouseArea. Note that we have no way of indicating the version/revision number in a grouped property for documentation at the moment. In addition we deliberately had to remove the REVISION from the property because it is blocked by QTBUG-33179. However, since this is not a user-creatable type it should not cause any issues in practice. This patch adds MouseArea.drag.threshold in order to improve on this. Change-Id: Ia4871e64fab39e30c4494f00be99ad38cdd630df Reviewed-by: J-P Nurmi <jpnurmi@digia.com>
Diffstat (limited to 'src/quick/items/qquickdrag.cpp')
-rw-r--r--src/quick/items/qquickdrag.cpp25
1 files changed, 23 insertions, 2 deletions
diff --git a/src/quick/items/qquickdrag.cpp b/src/quick/items/qquickdrag.cpp
index 0ae26cb5c3..166b40aaf2 100644
--- a/src/quick/items/qquickdrag.cpp
+++ b/src/quick/items/qquickdrag.cpp
@@ -45,11 +45,12 @@
#include <QtQuick/private/qquickevents_p_p.h>
#include <private/qquickitemchangelistener_p.h>
#include <private/qv8engine_p.h>
-#include <QtCore/qcoreapplication.h>
#include <QtCore/qmimedata.h>
#include <QtQml/qqmlinfo.h>
#include <QtGui/qdrag.h>
#include <QtGui/qevent.h>
+#include <QtGui/qstylehints.h>
+#include <QtGui/qguiapplication.h>
#ifndef QT_NO_DRAGANDDROP
@@ -785,7 +786,8 @@ void QQuickDragAttached::startDrag(QQmlV4Function *args)
QQuickDrag::QQuickDrag(QObject *parent)
: QObject(parent), _target(0), _axis(XAndYAxis), _xmin(-FLT_MAX),
-_xmax(FLT_MAX), _ymin(-FLT_MAX), _ymax(FLT_MAX), _active(false), _filterChildren(false)
+_xmax(FLT_MAX), _ymin(-FLT_MAX), _ymax(FLT_MAX), _active(false), _filterChildren(false),
+ _threshold(qApp->styleHints()->startDragDistance())
{
}
@@ -879,6 +881,25 @@ void QQuickDrag::setYmax(qreal m)
emit maximumYChanged();
}
+
+qreal QQuickDrag::threshold() const
+{
+ return _threshold;
+}
+
+void QQuickDrag::setThreshold(qreal value)
+{
+ if (_threshold != value) {
+ _threshold = value;
+ emit thresholdChanged();
+ }
+}
+
+void QQuickDrag::resetThreshold()
+{
+ setThreshold(qApp->styleHints()->startDragDistance());
+}
+
bool QQuickDrag::active() const
{
return _active;