6#include <QtQuick/private/qquickdeliveryagent_p_p.h>
7#include <QtQuick/qquickwindow.h>
8#include <qpa/qplatformtheme.h>
9#include <private/qguiapplication_p.h>
10#include <QtGui/qstylehints.h>
58 , m_longPressThreshold(
QGuiApplication::styleHints()->mousePressAndHoldInterval())
60 if (m_mouseMultiClickDistanceSquared < 0) {
61 m_multiTapInterval =
qApp->styleHints()->mouseDoubleClickInterval();
62 m_mouseMultiClickDistanceSquared =
qApp->styleHints()->mouseDoubleClickDistance();
63 m_mouseMultiClickDistanceSquared *= m_mouseMultiClickDistanceSquared;
64 m_touchMultiTapDistanceSquared =
qApp->styleHints()->touchDoubleTapDistance();
65 m_touchMultiTapDistanceSquared *= m_touchMultiTapDistanceSquared;
80 bool overThreshold = d_func()->dragOverThreshold(
point);
84 m_longPressTimer.
stop();
87 switch (
point.state()) {
94 switch (m_gesturePolicy) {
127 switch (
point.state()) {
145 point.setAccepted(
false);
164 return m_longPressThreshold /
qreal(1000);
174 if (m_longPressThreshold == ms)
177 m_longPressThreshold = ms;
184 if (m_longPressThreshold == ms)
187 m_longPressThreshold = ms;
194 m_longPressTimer.
stop();
196 m_longPressed =
true;
198 }
else if (
event->timerId() == m_doubleTapTimer.
timerId()) {
199 m_doubleTapTimer.
stop();
200 qCDebug(lcTapHandler) <<
objectName() <<
"double-tap timer expired; taps:" << m_tapCount;
204 else if (m_tapCount == 2)
346 if (m_exclusiveSignals == exc)
349 m_exclusiveSignals = exc;
350 emit exclusiveSignalsChanged();
364 if (m_pressed != press) {
366 << (
cancel ?
"CANCEL" :
"") <<
point <<
"gp" << m_gesturePolicy;
368 connectPreRenderSignal(press);
371 if (m_longPressThreshold > 0)
372 m_longPressTimer.
start(m_longPressThreshold,
this);
375 m_longPressTimer.
stop();
390 const quint64 ts =
event->timestamp();
391 const quint64 interval = ts - m_lastTapTimestamp;
394 if ((interval < m_multiTapInterval && distanceSquared <
396 m_mouseMultiClickDistanceSquared : m_touchMultiTapDistanceSquared))
397 && m_singleTapReleasedButton == singleTapReleasedButton) {
400 m_singleTapReleasedButton = singleTapReleasedButton;
401 m_singleTapReleasedPoint =
point;
404 qCDebug(lcTapHandler) <<
objectName() <<
"tapped" << m_tapCount <<
"times; interval since last:" << interval
405 <<
"sec; distance since last:" <<
qSqrt(distanceSquared);
409 switch (m_exclusiveSignals) {
413 else if (m_tapCount == 2)
425 if (m_tapCount == 1) {
426 qCDebug(lcTapHandler) <<
objectName() <<
"waiting to emit singleTapped:" << m_multiTapInterval <<
"ms";
427 m_doubleTapTimer.
start(m_multiTapInterval,
this);
430 qCDebug(lcTapHandler) <<
objectName() <<
"tap" << m_tapCount <<
"after" <<
event->timestamp() - m_lastTapTimestamp <<
"ms";
432 m_lastTapTimestamp = ts;
436 m_longPressed =
false;
459 setPressed(
false, isCanceled, ev,
point);
462void QQuickTapHandler::connectPreRenderSignal(
bool conn)
468 if (!par || !par->window())
481 this, &QQuickTapHandler::updateTimeHeld);
485void QQuickTapHandler::updateTimeHeld()
593#include "moc_qquicktaphandler_p.cpp"
void start(int msec, QObject *obj)
\obsolete Use chrono overload instead.
int timerId() const noexcept
Returns the timer's ID.
void stop()
Stops the timer.
bool isActive() const noexcept
Returns true if the timer is running and has not been stopped; otherwise returns false.
void invalidate() noexcept
Marks this QElapsedTimer object as invalid.
void start() noexcept
\typealias QElapsedTimer::Duration Synonym for std::chrono::nanoseconds.
The QEventPoint class provides information about a point in a QPointerEvent.
static QStyleHints * styleHints()
Returns the application's style hints.
QString objectName
the name of this object
A base class for pointer events.
GrabTransition
This enum represents a transition of exclusive or passive grab from one object (possibly nullptr) to ...
static bool isTabletEvent(const QPointerEvent *ev)
static bool isTouchEvent(const QPointerEvent *ev)
static bool isMouseEvent(const QPointerEvent *ev)
The QQuickItem class provides the most basic of all visual items in \l {Qt Quick}.
Qt::MouseButtons acceptedButtons
bool parentContains(const QEventPoint &point) const
Returns true if margin() > 0 and point is within the margin beyond QQuickItem::boundingRect(),...
QQuickItem * parentItem() const
\qmlproperty Item QtQuick::PointerHandler::parent
void setPassiveGrab(QPointerEvent *event, const QEventPoint &point, bool grab=true)
Acquire or give up a passive grab of the given point, according to the grab state.
bool setExclusiveGrab(QPointerEvent *ev, const QEventPoint &point, bool grab=true)
Acquire or give up the exclusive grab of the given point, according to the grab state,...
void canceled(QEventPoint point)
virtual void handleEventPoint(QPointerEvent *event, QEventPoint &point)
void onGrabChanged(QQuickPointerHandler *grabber, QPointingDevice::GrabTransition transition, QPointerEvent *event, QEventPoint &point) override
Notification that the grab has changed in some way which is relevant to this handler.
void handleEventPoint(QPointerEvent *event, QEventPoint &point) override
void doubleTapped(QEventPoint eventPoint, Qt::MouseButton)
void setExclusiveSignals(QQuickTapHandler::ExclusiveSignals newexclusiveSignals)
\qmlproperty enumeration QtQuick::TapHandler::exclusiveSignals
void setGesturePolicy(GesturePolicy gesturePolicy)
\qmlproperty enumeration QtQuick::TapHandler::gesturePolicy
GesturePolicy gesturePolicy
void onGrabChanged(QQuickPointerHandler *grabber, QPointingDevice::GrabTransition transition, QPointerEvent *ev, QEventPoint &point) override
Notification that the grab has changed in some way which is relevant to this handler.
void singleTapped(QEventPoint eventPoint, Qt::MouseButton)
void setLongPressThreshold(qreal longPressThreshold)
void timerEvent(QTimerEvent *event) override
This event handler can be reimplemented in a subclass to receive timer events for the object.
void gesturePolicyChanged()
void tapped(QEventPoint eventPoint, Qt::MouseButton)
void resetLongPressThreshold()
void longPressThresholdChanged()
bool wantsEventPoint(const QPointerEvent *event, const QEventPoint &point) override
Returns true if the given point (as part of event) could be relevant at all to this handler,...
void beforeSynchronizing()
This signal is emitted before the scene graph is synchronized with the QML state.
A base class for pointer events containing a single point, such as mouse events.
The QVector2D class represents a vector or vertex in 2D space.
constexpr float lengthSquared() const noexcept
Returns the squared length of the vector from the origin.
Combined button and popup list for selecting options.
qfloat16 qSqrt(qfloat16 f)
int qRound(qfloat16 d) noexcept
#define Q_LOGGING_CATEGORY(name,...)
#define qCDebug(category,...)
unsigned long long quint64
connect(quitButton, &QPushButton::clicked, &app, &QCoreApplication::quit, Qt::QueuedConnection)
myObject disconnect()
[26]