| 1 | /**************************************************************************** |
| 2 | ** |
| 3 | ** Copyright (C) 2020 The Qt Company Ltd. |
| 4 | ** Contact: https://www.qt.io/licensing/ |
| 5 | ** |
| 6 | ** This file is part of the QtGui module of the Qt Toolkit. |
| 7 | ** |
| 8 | ** $QT_BEGIN_LICENSE:LGPL$ |
| 9 | ** Commercial License Usage |
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in |
| 11 | ** accordance with the commercial license agreement provided with the |
| 12 | ** Software or, alternatively, in accordance with the terms contained in |
| 13 | ** a written agreement between you and The Qt Company. For licensing terms |
| 14 | ** and conditions see https://www.qt.io/terms-conditions. For further |
| 15 | ** information use the contact form at https://www.qt.io/contact-us. |
| 16 | ** |
| 17 | ** GNU Lesser General Public License Usage |
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser |
| 19 | ** General Public License version 3 as published by the Free Software |
| 20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the |
| 21 | ** packaging of this file. Please review the following information to |
| 22 | ** ensure the GNU Lesser General Public License version 3 requirements |
| 23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. |
| 24 | ** |
| 25 | ** GNU General Public License Usage |
| 26 | ** Alternatively, this file may be used under the terms of the GNU |
| 27 | ** General Public License version 2.0 or (at your option) the GNU General |
| 28 | ** Public license version 3 or any later version approved by the KDE Free |
| 29 | ** Qt Foundation. The licenses are as published by the Free Software |
| 30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 |
| 31 | ** included in the packaging of this file. Please review the following |
| 32 | ** information to ensure the GNU General Public License requirements will |
| 33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and |
| 34 | ** https://www.gnu.org/licenses/gpl-3.0.html. |
| 35 | ** |
| 36 | ** $QT_END_LICENSE$ |
| 37 | ** |
| 38 | ****************************************************************************/ |
| 39 | |
| 40 | #ifndef QEVENT_H |
| 41 | #define QEVENT_H |
| 42 | |
| 43 | #include <QtGui/qtguiglobal.h> |
| 44 | |
| 45 | #include <QtCore/qcoreevent.h> |
| 46 | #include <QtCore/qiodevice.h> |
| 47 | #include <QtCore/qlist.h> |
| 48 | #include <QtCore/qnamespace.h> |
| 49 | #include <QtCore/qpointer.h> |
| 50 | #include <QtCore/qstring.h> |
| 51 | #include <QtCore/qurl.h> |
| 52 | #include <QtCore/qvariant.h> |
| 53 | #include <QtGui/qpointingdevice.h> |
| 54 | #include <QtGui/qregion.h> |
| 55 | #include <QtGui/qvector2d.h> |
| 56 | #include <QtGui/qwindowdefs.h> |
| 57 | |
| 58 | #if QT_CONFIG(shortcut) |
| 59 | # include <QtGui/qkeysequence.h> |
| 60 | #endif |
| 61 | |
| 62 | QT_BEGIN_NAMESPACE |
| 63 | |
| 64 | class QFile; |
| 65 | class QAction; |
| 66 | class QMouseEvent; |
| 67 | class QPointerEvent; |
| 68 | class QScreen; |
| 69 | class QTabletEvent; |
| 70 | class QTouchEvent; |
| 71 | #if QT_CONFIG(gestures) |
| 72 | class QGesture; |
| 73 | #endif |
| 74 | |
| 75 | class Q_GUI_EXPORT QInputEvent : public QEvent |
| 76 | { |
| 77 | public: |
| 78 | explicit QInputEvent(Type type, const QInputDevice *m_dev, Qt::KeyboardModifiers modifiers = Qt::NoModifier); |
| 79 | ~QInputEvent(); |
| 80 | const QInputDevice *device() const { return m_dev; } |
| 81 | QInputDevice::DeviceType deviceType() const { return m_dev ? m_dev->type() : QInputDevice::DeviceType::Unknown; } |
| 82 | inline Qt::KeyboardModifiers modifiers() const { return m_modState; } |
| 83 | inline void setModifiers(Qt::KeyboardModifiers modifiers) { m_modState = modifiers; } |
| 84 | inline ulong timestamp() const { return m_timeStamp; } |
| 85 | virtual void setTimestamp(ulong timestamp) { m_timeStamp = timestamp; } |
| 86 | |
| 87 | protected: |
| 88 | QInputEvent(Type type, PointerEventTag, const QInputDevice *m_dev, Qt::KeyboardModifiers modifiers = Qt::NoModifier); |
| 89 | |
| 90 | const QInputDevice *m_dev = nullptr; |
| 91 | Qt::KeyboardModifiers m_modState = Qt::NoModifier; |
| 92 | ulong m_timeStamp = 0; |
| 93 | qint64 = 0; // reserved, unused for now |
| 94 | }; |
| 95 | |
| 96 | struct QEventPointPrivate; |
| 97 | class Q_GUI_EXPORT QEventPoint |
| 98 | { |
| 99 | Q_GADGET |
| 100 | Q_PROPERTY(const QPointingDevice *device READ device) |
| 101 | Q_PROPERTY(int id READ id) |
| 102 | Q_PROPERTY(QPointingDeviceUniqueId uniqueId READ uniqueId) |
| 103 | Q_PROPERTY(State state READ state) |
| 104 | Q_PROPERTY(ulong timestamp READ timestamp) |
| 105 | Q_PROPERTY(qreal timeHeld READ timeHeld) |
| 106 | Q_PROPERTY(qreal pressure READ pressure) |
| 107 | Q_PROPERTY(qreal rotation READ rotation) |
| 108 | Q_PROPERTY(QSizeF ellipseDiameters READ ellipseDiameters) |
| 109 | Q_PROPERTY(QVector2D velocity READ velocity) |
| 110 | Q_PROPERTY(QPointF position READ position) |
| 111 | Q_PROPERTY(QPointF scenePosition READ scenePosition) |
| 112 | Q_PROPERTY(QPointF globalPosition READ globalPosition) |
| 113 | public: |
| 114 | enum State : quint8 { |
| 115 | Unknown = Qt::TouchPointUnknownState, |
| 116 | Stationary = Qt::TouchPointStationary, |
| 117 | Pressed = Qt::TouchPointPressed, |
| 118 | Updated = Qt::TouchPointMoved, |
| 119 | Released = Qt::TouchPointReleased |
| 120 | }; |
| 121 | Q_DECLARE_FLAGS(States, State) |
| 122 | Q_FLAG(States) |
| 123 | |
| 124 | QEventPoint(int id = -1, const QPointingDevice *device = nullptr); |
| 125 | QEventPoint(int pointId, State state, const QPointF &scenePosition, const QPointF &globalPosition); |
| 126 | QEventPoint(const QEventPoint &other); |
| 127 | QEventPoint(QEventPoint && other) noexcept : d(std::move(other.d)) { other.d = nullptr; } |
| 128 | QEventPoint &operator=(const QEventPoint &other); |
| 129 | QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_MOVE_AND_SWAP(QEventPoint) |
| 130 | bool operator==(const QEventPoint &other) const noexcept; |
| 131 | inline bool operator!=(const QEventPoint &other) const noexcept { return !operator==(other); } |
| 132 | ~QEventPoint(); |
| 133 | inline void swap(QEventPoint &other) noexcept |
| 134 | { qSwap(d, other.d); } |
| 135 | |
| 136 | QPointF position() const; |
| 137 | QPointF pressPosition() const; |
| 138 | QPointF grabPosition() const; |
| 139 | QPointF lastPosition() const; |
| 140 | QPointF scenePosition() const; |
| 141 | QPointF scenePressPosition() const; |
| 142 | QPointF sceneGrabPosition() const; |
| 143 | QPointF sceneLastPosition() const; |
| 144 | QPointF globalPosition() const; |
| 145 | QPointF globalPressPosition() const; |
| 146 | QPointF globalGrabPosition() const; |
| 147 | QPointF globalLastPosition() const; |
| 148 | |
| 149 | #if QT_DEPRECATED_SINCE(6, 0) |
| 150 | // QEventPoint replaces QTouchEvent::TouchPoint, so we need all its old accessors, for now |
| 151 | QT_DEPRECATED_VERSION_X_6_0("Use position()" ) |
| 152 | QPointF pos() const { return position(); } |
| 153 | QT_DEPRECATED_VERSION_X_6_0("Use pressPosition()" ) |
| 154 | QPointF startPos() const { return pressPosition(); } |
| 155 | QT_DEPRECATED_VERSION_X_6_0("Use scenePosition()" ) |
| 156 | QPointF scenePos() const { return scenePosition(); } |
| 157 | QT_DEPRECATED_VERSION_X_6_0("Use scenePressPosition()" ) |
| 158 | QPointF startScenePos() const { return scenePressPosition(); } |
| 159 | QT_DEPRECATED_VERSION_X_6_0("Use globalPosition()" ) |
| 160 | QPointF screenPos() const { return globalPosition(); } |
| 161 | QT_DEPRECATED_VERSION_X_6_0("Use globalPressPosition()" ) |
| 162 | QPointF startScreenPos() const { return globalPressPosition(); } |
| 163 | QT_DEPRECATED_VERSION_X_6_0("Use globalPressPosition()" ) |
| 164 | QPointF startNormalizedPos() const; |
| 165 | QT_DEPRECATED_VERSION_X_6_0("Use globalPosition()" ) |
| 166 | QPointF normalizedPos() const; |
| 167 | QT_DEPRECATED_VERSION_X_6_0("Use lastPosition()" ) |
| 168 | QPointF lastPos() const { return lastPosition(); } |
| 169 | QT_DEPRECATED_VERSION_X_6_0("Use sceneLastPosition()" ) |
| 170 | QPointF lastScenePos() const { return sceneLastPosition(); } |
| 171 | QT_DEPRECATED_VERSION_X_6_0("Use globalLastPosition()" ) |
| 172 | QPointF lastScreenPos() const { return globalLastPosition(); } |
| 173 | QT_DEPRECATED_VERSION_X_6_0("Use globalLastPosition()" ) |
| 174 | QPointF lastNormalizedPos() const; |
| 175 | #endif // QT_DEPRECATED_SINCE(6, 0) |
| 176 | QVector2D velocity() const; |
| 177 | State state() const; |
| 178 | const QPointingDevice *device() const; |
| 179 | int id() const; |
| 180 | QPointingDeviceUniqueId uniqueId() const; |
| 181 | ulong timestamp() const; |
| 182 | ulong lastTimestamp() const; |
| 183 | ulong pressTimestamp() const; |
| 184 | qreal timeHeld() const; |
| 185 | qreal pressure() const; |
| 186 | qreal rotation() const; |
| 187 | QSizeF ellipseDiameters() const; |
| 188 | |
| 189 | bool isAccepted() const; |
| 190 | void setAccepted(bool accepted = true); |
| 191 | |
| 192 | private: |
| 193 | QEventPointPrivate *d; |
| 194 | friend class QMutableEventPoint; |
| 195 | friend class QPointerEvent; |
| 196 | }; |
| 197 | |
| 198 | #ifndef QT_NO_DEBUG_STREAM |
| 199 | Q_GUI_EXPORT QDebug operator<<(QDebug, const QEventPoint *); |
| 200 | Q_GUI_EXPORT QDebug operator<<(QDebug, const QEventPoint &); |
| 201 | #endif |
| 202 | |
| 203 | class Q_GUI_EXPORT QPointerEvent : public QInputEvent |
| 204 | { |
| 205 | public: |
| 206 | explicit QPointerEvent(Type type, const QPointingDevice *dev, |
| 207 | Qt::KeyboardModifiers modifiers = Qt::NoModifier, const QList<QEventPoint> &points = {}); |
| 208 | virtual ~QPointerEvent(); |
| 209 | const QPointingDevice *pointingDevice() const; |
| 210 | QPointingDevice::PointerType pointerType() const { |
| 211 | return pointingDevice() ? pointingDevice()->pointerType() : QPointingDevice::PointerType::Unknown; |
| 212 | } |
| 213 | void setTimestamp(ulong timestamp) override; |
| 214 | qsizetype pointCount() const { return m_points.count(); } |
| 215 | QEventPoint &point(qsizetype i) { return m_points[i]; } |
| 216 | const QList<QEventPoint> &points() const { return m_points; } |
| 217 | QEventPoint *pointById(int id); |
| 218 | bool allPointsGrabbed() const; |
| 219 | virtual bool isBeginEvent() const { return false; } |
| 220 | virtual bool isUpdateEvent() const { return false; } |
| 221 | virtual bool isEndEvent() const { return false; } |
| 222 | bool allPointsAccepted() const; |
| 223 | virtual void setAccepted(bool accepted) override; |
| 224 | QObject *exclusiveGrabber(const QEventPoint &point) const; |
| 225 | void setExclusiveGrabber(const QEventPoint &point, QObject *exclusiveGrabber); |
| 226 | QList<QPointer <QObject>> passiveGrabbers(const QEventPoint &point) const; |
| 227 | void clearPassiveGrabbers(const QEventPoint &point); |
| 228 | bool addPassiveGrabber(const QEventPoint &point, QObject *grabber); |
| 229 | bool removePassiveGrabber(const QEventPoint &point, QObject *grabber); |
| 230 | |
| 231 | protected: |
| 232 | QList<QEventPoint> m_points; |
| 233 | }; |
| 234 | |
| 235 | class Q_GUI_EXPORT QSinglePointEvent : public QPointerEvent |
| 236 | { |
| 237 | Q_GADGET |
| 238 | Q_PROPERTY(QObject *exclusivePointGrabber READ exclusivePointGrabber WRITE setExclusivePointGrabber) |
| 239 | |
| 240 | public: |
| 241 | QSinglePointEvent(Type type, const QPointingDevice *dev, const QPointF &localPos, |
| 242 | const QPointF &scenePos, const QPointF &globalPos, |
| 243 | Qt::MouseButton button = Qt::NoButton, Qt::MouseButtons buttons = Qt::NoButton, |
| 244 | Qt::KeyboardModifiers modifiers = Qt::NoModifier); |
| 245 | |
| 246 | inline Qt::MouseButton button() const { return m_button; } |
| 247 | inline Qt::MouseButtons buttons() const { return m_mouseState; } |
| 248 | |
| 249 | inline QPointF position() const |
| 250 | { Q_ASSERT(!m_points.isEmpty()); return m_points.first().position(); } |
| 251 | inline QPointF scenePosition() const |
| 252 | { Q_ASSERT(!m_points.isEmpty()); return m_points.first().scenePosition(); } |
| 253 | inline QPointF globalPosition() const |
| 254 | { Q_ASSERT(!m_points.isEmpty()); return m_points.first().globalPosition(); } |
| 255 | |
| 256 | bool isBeginEvent() const override; |
| 257 | bool isUpdateEvent() const override; |
| 258 | bool isEndEvent() const override; |
| 259 | |
| 260 | QObject *exclusivePointGrabber() const |
| 261 | { return QPointerEvent::exclusiveGrabber(points().first()); } |
| 262 | void setExclusivePointGrabber(QObject *exclusiveGrabber) |
| 263 | { QPointerEvent::setExclusiveGrabber(points().first(), exclusiveGrabber); } |
| 264 | |
| 265 | protected: |
| 266 | QSinglePointEvent(Type type, const QPointingDevice *dev, const QEventPoint &point, |
| 267 | Qt::MouseButton button, Qt::MouseButtons buttons, |
| 268 | Qt::KeyboardModifiers modifiers, Qt::MouseEventSource source); |
| 269 | |
| 270 | Qt::MouseButton m_button = Qt::NoButton; |
| 271 | Qt::MouseButtons m_mouseState = Qt::NoButton; |
| 272 | quint32 m_source : 8; // actually Qt::MouseEventSource |
| 273 | quint32 m_doubleClick : 1; |
| 274 | quint32 m_reserved : 7; // subclasses dovetail their flags, so we don't reserve all 32 bits here |
| 275 | }; |
| 276 | |
| 277 | class Q_GUI_EXPORT QEnterEvent : public QSinglePointEvent |
| 278 | { |
| 279 | public: |
| 280 | QEnterEvent(const QPointF &localPos, const QPointF &scenePos, const QPointF &globalPos, |
| 281 | const QPointingDevice *device = QPointingDevice::primaryPointingDevice()); |
| 282 | ~QEnterEvent(); |
| 283 | |
| 284 | #if QT_DEPRECATED_SINCE(6, 0) |
| 285 | #ifndef QT_NO_INTEGER_EVENT_COORDINATES |
| 286 | QT_DEPRECATED_VERSION_X_6_0("Use position()" ) |
| 287 | inline QPoint pos() const { return position().toPoint(); } |
| 288 | QT_DEPRECATED_VERSION_X_6_0("Use globalPosition()" ) |
| 289 | inline QPoint globalPos() const { return globalPosition().toPoint(); } |
| 290 | QT_DEPRECATED_VERSION_X_6_0("Use position()" ) |
| 291 | inline int x() const { return qRound(position().x()); } |
| 292 | QT_DEPRECATED_VERSION_X_6_0("Use position()" ) |
| 293 | inline int y() const { return qRound(position().y()); } |
| 294 | QT_DEPRECATED_VERSION_X_6_0("Use globalPosition()" ) |
| 295 | inline int globalX() const { return qRound(globalPosition().x()); } |
| 296 | QT_DEPRECATED_VERSION_X_6_0("Use globalPosition()" ) |
| 297 | inline int globalY() const { return qRound(globalPosition().y()); } |
| 298 | #endif |
| 299 | QT_DEPRECATED_VERSION_X_6_0("Use position()" ) |
| 300 | QPointF localPos() const { return position(); } |
| 301 | QT_DEPRECATED_VERSION_X_6_0("Use scenePosition()" ) |
| 302 | QPointF windowPos() const { return scenePosition(); } |
| 303 | QT_DEPRECATED_VERSION_X_6_0("Use globalPosition()" ) |
| 304 | QPointF screenPos() const { return globalPosition(); } |
| 305 | #endif // QT_DEPRECATED_SINCE(6, 0) |
| 306 | }; |
| 307 | |
| 308 | class Q_GUI_EXPORT QMouseEvent : public QSinglePointEvent |
| 309 | { |
| 310 | public: |
| 311 | QMouseEvent(Type type, const QPointF &localPos, Qt::MouseButton button, |
| 312 | Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, |
| 313 | const QPointingDevice *device = QPointingDevice::primaryPointingDevice()); |
| 314 | QMouseEvent(Type type, const QPointF &localPos, const QPointF &globalPos, |
| 315 | Qt::MouseButton button, Qt::MouseButtons buttons, |
| 316 | Qt::KeyboardModifiers modifiers, |
| 317 | const QPointingDevice *device = QPointingDevice::primaryPointingDevice()); |
| 318 | QMouseEvent(Type type, const QPointF &localPos, const QPointF &scenePos, const QPointF &globalPos, |
| 319 | Qt::MouseButton button, Qt::MouseButtons buttons, |
| 320 | Qt::KeyboardModifiers modifiers, |
| 321 | const QPointingDevice *device = QPointingDevice::primaryPointingDevice()); |
| 322 | QMouseEvent(Type type, const QPointF &localPos, const QPointF &scenePos, const QPointF &globalPos, |
| 323 | Qt::MouseButton button, Qt::MouseButtons buttons, |
| 324 | Qt::KeyboardModifiers modifiers, Qt::MouseEventSource source, |
| 325 | const QPointingDevice *device = QPointingDevice::primaryPointingDevice()); |
| 326 | ~QMouseEvent(); |
| 327 | |
| 328 | #ifndef QT_NO_INTEGER_EVENT_COORDINATES |
| 329 | inline QPoint pos() const { return position().toPoint(); } |
| 330 | #endif |
| 331 | #if QT_DEPRECATED_SINCE(6, 0) |
| 332 | #ifndef QT_NO_INTEGER_EVENT_COORDINATES |
| 333 | QT_DEPRECATED_VERSION_X_6_0("Use globalPosition()" ) |
| 334 | inline QPoint globalPos() const { return globalPosition().toPoint(); } |
| 335 | QT_DEPRECATED_VERSION_X_6_0("Use position()" ) |
| 336 | inline int x() const { return qRound(position().x()); } |
| 337 | QT_DEPRECATED_VERSION_X_6_0("Use position()" ) |
| 338 | inline int y() const { return qRound(position().y()); } |
| 339 | QT_DEPRECATED_VERSION_X_6_0("Use globalPosition()" ) |
| 340 | inline int globalX() const { return qRound(globalPosition().x()); } |
| 341 | QT_DEPRECATED_VERSION_X_6_0("Use globalPosition()" ) |
| 342 | inline int globalY() const { return qRound(globalPosition().y()); } |
| 343 | #endif // QT_NO_INTEGER_EVENT_COORDINATES |
| 344 | QT_DEPRECATED_VERSION_X_6_0("Use position()" ) |
| 345 | QPointF localPos() const { return position(); } |
| 346 | QT_DEPRECATED_VERSION_X_6_0("Use scenePosition()" ) |
| 347 | QPointF windowPos() const { return scenePosition(); } |
| 348 | QT_DEPRECATED_VERSION_X_6_0("Use globalPosition()" ) |
| 349 | QPointF screenPos() const { return globalPosition(); } |
| 350 | Qt::MouseEventSource source() const; |
| 351 | Qt::MouseEventFlags flags() const; |
| 352 | #endif // QT_DEPRECATED_SINCE(6, 0) |
| 353 | }; |
| 354 | |
| 355 | class Q_GUI_EXPORT QHoverEvent : public QSinglePointEvent |
| 356 | { |
| 357 | public: |
| 358 | QHoverEvent(Type type, const QPointF &pos, const QPointF &oldPos, |
| 359 | Qt::KeyboardModifiers modifiers = Qt::NoModifier, |
| 360 | const QPointingDevice *device = QPointingDevice::primaryPointingDevice()); |
| 361 | ~QHoverEvent(); |
| 362 | |
| 363 | #if QT_DEPRECATED_SINCE(6, 0) |
| 364 | #ifndef QT_NO_INTEGER_EVENT_COORDINATES |
| 365 | QT_DEPRECATED_VERSION_X_6_0("Use position()" ) |
| 366 | inline QPoint pos() const { return position().toPoint(); } |
| 367 | #endif |
| 368 | |
| 369 | QT_DEPRECATED_VERSION_X_6_0("Use position()" ) |
| 370 | inline QPointF posF() const { return position(); } |
| 371 | #endif // QT_DEPRECATED_SINCE(6, 0) |
| 372 | |
| 373 | bool isUpdateEvent() const override { return true; } |
| 374 | |
| 375 | // TODO deprecate when we figure out an actual replacement (point history?) |
| 376 | inline QPoint oldPos() const { return m_oldPos.toPoint(); } |
| 377 | inline QPointF oldPosF() const { return m_oldPos; } |
| 378 | |
| 379 | protected: |
| 380 | quint32 m_reserved : 16; |
| 381 | QPointF m_oldPos; // TODO remove? |
| 382 | }; |
| 383 | |
| 384 | #if QT_CONFIG(wheelevent) |
| 385 | class Q_GUI_EXPORT QWheelEvent : public QSinglePointEvent |
| 386 | { |
| 387 | Q_GADGET |
| 388 | Q_PROPERTY(const QPointingDevice *device READ pointingDevice) |
| 389 | Q_PROPERTY(QPoint pixelDelta READ pixelDelta) |
| 390 | Q_PROPERTY(QPoint angleDelta READ angleDelta) |
| 391 | Q_PROPERTY(Qt::ScrollPhase phase READ phase) |
| 392 | Q_PROPERTY(bool inverted READ inverted) |
| 393 | public: |
| 394 | enum { DefaultDeltasPerStep = 120 }; |
| 395 | |
| 396 | QWheelEvent(const QPointF &pos, const QPointF &globalPos, QPoint pixelDelta, QPoint angleDelta, |
| 397 | Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Qt::ScrollPhase phase, |
| 398 | bool inverted, Qt::MouseEventSource source = Qt::MouseEventNotSynthesized, |
| 399 | const QPointingDevice *device = QPointingDevice::primaryPointingDevice()); |
| 400 | ~QWheelEvent(); |
| 401 | |
| 402 | inline QPoint pixelDelta() const { return m_pixelDelta; } |
| 403 | inline QPoint angleDelta() const { return m_angleDelta; } |
| 404 | |
| 405 | inline Qt::ScrollPhase phase() const { return Qt::ScrollPhase(m_phase); } |
| 406 | inline bool inverted() const { return m_invertedScrolling; } |
| 407 | inline bool isInverted() const { return m_invertedScrolling; } |
| 408 | inline bool hasPixelDelta() const { return !m_pixelDelta.isNull(); } |
| 409 | |
| 410 | bool isBeginEvent() const override; |
| 411 | bool isUpdateEvent() const override; |
| 412 | bool isEndEvent() const override; |
| 413 | Qt::MouseEventSource source() const { return Qt::MouseEventSource(m_source); } |
| 414 | |
| 415 | protected: |
| 416 | quint32 m_phase : 3; |
| 417 | quint32 m_invertedScrolling : 1; |
| 418 | quint32 m_reserved : 12; |
| 419 | QPoint m_pixelDelta; |
| 420 | QPoint m_angleDelta; |
| 421 | }; |
| 422 | #endif |
| 423 | |
| 424 | #if QT_CONFIG(tabletevent) |
| 425 | class Q_GUI_EXPORT QTabletEvent : public QSinglePointEvent |
| 426 | { |
| 427 | public: |
| 428 | QTabletEvent(Type t, const QPointingDevice *device, |
| 429 | const QPointF &pos, const QPointF &globalPos, |
| 430 | qreal pressure, int xTilt, int yTilt, |
| 431 | qreal tangentialPressure, qreal rotation, int z, |
| 432 | Qt::KeyboardModifiers keyState, |
| 433 | Qt::MouseButton button, Qt::MouseButtons buttons); |
| 434 | ~QTabletEvent(); |
| 435 | |
| 436 | #if QT_DEPRECATED_SINCE(6, 0) |
| 437 | QT_DEPRECATED_VERSION_X_6_0("Use position()" ) |
| 438 | inline QPoint pos() const { return position().toPoint(); } |
| 439 | QT_DEPRECATED_VERSION_X_6_0("Use globalPosition()" ) |
| 440 | inline QPoint globalPos() const { return globalPosition().toPoint(); } |
| 441 | |
| 442 | QT_DEPRECATED_VERSION_X_6_0("Use position()" ) |
| 443 | inline const QPointF posF() const { return position(); } |
| 444 | QT_DEPRECATED_VERSION_X_6_0("Use globalPosition()" ) |
| 445 | inline const QPointF globalPosF() const { return globalPosition(); } |
| 446 | QT_DEPRECATED_VERSION_X_6_0("Use position().x()" ) |
| 447 | inline int x() const { return qRound(position().x()); } |
| 448 | QT_DEPRECATED_VERSION_X_6_0("Use position().y()" ) |
| 449 | inline int y() const { return qRound(position().y()); } |
| 450 | QT_DEPRECATED_VERSION_X_6_0("Use globalPosition().x()" ) |
| 451 | inline int globalX() const { return qRound(globalPosition().x()); } |
| 452 | QT_DEPRECATED_VERSION_X_6_0("Use globalPosition().y()" ) |
| 453 | inline int globalY() const { return qRound(globalPosition().y()); } |
| 454 | QT_DEPRECATED_VERSION_X_6_0("use globalPosition().x()" ) |
| 455 | inline qreal hiResGlobalX() const { return globalPosition().x(); } |
| 456 | QT_DEPRECATED_VERSION_X_6_0("use globalPosition().y()" ) |
| 457 | inline qreal hiResGlobalY() const { return globalPosition().y(); } |
| 458 | QT_DEPRECATED_VERSION_X_6_0("use pointingDevice().uniqueId()" ) |
| 459 | inline qint64 uniqueId() const { return pointingDevice() ? pointingDevice()->uniqueId().numericId() : -1; } |
| 460 | #endif |
| 461 | inline qreal pressure() const { Q_ASSERT(!points().isEmpty()); return points().first().pressure(); } |
| 462 | inline qreal rotation() const { Q_ASSERT(!points().isEmpty()); return points().first().rotation(); } |
| 463 | inline int z() const { return m_z; } |
| 464 | inline qreal tangentialPressure() const { return m_tangential; } |
| 465 | inline int xTilt() const { return m_xTilt; } |
| 466 | inline int yTilt() const { return m_yTilt; } |
| 467 | |
| 468 | protected: |
| 469 | quint32 m_reserved : 16; |
| 470 | int m_xTilt, m_yTilt, m_z; |
| 471 | qreal m_tangential; |
| 472 | }; |
| 473 | #endif // QT_CONFIG(tabletevent) |
| 474 | |
| 475 | #if QT_CONFIG(gestures) |
| 476 | class Q_GUI_EXPORT QNativeGestureEvent : public QSinglePointEvent |
| 477 | { |
| 478 | public: |
| 479 | QNativeGestureEvent(Qt::NativeGestureType type, const QPointingDevice *dev, const QPointF &localPos, const QPointF &scenePos, |
| 480 | const QPointF &globalPos, qreal value, ulong sequenceId, quint64 intArgument); |
| 481 | ~QNativeGestureEvent(); |
| 482 | Qt::NativeGestureType gestureType() const { return Qt::NativeGestureType(m_gestureType); } |
| 483 | qreal value() const { return m_realValue; } |
| 484 | |
| 485 | #if QT_DEPRECATED_SINCE(6, 0) |
| 486 | #ifndef QT_NO_INTEGER_EVENT_COORDINATES |
| 487 | QT_DEPRECATED_VERSION_X_6_0("Use position().toPoint()" ) |
| 488 | inline const QPoint pos() const { return position().toPoint(); } |
| 489 | QT_DEPRECATED_VERSION_X_6_0("Use globalPosition().toPoint()" ) |
| 490 | inline const QPoint globalPos() const { return globalPosition().toPoint(); } |
| 491 | #endif |
| 492 | QT_DEPRECATED_VERSION_X_6_0("Use position()" ) |
| 493 | QPointF localPos() const { return position(); } |
| 494 | QT_DEPRECATED_VERSION_X_6_0("Use scenePosition()" ) |
| 495 | QPointF windowPos() const { return scenePosition(); } |
| 496 | QT_DEPRECATED_VERSION_X_6_0("Use globalPosition()" ) |
| 497 | QPointF screenPos() const { return globalPosition(); } |
| 498 | #endif |
| 499 | |
| 500 | protected: |
| 501 | quint32 m_gestureType : 4; |
| 502 | quint32 m_reserved : 12; |
| 503 | qreal m_realValue; |
| 504 | ulong m_sequenceId; |
| 505 | quint64 m_intValue; |
| 506 | }; |
| 507 | #endif // QT_CONFIG(gestures) |
| 508 | |
| 509 | class Q_GUI_EXPORT QKeyEvent : public QInputEvent |
| 510 | { |
| 511 | public: |
| 512 | QKeyEvent(Type type, int key, Qt::KeyboardModifiers modifiers, const QString& text = QString(), |
| 513 | bool autorep = false, ushort count = 1); |
| 514 | QKeyEvent(Type type, int key, Qt::KeyboardModifiers modifiers, |
| 515 | quint32 nativeScanCode, quint32 nativeVirtualKey, quint32 nativeModifiers, |
| 516 | const QString &text = QString(), bool autorep = false, ushort count = 1, |
| 517 | const QInputDevice *device = QInputDevice::primaryKeyboard()); |
| 518 | ~QKeyEvent(); |
| 519 | |
| 520 | int key() const { return m_key; } |
| 521 | #if QT_CONFIG(shortcut) |
| 522 | bool matches(QKeySequence::StandardKey key) const; |
| 523 | #endif |
| 524 | Qt::KeyboardModifiers modifiers() const; |
| 525 | QKeyCombination keyCombination() const |
| 526 | { |
| 527 | return QKeyCombination(modifiers(), Qt::Key(m_key)); |
| 528 | } |
| 529 | inline QString text() const { return m_text; } |
| 530 | inline bool isAutoRepeat() const { return m_autoRepeat; } |
| 531 | inline int count() const { return int(m_count); } |
| 532 | |
| 533 | inline quint32 nativeScanCode() const { return m_scanCode; } |
| 534 | inline quint32 nativeVirtualKey() const { return m_virtualKey; } |
| 535 | inline quint32 nativeModifiers() const { return m_modifiers; } |
| 536 | |
| 537 | protected: |
| 538 | QString m_text; |
| 539 | int m_key; |
| 540 | quint32 m_scanCode; |
| 541 | quint32 m_virtualKey; |
| 542 | quint32 m_modifiers; |
| 543 | ushort m_count; |
| 544 | ushort m_autoRepeat:1; |
| 545 | // ushort reserved:15; |
| 546 | }; |
| 547 | |
| 548 | |
| 549 | class Q_GUI_EXPORT QFocusEvent : public QEvent |
| 550 | { |
| 551 | public: |
| 552 | explicit QFocusEvent(Type type, Qt::FocusReason reason=Qt::OtherFocusReason); |
| 553 | ~QFocusEvent(); |
| 554 | |
| 555 | inline bool gotFocus() const { return type() == FocusIn; } |
| 556 | inline bool lostFocus() const { return type() == FocusOut; } |
| 557 | |
| 558 | Qt::FocusReason reason() const; |
| 559 | |
| 560 | private: |
| 561 | Qt::FocusReason m_reason; |
| 562 | }; |
| 563 | |
| 564 | |
| 565 | class Q_GUI_EXPORT QPaintEvent : public QEvent |
| 566 | { |
| 567 | public: |
| 568 | explicit QPaintEvent(const QRegion& paintRegion); |
| 569 | explicit QPaintEvent(const QRect &paintRect); |
| 570 | ~QPaintEvent(); |
| 571 | |
| 572 | inline const QRect &rect() const { return m_rect; } |
| 573 | inline const QRegion ®ion() const { return m_region; } |
| 574 | |
| 575 | protected: |
| 576 | QRect m_rect; |
| 577 | QRegion m_region; |
| 578 | bool m_erased; |
| 579 | }; |
| 580 | |
| 581 | class Q_GUI_EXPORT QMoveEvent : public QEvent |
| 582 | { |
| 583 | public: |
| 584 | QMoveEvent(const QPoint &pos, const QPoint &oldPos); |
| 585 | ~QMoveEvent(); |
| 586 | |
| 587 | inline const QPoint &pos() const { return m_pos; } |
| 588 | inline const QPoint &oldPos() const { return m_oldPos;} |
| 589 | protected: |
| 590 | QPoint m_pos, m_oldPos; |
| 591 | friend class QApplication; |
| 592 | }; |
| 593 | |
| 594 | class Q_GUI_EXPORT QExposeEvent : public QEvent |
| 595 | { |
| 596 | public: |
| 597 | explicit QExposeEvent(const QRegion &m_region); |
| 598 | ~QExposeEvent(); |
| 599 | |
| 600 | #if QT_DEPRECATED_SINCE(6, 0) |
| 601 | QT_DEPRECATED_VERSION_X_6_0("Handle QPaintEvent instead" ) |
| 602 | inline const QRegion ®ion() const { return m_region; } |
| 603 | #endif |
| 604 | |
| 605 | protected: |
| 606 | QRegion m_region; |
| 607 | }; |
| 608 | |
| 609 | class Q_GUI_EXPORT QPlatformSurfaceEvent : public QEvent |
| 610 | { |
| 611 | public: |
| 612 | enum SurfaceEventType { |
| 613 | SurfaceCreated, |
| 614 | SurfaceAboutToBeDestroyed |
| 615 | }; |
| 616 | |
| 617 | explicit QPlatformSurfaceEvent(SurfaceEventType surfaceEventType); |
| 618 | ~QPlatformSurfaceEvent(); |
| 619 | |
| 620 | inline SurfaceEventType surfaceEventType() const { return m_surfaceEventType; } |
| 621 | |
| 622 | protected: |
| 623 | SurfaceEventType m_surfaceEventType; |
| 624 | }; |
| 625 | |
| 626 | class Q_GUI_EXPORT QResizeEvent : public QEvent |
| 627 | { |
| 628 | public: |
| 629 | QResizeEvent(const QSize &size, const QSize &oldSize); |
| 630 | ~QResizeEvent(); |
| 631 | |
| 632 | inline const QSize &size() const { return m_size; } |
| 633 | inline const QSize &oldSize()const { return m_oldSize;} |
| 634 | protected: |
| 635 | QSize m_size, m_oldSize; |
| 636 | friend class QApplication; |
| 637 | }; |
| 638 | |
| 639 | |
| 640 | class Q_GUI_EXPORT QCloseEvent : public QEvent |
| 641 | { |
| 642 | public: |
| 643 | QCloseEvent(); |
| 644 | ~QCloseEvent(); |
| 645 | }; |
| 646 | |
| 647 | |
| 648 | class Q_GUI_EXPORT QIconDragEvent : public QEvent |
| 649 | { |
| 650 | public: |
| 651 | QIconDragEvent(); |
| 652 | ~QIconDragEvent(); |
| 653 | }; |
| 654 | |
| 655 | |
| 656 | class Q_GUI_EXPORT QShowEvent : public QEvent |
| 657 | { |
| 658 | public: |
| 659 | QShowEvent(); |
| 660 | ~QShowEvent(); |
| 661 | }; |
| 662 | |
| 663 | |
| 664 | class Q_GUI_EXPORT QHideEvent : public QEvent |
| 665 | { |
| 666 | public: |
| 667 | QHideEvent(); |
| 668 | ~QHideEvent(); |
| 669 | }; |
| 670 | |
| 671 | #ifndef QT_NO_CONTEXTMENU |
| 672 | class Q_GUI_EXPORT : public QInputEvent |
| 673 | { |
| 674 | public: |
| 675 | enum { , , }; |
| 676 | |
| 677 | (Reason reason, const QPoint &pos, const QPoint &globalPos, |
| 678 | Qt::KeyboardModifiers modifiers); |
| 679 | (Reason reason, const QPoint &pos, const QPoint &globalPos); |
| 680 | (Reason reason, const QPoint &pos); |
| 681 | (); |
| 682 | |
| 683 | inline int () const { return m_pos.x(); } |
| 684 | inline int () const { return m_pos.y(); } |
| 685 | inline int () const { return m_globalPos.x(); } |
| 686 | inline int () const { return m_globalPos.y(); } |
| 687 | |
| 688 | inline const QPoint& () const { return m_pos; } |
| 689 | inline const QPoint& () const { return m_globalPos; } |
| 690 | |
| 691 | inline Reason () const { return Reason(m_reason); } |
| 692 | |
| 693 | protected: |
| 694 | QPoint ; |
| 695 | QPoint ; |
| 696 | uint : 8; |
| 697 | }; |
| 698 | #endif // QT_NO_CONTEXTMENU |
| 699 | |
| 700 | #ifndef QT_NO_INPUTMETHOD |
| 701 | class Q_GUI_EXPORT QInputMethodEvent : public QEvent |
| 702 | { |
| 703 | public: |
| 704 | enum AttributeType { |
| 705 | TextFormat, |
| 706 | Cursor, |
| 707 | Language, |
| 708 | Ruby, |
| 709 | Selection |
| 710 | }; |
| 711 | class Attribute { |
| 712 | public: |
| 713 | Attribute(AttributeType typ, int s, int l, QVariant val) : type(typ), start(s), length(l), value(std::move(val)) {} |
| 714 | Attribute(AttributeType typ, int s, int l) : type(typ), start(s), length(l), value() {} |
| 715 | |
| 716 | AttributeType type; |
| 717 | int start; |
| 718 | int length; |
| 719 | QVariant value; |
| 720 | }; |
| 721 | QInputMethodEvent(); |
| 722 | QInputMethodEvent(const QString &preeditText, const QList<Attribute> &attributes); |
| 723 | ~QInputMethodEvent(); |
| 724 | |
| 725 | void setCommitString(const QString &commitString, int replaceFrom = 0, int replaceLength = 0); |
| 726 | inline const QList<Attribute> &attributes() const { return m_attributes; } |
| 727 | inline const QString &preeditString() const { return m_preedit; } |
| 728 | |
| 729 | inline const QString &commitString() const { return m_commit; } |
| 730 | inline int replacementStart() const { return m_replacementStart; } |
| 731 | inline int replacementLength() const { return m_replacementLength; } |
| 732 | |
| 733 | QInputMethodEvent(const QInputMethodEvent &other); |
| 734 | |
| 735 | inline friend bool operator==(const QInputMethodEvent::Attribute &lhs, |
| 736 | const QInputMethodEvent::Attribute &rhs) |
| 737 | { |
| 738 | return lhs.type == rhs.type && lhs.start == rhs.start |
| 739 | && lhs.length == rhs.length && lhs.value == rhs.value; |
| 740 | } |
| 741 | |
| 742 | inline friend bool operator!=(const QInputMethodEvent::Attribute &lhs, |
| 743 | const QInputMethodEvent::Attribute &rhs) |
| 744 | { |
| 745 | return !(lhs == rhs); |
| 746 | } |
| 747 | |
| 748 | private: |
| 749 | QString m_preedit; |
| 750 | QList<Attribute> m_attributes; |
| 751 | QString m_commit; |
| 752 | int m_replacementStart; |
| 753 | int m_replacementLength; |
| 754 | }; |
| 755 | Q_DECLARE_TYPEINFO(QInputMethodEvent::Attribute, Q_MOVABLE_TYPE); |
| 756 | |
| 757 | class Q_GUI_EXPORT QInputMethodQueryEvent : public QEvent |
| 758 | { |
| 759 | public: |
| 760 | explicit QInputMethodQueryEvent(Qt::InputMethodQueries queries); |
| 761 | ~QInputMethodQueryEvent(); |
| 762 | |
| 763 | Qt::InputMethodQueries queries() const { return m_queries; } |
| 764 | |
| 765 | void setValue(Qt::InputMethodQuery query, const QVariant &value); |
| 766 | QVariant value(Qt::InputMethodQuery query) const; |
| 767 | private: |
| 768 | Qt::InputMethodQueries m_queries; |
| 769 | struct QueryPair { |
| 770 | Qt::InputMethodQuery query; |
| 771 | QVariant value; |
| 772 | }; |
| 773 | friend QTypeInfo<QueryPair>; |
| 774 | QList<QueryPair> m_values; |
| 775 | }; |
| 776 | Q_DECLARE_TYPEINFO(QInputMethodQueryEvent::QueryPair, Q_MOVABLE_TYPE); |
| 777 | |
| 778 | #endif // QT_NO_INPUTMETHOD |
| 779 | |
| 780 | #if QT_CONFIG(draganddrop) |
| 781 | |
| 782 | class QMimeData; |
| 783 | |
| 784 | class Q_GUI_EXPORT QDropEvent : public QEvent |
| 785 | { |
| 786 | public: |
| 787 | QDropEvent(const QPointF& pos, Qt::DropActions actions, const QMimeData *data, |
| 788 | Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Type type = Drop); |
| 789 | ~QDropEvent(); |
| 790 | |
| 791 | #if QT_DEPRECATED_SINCE(6, 0) |
| 792 | QT_DEPRECATED_VERSION_X_6_0("Use position().toPoint()" ) |
| 793 | inline QPoint pos() const { return position().toPoint(); } |
| 794 | QT_DEPRECATED_VERSION_X_6_0("Use position()" ) |
| 795 | inline QPointF posF() const { return position(); } |
| 796 | QT_DEPRECATED_VERSION_X_6_0("Use buttons()" ) |
| 797 | inline Qt::MouseButtons mouseButtons() const { return buttons(); } |
| 798 | QT_DEPRECATED_VERSION_X_6_0("Use modifiers()" ) |
| 799 | inline Qt::KeyboardModifiers keyboardModifiers() const { return modifiers(); } |
| 800 | #endif // QT_DEPRECATED_SINCE(6, 0) |
| 801 | |
| 802 | QPointF position() const { return m_pos; } |
| 803 | inline Qt::MouseButtons buttons() const { return m_mouseState; } |
| 804 | inline Qt::KeyboardModifiers modifiers() const { return m_modState; } |
| 805 | |
| 806 | inline Qt::DropActions possibleActions() const { return m_actions; } |
| 807 | inline Qt::DropAction proposedAction() const { return m_defaultAction; } |
| 808 | inline void acceptProposedAction() { m_dropAction = m_defaultAction; accept(); } |
| 809 | |
| 810 | inline Qt::DropAction dropAction() const { return m_dropAction; } |
| 811 | void setDropAction(Qt::DropAction action); |
| 812 | |
| 813 | QObject* source() const; |
| 814 | inline const QMimeData *mimeData() const { return m_data; } |
| 815 | |
| 816 | protected: |
| 817 | friend class QApplication; |
| 818 | QPointF m_pos; |
| 819 | Qt::MouseButtons m_mouseState; |
| 820 | Qt::KeyboardModifiers m_modState; |
| 821 | Qt::DropActions m_actions; |
| 822 | Qt::DropAction m_dropAction; |
| 823 | Qt::DropAction m_defaultAction; |
| 824 | const QMimeData *m_data; |
| 825 | }; |
| 826 | |
| 827 | |
| 828 | class Q_GUI_EXPORT QDragMoveEvent : public QDropEvent |
| 829 | { |
| 830 | public: |
| 831 | QDragMoveEvent(const QPoint &pos, Qt::DropActions actions, const QMimeData *data, |
| 832 | Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Type type = DragMove); |
| 833 | ~QDragMoveEvent(); |
| 834 | |
| 835 | inline QRect answerRect() const { return m_rect; } |
| 836 | |
| 837 | inline void accept() { QDropEvent::accept(); } |
| 838 | inline void ignore() { QDropEvent::ignore(); } |
| 839 | |
| 840 | inline void accept(const QRect & r) { accept(); m_rect = r; } |
| 841 | inline void ignore(const QRect & r) { ignore(); m_rect = r; } |
| 842 | |
| 843 | protected: |
| 844 | QRect m_rect; |
| 845 | }; |
| 846 | |
| 847 | |
| 848 | class Q_GUI_EXPORT QDragEnterEvent : public QDragMoveEvent |
| 849 | { |
| 850 | public: |
| 851 | QDragEnterEvent(const QPoint &pos, Qt::DropActions actions, const QMimeData *data, |
| 852 | Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers); |
| 853 | ~QDragEnterEvent(); |
| 854 | }; |
| 855 | |
| 856 | |
| 857 | class Q_GUI_EXPORT QDragLeaveEvent : public QEvent |
| 858 | { |
| 859 | public: |
| 860 | QDragLeaveEvent(); |
| 861 | ~QDragLeaveEvent(); |
| 862 | }; |
| 863 | #endif // QT_CONFIG(draganddrop) |
| 864 | |
| 865 | |
| 866 | class Q_GUI_EXPORT QHelpEvent : public QEvent |
| 867 | { |
| 868 | public: |
| 869 | QHelpEvent(Type type, const QPoint &pos, const QPoint &globalPos); |
| 870 | ~QHelpEvent(); |
| 871 | |
| 872 | inline int x() const { return m_pos.x(); } |
| 873 | inline int y() const { return m_pos.y(); } |
| 874 | inline int globalX() const { return m_globalPos.x(); } |
| 875 | inline int globalY() const { return m_globalPos.y(); } |
| 876 | |
| 877 | inline const QPoint& pos() const { return m_pos; } |
| 878 | inline const QPoint& globalPos() const { return m_globalPos; } |
| 879 | |
| 880 | private: |
| 881 | QPoint m_pos; |
| 882 | QPoint m_globalPos; |
| 883 | }; |
| 884 | |
| 885 | #ifndef QT_NO_STATUSTIP |
| 886 | class Q_GUI_EXPORT QStatusTipEvent : public QEvent |
| 887 | { |
| 888 | public: |
| 889 | explicit QStatusTipEvent(const QString &tip); |
| 890 | ~QStatusTipEvent(); |
| 891 | |
| 892 | inline QString tip() const { return m_tip; } |
| 893 | private: |
| 894 | QString m_tip; |
| 895 | }; |
| 896 | #endif |
| 897 | |
| 898 | #if QT_CONFIG(whatsthis) |
| 899 | class Q_GUI_EXPORT QWhatsThisClickedEvent : public QEvent |
| 900 | { |
| 901 | public: |
| 902 | explicit QWhatsThisClickedEvent(const QString &href); |
| 903 | ~QWhatsThisClickedEvent(); |
| 904 | |
| 905 | inline QString href() const { return m_href; } |
| 906 | private: |
| 907 | QString m_href; |
| 908 | }; |
| 909 | #endif |
| 910 | |
| 911 | #if QT_CONFIG(action) |
| 912 | class Q_GUI_EXPORT QActionEvent : public QEvent |
| 913 | { |
| 914 | QAction *m_action, *m_before; |
| 915 | public: |
| 916 | QActionEvent(int type, QAction *action, QAction *before = nullptr); |
| 917 | ~QActionEvent(); |
| 918 | |
| 919 | inline QAction *action() const { return m_action; } |
| 920 | inline QAction *before() const { return m_before; } |
| 921 | }; |
| 922 | #endif // QT_CONFIG(action) |
| 923 | |
| 924 | class Q_GUI_EXPORT QFileOpenEvent : public QEvent |
| 925 | { |
| 926 | public: |
| 927 | explicit QFileOpenEvent(const QString &file); |
| 928 | explicit QFileOpenEvent(const QUrl &url); |
| 929 | ~QFileOpenEvent(); |
| 930 | |
| 931 | inline QString file() const { return m_file; } |
| 932 | QUrl url() const { return m_url; } |
| 933 | bool openFile(QFile &file, QIODevice::OpenMode flags) const; |
| 934 | private: |
| 935 | QString m_file; |
| 936 | QUrl m_url; |
| 937 | }; |
| 938 | |
| 939 | #ifndef QT_NO_TOOLBAR |
| 940 | class Q_GUI_EXPORT QToolBarChangeEvent : public QEvent |
| 941 | { |
| 942 | public: |
| 943 | explicit QToolBarChangeEvent(bool t); |
| 944 | ~QToolBarChangeEvent(); |
| 945 | |
| 946 | inline bool toggle() const { return m_toggle; } |
| 947 | private: |
| 948 | uint m_toggle : 1; |
| 949 | }; |
| 950 | #endif |
| 951 | |
| 952 | #if QT_CONFIG(shortcut) |
| 953 | class Q_GUI_EXPORT QShortcutEvent : public QEvent |
| 954 | { |
| 955 | public: |
| 956 | QShortcutEvent(const QKeySequence &key, int id, bool ambiguous = false); |
| 957 | ~QShortcutEvent(); |
| 958 | |
| 959 | inline const QKeySequence &key() const { return m_sequence; } |
| 960 | inline int shortcutId() const { return m_shortcutId; } |
| 961 | inline bool isAmbiguous() const { return m_ambiguous; } |
| 962 | protected: |
| 963 | QKeySequence m_sequence; |
| 964 | bool m_ambiguous; |
| 965 | int m_shortcutId; |
| 966 | }; |
| 967 | #endif |
| 968 | |
| 969 | class Q_GUI_EXPORT QWindowStateChangeEvent: public QEvent |
| 970 | { |
| 971 | public: |
| 972 | explicit QWindowStateChangeEvent(Qt::WindowStates oldState, bool isOverride = false); |
| 973 | ~QWindowStateChangeEvent(); |
| 974 | |
| 975 | inline Qt::WindowStates oldState() const { return m_oldStates; } |
| 976 | bool isOverride() const; |
| 977 | |
| 978 | private: |
| 979 | Qt::WindowStates m_oldStates; |
| 980 | bool m_override; |
| 981 | }; |
| 982 | |
| 983 | #ifndef QT_NO_DEBUG_STREAM |
| 984 | Q_GUI_EXPORT QDebug operator<<(QDebug, const QEvent *); |
| 985 | #endif |
| 986 | |
| 987 | #if QT_CONFIG(shortcut) |
| 988 | inline bool operator==(QKeyEvent *e, QKeySequence::StandardKey key){return (e ? e->matches(key) : false);} |
| 989 | inline bool operator==(QKeySequence::StandardKey key, QKeyEvent *e){return (e ? e->matches(key) : false);} |
| 990 | #endif // QT_CONFIG(shortcut) |
| 991 | |
| 992 | class Q_GUI_EXPORT QTouchEvent : public QPointerEvent |
| 993 | { |
| 994 | public: |
| 995 | using TouchPoint = QEventPoint; // source compat |
| 996 | |
| 997 | explicit QTouchEvent(QEvent::Type eventType, |
| 998 | const QPointingDevice *device = nullptr, |
| 999 | Qt::KeyboardModifiers modifiers = Qt::NoModifier, |
| 1000 | const QList<QEventPoint> &touchPoints = {}); |
| 1001 | #if QT_DEPRECATED_SINCE(6, 0) |
| 1002 | QT_DEPRECATED_VERSION_X_6_0("Use another constructor" ) |
| 1003 | explicit QTouchEvent(QEvent::Type eventType, |
| 1004 | const QPointingDevice *device, |
| 1005 | Qt::KeyboardModifiers modifiers, |
| 1006 | QEventPoint::States touchPointStates, |
| 1007 | const QList<QEventPoint> &touchPoints = {}); |
| 1008 | #endif |
| 1009 | ~QTouchEvent(); |
| 1010 | |
| 1011 | inline QObject *target() const { return m_target; } |
| 1012 | inline QEventPoint::States touchPointStates() const { return m_touchPointStates; } |
| 1013 | #if QT_DEPRECATED_SINCE(6, 0) |
| 1014 | QT_DEPRECATED_VERSION_X_6_0("Use points()" ) |
| 1015 | const QList<QEventPoint> &touchPoints() const { return points(); } |
| 1016 | #endif |
| 1017 | bool isBeginEvent() const override; |
| 1018 | bool isUpdateEvent() const override; |
| 1019 | bool isEndEvent() const override; |
| 1020 | |
| 1021 | protected: |
| 1022 | QObject *m_target = nullptr; |
| 1023 | QEventPoint::States m_touchPointStates = QEventPoint::State::Unknown; |
| 1024 | quint32 m_reserved : 24; |
| 1025 | }; |
| 1026 | |
| 1027 | class Q_GUI_EXPORT QScrollPrepareEvent : public QEvent |
| 1028 | { |
| 1029 | public: |
| 1030 | explicit QScrollPrepareEvent(const QPointF &startPos); |
| 1031 | ~QScrollPrepareEvent(); |
| 1032 | |
| 1033 | QPointF startPos() const; |
| 1034 | |
| 1035 | QSizeF viewportSize() const; |
| 1036 | QRectF contentPosRange() const; |
| 1037 | QPointF contentPos() const; |
| 1038 | |
| 1039 | void setViewportSize(const QSizeF &size); |
| 1040 | void setContentPosRange(const QRectF &rect); |
| 1041 | void setContentPos(const QPointF &pos); |
| 1042 | |
| 1043 | private: |
| 1044 | QPointF m_startPos; |
| 1045 | QSizeF m_viewportSize; |
| 1046 | QRectF m_contentPosRange; |
| 1047 | QPointF m_contentPos; |
| 1048 | }; |
| 1049 | |
| 1050 | |
| 1051 | class Q_GUI_EXPORT QScrollEvent : public QEvent |
| 1052 | { |
| 1053 | public: |
| 1054 | enum ScrollState |
| 1055 | { |
| 1056 | ScrollStarted, |
| 1057 | ScrollUpdated, |
| 1058 | ScrollFinished |
| 1059 | }; |
| 1060 | |
| 1061 | QScrollEvent(const QPointF &contentPos, const QPointF &overshoot, ScrollState scrollState); |
| 1062 | ~QScrollEvent(); |
| 1063 | |
| 1064 | QPointF contentPos() const; |
| 1065 | QPointF overshootDistance() const; |
| 1066 | ScrollState scrollState() const; |
| 1067 | |
| 1068 | private: |
| 1069 | QPointF m_contentPos; |
| 1070 | QPointF m_overshoot; |
| 1071 | QScrollEvent::ScrollState m_state; |
| 1072 | }; |
| 1073 | |
| 1074 | class Q_GUI_EXPORT QScreenOrientationChangeEvent : public QEvent |
| 1075 | { |
| 1076 | public: |
| 1077 | QScreenOrientationChangeEvent(QScreen *screen, Qt::ScreenOrientation orientation); |
| 1078 | ~QScreenOrientationChangeEvent(); |
| 1079 | |
| 1080 | QScreen *screen() const; |
| 1081 | Qt::ScreenOrientation orientation() const; |
| 1082 | |
| 1083 | private: |
| 1084 | QScreen *m_screen; |
| 1085 | Qt::ScreenOrientation m_orientation; |
| 1086 | }; |
| 1087 | |
| 1088 | class Q_GUI_EXPORT QApplicationStateChangeEvent : public QEvent |
| 1089 | { |
| 1090 | public: |
| 1091 | explicit QApplicationStateChangeEvent(Qt::ApplicationState state); |
| 1092 | Qt::ApplicationState applicationState() const; |
| 1093 | |
| 1094 | private: |
| 1095 | Qt::ApplicationState m_applicationState; |
| 1096 | }; |
| 1097 | |
| 1098 | QT_END_NAMESPACE |
| 1099 | |
| 1100 | #endif // QEVENT_H |
| 1101 | |