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
qquickevents_p_p.h
Go to the documentation of this file.
1// Copyright (C) 2020 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 QQUICKEVENTS_P_P_H
5#define QQUICKEVENTS_P_P_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 <private/qtquickglobal_p.h>
19#include <qqml.h>
20
21#include <QtCore/qobject.h>
22#include <QtCore/qpointer.h>
23#include <QtGui/qevent.h>
24#include <QtGui/qpointingdevice.h>
25#include <QtGui/qvector2d.h>
26#include <QtQuick/qquickitem.h>
27
28#if QT_CONFIG(shortcut)
29# include <QtGui/qkeysequence.h>
30#endif
31
33
34class QPointingDevice;
35class QPointerEvent;
36class QMouseEvent;
38
39class Q_QUICK_EXPORT QQuickKeyEvent : public QObject
40{
42 Q_PROPERTY(int key READ key CONSTANT FINAL)
43 Q_PROPERTY(QString text READ text CONSTANT FINAL)
44 Q_PROPERTY(int modifiers READ modifiers CONSTANT FINAL)
45 Q_PROPERTY(bool isAutoRepeat READ isAutoRepeat CONSTANT FINAL)
46 Q_PROPERTY(int count READ count CONSTANT FINAL)
47 Q_PROPERTY(quint32 nativeScanCode READ nativeScanCode CONSTANT FINAL)
48 Q_PROPERTY(bool accepted READ isAccepted WRITE setAccepted FINAL)
50 QML_UNCREATABLE("Should only be used by signal handlers in the Keys attached property")
52
53public:
56
57 void reset(QEvent::Type type, int key, Qt::KeyboardModifiers modifiers,
58 const QString &text = QString(), bool autorep = false, ushort count = 1)
59 {
60 m_type = type;
61 m_key = key;
62 m_modifiers = modifiers;
63 m_text = text;
64 m_autoRepeat = autorep;
65 m_count = count;
66 setAccepted(false);
67 }
68
69 void reset(const QKeyEvent &ke)
70 {
71 m_type = ke.type();
72 m_key = ke.key();
73 m_modifiers = ke.modifiers();
74 m_text = ke.text();
75 m_autoRepeat = ke.isAutoRepeat();
76 m_count = ke.count();
77 m_nativeScanCode = ke.nativeScanCode();
78 setAccepted(false);
79 }
80
81 int key() const { return m_key; }
82 QString text() const { return m_text; }
83 int modifiers() const { return m_modifiers; }
84 bool isAutoRepeat() const { return m_autoRepeat; }
85 int count() const { return m_count; }
86 quint32 nativeScanCode() const { return m_nativeScanCode; }
87
88 bool isAccepted() { return m_accepted; }
89 void setAccepted(bool accepted) { m_accepted = accepted; }
90
91#if QT_CONFIG(shortcut)
92 Q_REVISION(2, 2) Q_INVOKABLE bool matches(QKeySequence::StandardKey key) const;
93#endif
94
95private:
96 QString m_text;
97 quint32 m_nativeScanCode = 0;
99 int m_key = 0;
100 int m_modifiers = 0;
101 int m_count = 0;
102 bool m_accepted = false;
103 bool m_autoRepeat = false;
104};
105
106class Q_QUICK_EXPORT QQuickMouseEvent : public QObject
107{
109 Q_PROPERTY(qreal x READ x CONSTANT FINAL)
110 Q_PROPERTY(qreal y READ y CONSTANT FINAL)
111 Q_PROPERTY(int button READ button CONSTANT FINAL)
112 Q_PROPERTY(int buttons READ buttons CONSTANT FINAL)
113 Q_PROPERTY(int modifiers READ modifiers CONSTANT FINAL)
114#if QT_DEPRECATED_SINCE(6, 6)
115 Q_PROPERTY(int source READ source CONSTANT REVISION(2, 7) FINAL)
116#endif
117 Q_PROPERTY(bool isClick READ isClick CONSTANT FINAL)
118 Q_PROPERTY(bool wasHeld READ wasHeld CONSTANT FINAL)
119 Q_PROPERTY(bool accepted READ isAccepted WRITE setAccepted FINAL)
120 Q_PROPERTY(int flags READ flags CONSTANT REVISION(2, 11) FINAL)
122 QML_UNCREATABLE("Should only be used by mouse event signal handlers, for example in MouseArea")
124
125public:
127 : _wasHeld(false), _isClick(false), _accepted(false)
128 {}
129
130 void reset(qreal x, qreal y, Qt::MouseButton button, Qt::MouseButtons buttons,
131 Qt::KeyboardModifiers modifiers, bool isClick = false, bool wasHeld = false,
132 Qt::MouseEventFlags flags = { })
133 {
134 _x = x;
135 _y = y;
136 _button = button;
137 _buttons = buttons;
138 _modifiers = modifiers;
140 _wasHeld = wasHeld;
141 _isClick = isClick;
142 _accepted = true;
143 _flags = flags;
144 }
145
146 qreal x() const { return _x; }
147 qreal y() const { return _y; }
148 int button() const { return _button; }
149 int buttons() const { return _buttons; }
150 int modifiers() const { return _modifiers; }
151#if QT_DEPRECATED_SINCE(6, 6)
152 int source() const { return _source; }
153#endif
154 bool wasHeld() const { return _wasHeld; }
155 bool isClick() const { return _isClick; }
156
157 // only for internal usage
158 void setX(qreal x) { _x = x; }
159 void setY(qreal y) { _y = y; }
160 void setPosition(const QPointF &point) { _x = point.x(); _y = point.y(); }
161#if QT_DEPRECATED_SINCE(6, 6)
162 void setSource(Qt::MouseEventSource s) { _source = s; }
163#endif
164
165 bool isAccepted() { return _accepted; }
166 void setAccepted(bool accepted) { _accepted = accepted; }
167 int flags() const { return _flags; }
168private:
169 qreal _x = 0;
170 qreal _y = 0;
172 Qt::MouseButtons _buttons = Qt::NoButton;
173 Qt::KeyboardModifiers _modifiers = Qt::NoModifier;
175 bool _wasHeld : 1;
176 bool _isClick : 1;
177 bool _accepted : 1;
178 Qt::MouseEventFlags _flags = Qt::NoMouseEventFlag;
179};
180
181#if QT_CONFIG(wheelevent)
182class Q_QUICK_EXPORT QQuickWheelEvent : public QObject
183{
185 Q_PROPERTY(const QPointingDevice *device READ pointingDevice CONSTANT FINAL)
186 Q_PROPERTY(qreal x READ x CONSTANT FINAL)
187 Q_PROPERTY(qreal y READ y CONSTANT FINAL)
188 Q_PROPERTY(QPoint angleDelta READ angleDelta CONSTANT FINAL)
189 Q_PROPERTY(QPoint pixelDelta READ pixelDelta CONSTANT FINAL)
190 Q_PROPERTY(Qt::ScrollPhase phase READ phase CONSTANT FINAL)
191 Q_PROPERTY(int buttons READ buttons CONSTANT FINAL)
192 Q_PROPERTY(int modifiers READ modifiers CONSTANT FINAL)
193 Q_PROPERTY(bool inverted READ inverted CONSTANT FINAL)
194 Q_PROPERTY(bool accepted READ isAccepted WRITE setAccepted FINAL)
196 QML_UNCREATABLE("Should only be used by wheel event signal handlers, for example in MouseArea")
198
199public:
200 QQuickWheelEvent() = default;
201
202 void reset(const QWheelEvent *event)
203 {
204 _device = event->pointingDevice();
205 _x = event->position().x();
206 _y = event->position().y();
207 _angleDelta = event->angleDelta();
208 _pixelDelta = event->pixelDelta();
209 _buttons = event->buttons();
210 _modifiers = event->modifiers();
211 _accepted = true;
212 _inverted = event->inverted();
213 _phase = event->phase();
214 }
215
216 const QPointingDevice *pointingDevice() const { return _device; }
217 qreal x() const { return _x; }
218 qreal y() const { return _y; }
219 QPoint angleDelta() const { return _angleDelta; }
220 QPoint pixelDelta() const { return _pixelDelta; }
221 int buttons() const { return _buttons; }
222 int modifiers() const { return _modifiers; }
223 Qt::ScrollPhase phase() const { return _phase; }
224 bool inverted() const { return _inverted; }
225 bool isAccepted() { return _accepted; }
226 void setAccepted(bool accepted) { _accepted = accepted; }
227
228private:
229 const QPointingDevice *_device = nullptr;
230 qreal _x = 0;
231 qreal _y = 0;
232 QPoint _angleDelta;
233 QPoint _pixelDelta;
234 Qt::MouseButtons _buttons = Qt::NoButton;
235 Qt::KeyboardModifiers _modifiers = Qt::NoModifier;
237 bool _inverted = false;
238 bool _accepted = false;
239};
240#endif
241
242class Q_QUICK_EXPORT QQuickCloseEvent : public QObject
243{
245 Q_PROPERTY(bool accepted READ isAccepted WRITE setAccepted FINAL)
246 QML_NAMED_ELEMENT(CloseEvent)
247 QML_UNCREATABLE("Should only be used by Window's closing signal")
249
250public:
252
253 bool isAccepted() { return _accepted; }
254 void setAccepted(bool accepted) { _accepted = accepted; }
255
256private:
257 bool _accepted = true;
258};
259
261
262#endif // QQUICKEVENTS_P_P_H
IOBluetoothDevice * device
Type
This enum type defines the valid event types in Qt.
Definition qcoreevent.h:51
The QKeyEvent class describes a key event.
Definition qevent.h:424
The QKeySequence class encapsulates a key sequence as used by shortcuts.
\inmodule QtGui
Definition qevent.h:196
\inmodule QtCore
Definition qobject.h:103
\inmodule QtCore\reentrant
Definition qpoint.h:217
constexpr qreal x() const noexcept
Returns the x coordinate of this point.
Definition qpoint.h:343
constexpr qreal y() const noexcept
Returns the y coordinate of this point.
Definition qpoint.h:348
\inmodule QtCore\reentrant
Definition qpoint.h:25
A base class for pointer events.
Definition qevent.h:73
The QPointingDevice class describes a device from which mouse, touch or tablet events originate.
\qmlsignal QtQuick::Window::sceneGraphError(SceneGraphError error, QString message)
void setAccepted(bool accepted)
quint32 nativeScanCode() const
void reset(const QKeyEvent &ke)
void setAccepted(bool accepted)
int modifiers() const
int count() const
void reset(QEvent::Type type, int key, Qt::KeyboardModifiers modifiers, const QString &text=QString(), bool autorep=false, ushort count=1)
bool isAutoRepeat() const
QString text() const
\qmlproperty int QtQuick::KeyEvent::key
void setAccepted(bool accepted)
void reset(qreal x, qreal y, Qt::MouseButton button, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, bool isClick=false, bool wasHeld=false, Qt::MouseEventFlags flags={ })
void setPosition(const QPointF &point)
\qmlproperty real QtQuick::MouseEvent::x \qmlproperty real QtQuick::MouseEvent::y
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
qsizetype count(QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition qstring.cpp:4833
EGLImageKHR int int EGLuint64KHR * modifiers
for(qsizetype i=0;i< list.size();++i)
QString text
QPushButton * button
[2]
auto signal
Combined button and popup list for selecting options.
MouseButton
Definition qnamespace.h:56
@ NoButton
Definition qnamespace.h:57
MouseEventSource
@ MouseEventNotSynthesized
@ NoModifier
ScrollPhase
@ NoScrollPhase
@ NoMouseEventFlag
static bool matches(const QJsonObject &object, const QString &osName, const QVersionNumber &kernelVersion, const QString &osRelease, const QOpenGLConfig::Gpu &gpu)
Definition qopengl.cpp:270
GLint GLint GLint GLint GLint x
[0]
GLuint64 key
GLenum GLenum GLsizei count
GLenum type
GLbitfield flags
GLint y
GLsizei GLsizei GLchar * source
struct _cl_event * event
GLdouble s
[6]
Definition qopenglext.h:235
GLboolean reset
GLuint in
GLbyte by
#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_INVOKABLE
unsigned int quint32
Definition qtypes.h:50
unsigned short ushort
Definition qtypes.h:33
double qreal
Definition qtypes.h:187
const char property[13]
Definition qwizard.cpp:101