diff options
Diffstat (limited to 'src/gui/kernel/qevent.cpp')
-rw-r--r-- | src/gui/kernel/qevent.cpp | 125 |
1 files changed, 100 insertions, 25 deletions
diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index 78a4dc4f35..305ce5c82e 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -289,7 +289,7 @@ QMouseEvent::QMouseEvent(Type type, const QPointF &localPos, Qt::MouseButton but QMouseEvent::QMouseEvent(Type type, const QPointF &localPos, const QPointF &screenPos, Qt::MouseButton button, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers) - : QInputEvent(type, modifiers), l(localPos), w(localPos), s(screenPos), b(button), mouseState(buttons), caps(0) + : QMouseEvent(type, localPos, localPos, screenPos, button, buttons, modifiers) {} /*! @@ -342,7 +342,7 @@ QMouseEvent::QMouseEvent(Type type, const QPointF &localPos, const QPointF &wind QMouseEvent::QMouseEvent(QEvent::Type type, const QPointF &localPos, const QPointF &windowPos, const QPointF &screenPos, Qt::MouseButton button, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Qt::MouseEventSource source) - : QInputEvent(type, modifiers), l(localPos), w(windowPos), s(screenPos), b(button), mouseState(buttons), caps(0) + : QMouseEvent(type, localPos, windowPos, screenPos, button, buttons, modifiers) { QGuiApplicationPrivate::setMouseEventSource(this, source); } @@ -829,9 +829,8 @@ QWheelEvent::QWheelEvent(const QPointF &pos, const QPointF& globalPos, int delta QWheelEvent::QWheelEvent(const QPointF &pos, const QPointF& globalPos, QPoint pixelDelta, QPoint angleDelta, int qt4Delta, Qt::Orientation qt4Orientation, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers) - : QInputEvent(Wheel, modifiers), p(pos), g(globalPos), pixelD(pixelDelta), - angleD(angleDelta), qt4D(qt4Delta), qt4O(qt4Orientation), mouseState(buttons), ph(Qt::NoScrollPhase), - src(Qt::MouseEventNotSynthesized), invertedScrolling(false) + : QWheelEvent(pos, globalPos, pixelDelta, angleDelta, qt4Delta, qt4Orientation, + buttons, modifiers, Qt::NoScrollPhase) {} /*! @@ -860,9 +859,8 @@ QWheelEvent::QWheelEvent(const QPointF &pos, const QPointF& globalPos, QWheelEvent::QWheelEvent(const QPointF &pos, const QPointF& globalPos, QPoint pixelDelta, QPoint angleDelta, int qt4Delta, Qt::Orientation qt4Orientation, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Qt::ScrollPhase phase) - : QInputEvent(Wheel, modifiers), p(pos), g(globalPos), pixelD(pixelDelta), - angleD(angleDelta), qt4D(qt4Delta), qt4O(qt4Orientation), mouseState(buttons), ph(phase), - src(Qt::MouseEventNotSynthesized), invertedScrolling(false) + : QWheelEvent(pos, globalPos, pixelDelta, angleDelta, qt4Delta, qt4Orientation, + buttons, modifiers, phase, Qt::MouseEventNotSynthesized) {} /*! @@ -896,9 +894,8 @@ QWheelEvent::QWheelEvent(const QPointF &pos, const QPointF& globalPos, QWheelEvent::QWheelEvent(const QPointF &pos, const QPointF& globalPos, QPoint pixelDelta, QPoint angleDelta, int qt4Delta, Qt::Orientation qt4Orientation, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Qt::ScrollPhase phase, Qt::MouseEventSource source) - : QInputEvent(Wheel, modifiers), p(pos), g(globalPos), pixelD(pixelDelta), - angleD(angleDelta), qt4D(qt4Delta), qt4O(qt4Orientation), mouseState(buttons), ph(phase), src(source), - invertedScrolling(false) + : QWheelEvent(pos, globalPos, pixelDelta, angleDelta, qt4Delta, qt4Orientation, + buttons, modifiers, phase, source, false) {} /*! @@ -1767,7 +1764,7 @@ QIconDragEvent::~QIconDragEvent() coordinates. */ QContextMenuEvent::QContextMenuEvent(Reason reason, const QPoint &pos, const QPoint &globalPos) - : QInputEvent(ContextMenu), p(pos), gp(globalPos), reas(reason) + : QContextMenuEvent(reason, pos, globalPos, Qt::NoModifier) {} /*! @@ -2065,6 +2062,16 @@ QContextMenuEvent::QContextMenuEvent(Reason reason, const QPoint &pos) */ /*! + \fn QInputMethodEvent::Attribute::Attribute(AttributeType type, int start, int length) + \overload + \since 5.7 + + Constructs an input method attribute with no value. \a type + specifies the type of attribute, and \a start and \a length + the position of the attribute. +*/ + +/*! Constructs an event of type QEvent::InputMethod. The attributes(), preeditString(), commitString(), replacementStart(), and replacementLength() are initialized to default values. @@ -2440,19 +2447,8 @@ QTabletEvent::QTabletEvent(Type type, const QPointF &pos, const QPointF &globalP int device, int pointerType, qreal pressure, int xTilt, int yTilt, qreal tangentialPressure, qreal rotation, int z, Qt::KeyboardModifiers keyState, qint64 uniqueID) - : QInputEvent(type, keyState), - mPos(pos), - mGPos(globalPos), - mDev(device), - mPointerType(pointerType), - mXT(xTilt), - mYT(yTilt), - mZ(z), - mPress(pressure), - mTangential(tangentialPressure), - mRot(rotation), - mUnique(uniqueID), - mExtra(new QTabletEventPrivate(Qt::NoButton, Qt::NoButton)) + : QTabletEvent(type, pos, globalPos, device, pointerType, pressure, xTilt, yTilt, + tangentialPressure, rotation, z, keyState, uniqueID, Qt::NoButton, Qt::NoButton) { } @@ -4411,6 +4407,7 @@ QTouchEvent::~QTouchEvent() The values of this enum describe additional information about a touch point. \value Pen Indicates that the contact has been made by a designated pointing device (e.g. a pen) instead of a finger. + \value Token Indicates that the contact has been made by a fiducial object (e.g. a knob or other token) instead of a finger. */ /*! @@ -4457,6 +4454,22 @@ int QTouchEvent::TouchPoint::id() const } /*! + \since 5.8 + Returns the unique ID of this touch point or token, if any. + + It is normally invalid (with a \l {QPointerUniqueId::numeric()} {numeric()} value of -1), + because touchscreens cannot uniquely identify fingers. But when the + \l {TouchPoint::InfoFlag} {Token} flag is set, it is expected to uniquely + identify a specific token (fiducial object). + + \sa flags +*/ +QPointerUniqueId QTouchEvent::TouchPoint::uniqueId() const +{ + return d->uniqueId; +} + +/*! Returns the current state of this touch point. */ Qt::TouchPointState QTouchEvent::TouchPoint::state() const @@ -4660,6 +4673,19 @@ qreal QTouchEvent::TouchPoint::pressure() const } /*! + \since 5.8 + Returns the angular orientation of this touch point. The return value is in degrees, + where zero (the default) indicates the finger or token is pointing upwards, + a negative angle means it's rotated to the left, and a positive angle means + it's rotated to the right. Most touchscreens do not detect rotation, so + zero is the most common value. +*/ +qreal QTouchEvent::TouchPoint::rotation() const +{ + return d->rotation; +} + +/*! Returns a velocity vector for this touch point. The vector is in the screen's coordinate system, using pixels per seconds for the magnitude. @@ -4710,6 +4736,14 @@ void QTouchEvent::TouchPoint::setId(int id) } /*! \internal */ +void QTouchEvent::TouchPoint::setUniqueId(qint64 uid) +{ + if (d->ref.load() != 1) + d = d->detach(); + d->uniqueId = QPointerUniqueId(uid); +} + +/*! \internal */ void QTouchEvent::TouchPoint::setState(Qt::TouchPointStates state) { if (d->ref.load() != 1) @@ -4846,6 +4880,14 @@ void QTouchEvent::TouchPoint::setPressure(qreal pressure) } /*! \internal */ +void QTouchEvent::TouchPoint::setRotation(qreal angle) +{ + if (d->ref.load() != 1) + d = d->detach(); + d->rotation = angle; +} + +/*! \internal */ void QTouchEvent::TouchPoint::setVelocity(const QVector2D &v) { if (d->ref.load() != 1) @@ -5116,4 +5158,37 @@ Qt::ApplicationState QApplicationStateChangeEvent::applicationState() const return m_applicationState; } +/*! + \class QPointerUniqueId + \since 5.8 + \ingroup events + \inmodule QtGui + + \brief QPointerUniqueId identifies a unique object, such as a tagged token + or stylus, which is used with a pointing device. + + \sa QTouchEvent::TouchPoint +*/ + +/*! + Constructs a unique pointer ID with a numeric \a id provided by the hardware. + The default is -1, which means an invalid pointer ID. +*/ +QPointerUniqueId::QPointerUniqueId(qint64 id) + : m_numericId(id) +{ +} + +/*! + \property QPointerUniqueId::numeric + \brief the numeric unique ID of the token represented by a touchpoint + + This is the numeric unique ID if the device provides that type of ID; + otherwise it is -1. +*/ +qint64 QPointerUniqueId::numeric() +{ + return m_numericId; +} + QT_END_NAMESPACE |