aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/handlers/qquicktaphandler_p.h
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2015-08-05 12:45:48 +0200
committerShawn Rutledge <shawn.rutledge@qt.io>2017-02-09 14:32:32 +0000
commit12f3f20be7e160b4f8de4ee267909fec61673111 (patch)
tree46bb48b514d537315a920dbe135c60f05d49d4f8 /src/quick/handlers/qquicktaphandler_p.h
parentcb78d5c91ed33543a8e7fe7717f74f95834e4cc3 (diff)
TapHandler: add timeHeld property
It enables long-press gestures to have continuous feedback. Change-Id: Idd0838aff6213ebfc2fce66639bbc932e77208b4 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.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/quick/handlers/qquicktaphandler_p.h b/src/quick/handlers/qquicktaphandler_p.h
index 93fe817844..bc292ecb12 100644
--- a/src/quick/handlers/qquicktaphandler_p.h
+++ b/src/quick/handlers/qquicktaphandler_p.h
@@ -63,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 timeHeld READ timeHeld NOTIFY timeHeldChanged)
Q_PROPERTY(qreal longPressThreshold READ longPressThreshold WRITE setLongPressThreshold NOTIFY longPressThresholdChanged)
Q_PROPERTY(GesturePolicy gesturePolicy READ gesturePolicy WRITE setGesturePolicy NOTIFY gesturePolicyChanged)
@@ -83,6 +84,7 @@ public:
bool isPressed() const { return m_pressed; }
int tapCount() const { return m_tapCount; }
+ qreal timeHeld() const { return (m_holdTimer.isValid() ? m_holdTimer.elapsed() / 1000.0 : -1.0); }
qreal longPressThreshold() const;
void setLongPressThreshold(qreal longPressThreshold);
@@ -93,6 +95,7 @@ public:
Q_SIGNALS:
void pressedChanged();
void tapCountChanged();
+ void timeHeldChanged();
void longPressThresholdChanged();
void gesturePolicyChanged();
void tapped(QQuickEventPoint *point);
@@ -105,6 +108,8 @@ protected:
private:
void setPressed(bool press, bool cancel, QQuickEventPoint *point);
int longPressThresholdMilliseconds() const;
+ void connectPreRenderSignal(bool conn = true);
+ void updateTimeHeld();
private:
bool m_pressed;
@@ -112,6 +117,7 @@ private:
int m_tapCount;
int m_longPressThreshold;
QBasicTimer m_longPressTimer;
+ QElapsedTimer m_holdTimer;
QPointF m_lastTapPos;
qreal m_lastTapTimestamp;