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>
59 if (m_mouseMultiClickDistanceSquared < 0) {
60 m_multiTapInterval =
qApp->styleHints()->mouseDoubleClickInterval();
61 m_mouseMultiClickDistanceSquared =
qApp->styleHints()->mouseDoubleClickDistance();
62 m_mouseMultiClickDistanceSquared *= m_mouseMultiClickDistanceSquared;
63 m_touchMultiTapDistanceSquared =
qApp->styleHints()->touchDoubleTapDistance();
64 m_touchMultiTapDistanceSquared *= m_touchMultiTapDistanceSquared;
79 bool overThreshold = d_func()->dragOverThreshold(
point);
81 m_longPressTimer.
stop();
84 switch (
point.state()) {
91 switch (m_gesturePolicy) {
124 switch (
point.state()) {
142 point.setAccepted(
false);
156 return longPressThresholdMilliseconds() / 1000.0;
162 if (m_longPressThreshold == ms)
165 m_longPressThreshold = ms;
169int QQuickTapHandler::longPressThresholdMilliseconds()
const
177 m_longPressTimer.
stop();
180 }
else if (
event->timerId() == m_doubleTapTimer.
timerId()) {
181 m_doubleTapTimer.
stop();
182 qCDebug(lcTapHandler) <<
objectName() <<
"double-tap timer expired; taps:" << m_tapCount;
186 else if (m_tapCount == 2)
328 if (m_exclusiveSignals == exc)
331 m_exclusiveSignals = exc;
332 emit exclusiveSignalsChanged();
346 if (m_pressed != press) {
348 << (
cancel ?
"CANCEL" :
"") <<
point <<
"gp" << m_gesturePolicy;
350 connectPreRenderSignal(press);
353 m_longPressTimer.
start(longPressThresholdMilliseconds(),
this);
356 m_longPressTimer.
stop();
369 const quint64 ts =
event->timestamp();
370 const quint64 interval = ts - m_lastTapTimestamp;
373 if ((interval < m_multiTapInterval && distanceSquared <
375 m_mouseMultiClickDistanceSquared : m_touchMultiTapDistanceSquared))
376 && m_singleTapReleasedButton == singleTapReleasedButton) {
379 m_singleTapReleasedButton = singleTapReleasedButton;
380 m_singleTapReleasedPoint =
point;
383 qCDebug(lcTapHandler) <<
objectName() <<
"tapped" << m_tapCount <<
"times; interval since last:" << interval
384 <<
"sec; distance since last:" <<
qSqrt(distanceSquared);
388 switch (m_exclusiveSignals) {
392 else if (m_tapCount == 2)
404 if (m_tapCount == 1) {
405 qCDebug(lcTapHandler) <<
objectName() <<
"waiting to emit singleTapped:" << m_multiTapInterval <<
"ms";
406 m_doubleTapTimer.
start(m_multiTapInterval,
this);
409 qCDebug(lcTapHandler) <<
objectName() <<
"tap" << m_tapCount <<
"after" <<
event->timestamp() - m_lastTapTimestamp <<
"ms";
411 m_lastTapTimestamp = ts;
439 setPressed(
false, isCanceled, ev,
point);
442void QQuickTapHandler::connectPreRenderSignal(
bool conn)
453void QQuickTapHandler::updateTimeHeld()
561#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.
void invalidate() noexcept
Marks this QElapsedTimer object as invalid.
void start() noexcept
Starts this timer.
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 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]
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent