aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/handlers/qquicktaphandler_p.h
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2016-11-18 15:02:18 +0100
committerShawn Rutledge <shawn.rutledge@qt.io>2017-02-09 14:32:10 +0000
commit5c639a07fd90916d39823e800d5d89f779d892e9 (patch)
tree6a42a04f6c9093ec7430b79e577eaa99413ef3c3 /src/quick/handlers/qquicktaphandler_p.h
parent3e21962cea50433c8f043d2a8a0d61ef86339a22 (diff)
TapHandler: add long-press feature
Add a longPressed signal, emitted when the point is held long enough. Add the longPressThreshold to control how long that is. Change-Id: I95a65f1e4c62eb41fb9ea02b14bdc3f16aa72ec2 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
Diffstat (limited to 'src/quick/handlers/qquicktaphandler_p.h')
-rw-r--r--src/quick/handlers/qquicktaphandler_p.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/quick/handlers/qquicktaphandler_p.h b/src/quick/handlers/qquicktaphandler_p.h
index c11d51ee03..0559089fbf 100644
--- a/src/quick/handlers/qquicktaphandler_p.h
+++ b/src/quick/handlers/qquicktaphandler_p.h
@@ -54,6 +54,7 @@
#include "qquickitem.h"
#include "qevent.h"
#include "qquickpointersinglehandler_p.h"
+#include <QtCore/qbasictimer.h>
QT_BEGIN_NAMESPACE
@@ -62,6 +63,7 @@ class Q_AUTOTEST_EXPORT QQuickTapHandler : public QQuickPointerSingleHandler
Q_OBJECT
Q_PROPERTY(bool isPressed READ isPressed NOTIFY pressedChanged)
Q_PROPERTY(int tapCount READ tapCount NOTIFY tapCountChanged)
+ Q_PROPERTY(qreal longPressThreshold READ longPressThreshold WRITE setLongPressThreshold NOTIFY longPressThresholdChanged)
public:
QQuickTapHandler(QObject *parent = 0);
@@ -74,20 +76,29 @@ public:
int tapCount() const { return m_tapCount; }
+ qreal longPressThreshold() const;
+ void setLongPressThreshold(qreal longPressThreshold);
+
Q_SIGNALS:
void pressedChanged();
void tapCountChanged();
+ void longPressThresholdChanged();
void tapped(QQuickEventPoint *point);
+ void longPressed();
protected:
void handleGrabCancel(QQuickEventPoint *point) override;
+ void timerEvent(QTimerEvent *event) override;
private:
void setPressed(bool press, bool cancel, QQuickEventPoint *point);
+ int longPressThresholdMilliseconds() const;
private:
bool m_pressed;
int m_tapCount;
+ int m_longPressThreshold;
+ QBasicTimer m_longPressTimer;
QPointF m_lastTapPos;
qreal m_lastTapTimestamp;