Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qquickpointerhandler_p.h
Go to the documentation of this file.
1// Copyright (C) 2018 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QQUICKPOINTERHANDLER_H
5#define QQUICKPOINTERHANDLER_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtCore/QObject>
19#include <QtCore/qloggingcategory.h>
20#include <QtCore/qtconfigmacros.h>
21#include <QtGui/qeventpoint.h>
22#include <QtGui/qpointingdevice.h>
23#include <QtQml/QQmlParserStatus>
24#include <QtQml/qqmlregistration.h>
25#include <QtQuick/qtquickglobal.h>
26#include <QtQuick/qtquickexports.h>
27
29
30Q_DECLARE_LOGGING_CATEGORY(lcPointerHandlerDispatch)
31
32class QQuickItem;
34class QPointerEvent;
35
36class Q_QUICK_EXPORT QQuickPointerHandler : public QObject, public QQmlParserStatus
37{
40
41 Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged)
42 Q_PROPERTY(bool active READ active NOTIFY activeChanged)
43 Q_PROPERTY(QQuickItem * target READ target WRITE setTarget NOTIFY targetChanged)
44 Q_PROPERTY(QQuickItem * parent READ parentItem WRITE setParentItem NOTIFY parentChanged)
45 Q_PROPERTY(GrabPermissions grabPermissions READ grabPermissions WRITE setGrabPermissions NOTIFY grabPermissionChanged)
46 Q_PROPERTY(qreal margin READ margin WRITE setMargin NOTIFY marginChanged)
47 Q_PROPERTY(int dragThreshold READ dragThreshold WRITE setDragThreshold RESET resetDragThreshold NOTIFY dragThresholdChanged REVISION(2, 15))
48#if QT_CONFIG(cursor)
49 Q_PROPERTY(Qt::CursorShape cursorShape READ cursorShape WRITE setCursorShape RESET resetCursorShape NOTIFY cursorShapeChanged REVISION(2, 15))
50#endif
51
52 Q_CLASSINFO("ParentProperty", "parent")
53 QML_NAMED_ELEMENT(PointerHandler)
54 QML_UNCREATABLE("PointerHandler is an abstract base class.")
56
57public:
58 explicit QQuickPointerHandler(QQuickItem *parent = nullptr);
60
62 TakeOverForbidden = 0x0,
63 CanTakeOverFromHandlersOfSameType = 0x01,
64 CanTakeOverFromHandlersOfDifferentType= 0x02,
65 CanTakeOverFromItems = 0x04,
66 CanTakeOverFromAnything = 0x0F,
67 ApprovesTakeOverByHandlersOfSameType = 0x10,
68 ApprovesTakeOverByHandlersOfDifferentType= 0x20,
69 ApprovesTakeOverByItems = 0x40,
70 ApprovesCancellation = 0x80,
71 ApprovesTakeOverByAnything = 0xF0
72 };
73 Q_DECLARE_FLAGS(GrabPermissions, GrabPermission)
74 Q_FLAG(GrabPermissions)
75
76public:
77 bool enabled() const;
78 void setEnabled(bool enabled);
79
80 bool active() const;
81
82 QQuickItem *target() const;
83 void setTarget(QQuickItem *target);
84
85 QQuickItem * parentItem() const;
86 void setParentItem(QQuickItem *p);
87
88 void handlePointerEvent(QPointerEvent *event);
89
90 GrabPermissions grabPermissions() const;
91 void setGrabPermissions(GrabPermissions grabPermissions);
92
93 qreal margin() const;
94 void setMargin(qreal pointDistanceThreshold);
95
96 int dragThreshold() const;
97 void setDragThreshold(int t);
98 void resetDragThreshold();
99
100#if QT_CONFIG(cursor)
101 Qt::CursorShape cursorShape() const;
102 void setCursorShape(Qt::CursorShape shape);
103 void resetCursorShape();
104 bool isCursorShapeExplicitlySet() const;
105#endif
106
112 Q_REVISION(2, 15) void dragThresholdChanged();
113 void grabChanged(QPointingDevice::GrabTransition transition, QEventPoint point);
114 void grabPermissionChanged();
115 void canceled(QEventPoint point);
116#if QT_CONFIG(cursor)
117 Q_REVISION(2, 15) void cursorShapeChanged();
118#endif
119 Q_REVISION(6, 3) void parentChanged();
120
121protected:
123
124 void classBegin() override;
125 void componentComplete() override;
126 bool event(QEvent *) override;
127
128 QPointerEvent *currentEvent();
129 virtual bool wantsPointerEvent(QPointerEvent *event);
130 virtual bool wantsEventPoint(const QPointerEvent *event, const QEventPoint &point);
131 virtual void handlePointerEventImpl(QPointerEvent *event);
132 void setActive(bool active);
133 virtual void onTargetChanged(QQuickItem *oldTarget) { Q_UNUSED(oldTarget); }
134 virtual void onActiveChanged() { }
135 virtual void onGrabChanged(QQuickPointerHandler *grabber, QPointingDevice::GrabTransition transition,
137 virtual bool canGrab(QPointerEvent *event, const QEventPoint &point);
138 virtual bool approveGrabTransition(QPointerEvent *event, const QEventPoint &point, QObject *proposedGrabber);
139 void setPassiveGrab(QPointerEvent *event, const QEventPoint &point, bool grab = true);
140 bool setExclusiveGrab(QPointerEvent *ev, const QEventPoint &point, bool grab = true);
141 void cancelAllGrabs(QPointerEvent *event, QEventPoint &point);
142 QPointF eventPos(const QEventPoint &point) const;
143 bool parentContains(const QEventPoint &point) const;
144 bool parentContains(const QPointF &scenePosition) const;
145
147 friend class QQuickItemPrivate;
149
150 Q_DECLARE_PRIVATE(QQuickPointerHandler)
151};
152
153Q_DECLARE_OPERATORS_FOR_FLAGS(QQuickPointerHandler::GrabPermissions)
154
156
157#endif // QQUICKPOINTERHANDLER_H
The QEventPoint class provides information about a point in a QPointerEvent.
Definition qeventpoint.h:20
\inmodule QtCore
Definition qcoreevent.h:45
\inmodule QtCore
Definition qobject.h:103
\inmodule QtCore\reentrant
Definition qpoint.h:217
A base class for pointer events.
Definition qevent.h:73
The QPointingDevice class describes a device from which mouse, touch or tablet events originate.
GrabTransition
This enum represents a transition of exclusive or passive grab from one object (possibly nullptr) to ...
The QQmlParserStatus class provides updates on the QML parser state.
The QQuickItem class provides the most basic of all visual items in \l {Qt Quick}.
Definition qquickitem.h:63
Q_REVISION(2, 15) void dragThresholdChanged()
Q_REVISION(6, 3) void parentChanged()
Combined button and popup list for selecting options.
CursorShape
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter int const void return DBusMessageIter DBusMessageIter return DBusMessageIter void DBusMessageIter void int return DBusMessage DBusMessageIter return DBusMessageIter return DBusMessageIter DBusMessageIter const char const char const char const char return DBusMessage return DBusMessage const char return DBusMessage dbus_bool_t return DBusMessage dbus_uint32_t return DBusMessage void
#define Q_DECLARE_FLAGS(Flags, Enum)
Definition qflags.h:174
#define Q_DECLARE_OPERATORS_FOR_FLAGS(Flags)
Definition qflags.h:194
#define Q_DECLARE_LOGGING_CATEGORY(name)
GLenum GLenum GLsizei const GLuint GLboolean enabled
GLenum target
struct _cl_event * event
GLdouble GLdouble t
Definition qopenglext.h:243
GLfloat GLfloat p
[1]
#define QML_UNCREATABLE(REASON)
#define QML_NAMED_ELEMENT(NAME)
#define QML_ADDED_IN_VERSION(MAJOR, MINOR)
#define Q_PROPERTY(...)
#define Q_OBJECT
#define Q_REVISION(...)
#define Q_CLASSINFO(name, value)
#define Q_FLAG(x)
#define Q_INTERFACES(x)
#define Q_SIGNALS
#define Q_UNUSED(x)
double qreal
Definition qtypes.h:187
static const uint base
Definition qurlidna.cpp:20
#define enabled
#define explicit