From 0390b02a7fdf96dc8b403e4634f62bf0a08ab94d Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Tue, 22 May 2012 10:44:48 +0300 Subject: Add mouse event internal members needed by declarative MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In order to remove QQuickMouseEventEx we have to be able to store touch-related data, like capabilities and velocity, also in mouse events. However they should not be exposed through the public API in any way. (at least not in 5.0) Change-Id: I7774b9ea00074950208559463249fbdcaeeaefbf Reviewed-by: Samuel Rødal Reviewed-by: Shawn Rutledge Reviewed-by: Lars Knoll --- src/gui/kernel/qevent.cpp | 6 +++--- src/gui/kernel/qevent.h | 4 ++++ src/gui/kernel/qguiapplication.cpp | 23 +++++++++++++++++++++++ src/gui/kernel/qguiapplication_p.h | 5 +++++ 4 files changed, 35 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index beb75308b3..2181d06734 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -161,7 +161,7 @@ QInputEvent::~QInputEvent() */ QMouseEvent::QMouseEvent(Type type, const QPointF &localPos, Qt::MouseButton button, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers) - : QInputEvent(type, modifiers), l(localPos), w(localPos), b(button), mouseState(buttons) + : QInputEvent(type, modifiers), l(localPos), w(localPos), b(button), mouseState(buttons), caps(0) { s = QCursor::pos(); } @@ -188,7 +188,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) + : QInputEvent(type, modifiers), l(localPos), w(localPos), s(screenPos), b(button), mouseState(buttons), caps(0) {} /*! @@ -211,7 +211,7 @@ QMouseEvent::QMouseEvent(Type type, const QPointF &localPos, const QPointF &scre QMouseEvent::QMouseEvent(Type type, const QPointF &localPos, const QPointF &windowPos, const QPointF &screenPos, Qt::MouseButton button, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers) - : QInputEvent(type, modifiers), l(localPos), w(windowPos), s(screenPos), b(button), mouseState(buttons) + : QInputEvent(type, modifiers), l(localPos), w(windowPos), s(screenPos), b(button), mouseState(buttons), caps(0) {} /*! diff --git a/src/gui/kernel/qevent.h b/src/gui/kernel/qevent.h index 96e630ed0a..de80d19fe6 100644 --- a/src/gui/kernel/qevent.h +++ b/src/gui/kernel/qevent.h @@ -119,6 +119,10 @@ protected: QPointF l, w, s; Qt::MouseButton b; Qt::MouseButtons mouseState; + int caps; + QVector2D velocity; + + friend class QGuiApplicationPrivate; }; class Q_GUI_EXPORT QHoverEvent : public QInputEvent diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index 570f3f7f3f..4e4bc13f12 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -2387,6 +2387,29 @@ void QGuiApplicationPrivate::q_updateFocusObject(QObject *object) emit q->focusObjectChanged(object); } +int QGuiApplicationPrivate::mouseEventCaps(QMouseEvent *event) +{ + return event->caps; +} + +QVector2D QGuiApplicationPrivate::mouseEventVelocity(QMouseEvent *event) +{ + return event->velocity; +} + +void QGuiApplicationPrivate::setMouseEventCapsAndVelocity(QMouseEvent *event, int caps, const QVector2D &velocity) +{ + event->caps = caps; + event->velocity = velocity; +} + +void QGuiApplicationPrivate::setMouseEventCapsAndVelocity(QMouseEvent *event, QMouseEvent *other) +{ + event->caps = other->caps; + event->velocity = other->velocity; +} + + #include "moc_qguiapplication.cpp" QT_END_NAMESPACE diff --git a/src/gui/kernel/qguiapplication_p.h b/src/gui/kernel/qguiapplication_p.h index bab3ecc997..d40f61d13b 100644 --- a/src/gui/kernel/qguiapplication_p.h +++ b/src/gui/kernel/qguiapplication_p.h @@ -212,6 +212,11 @@ public: }; QHash synthesizedMousePoints; + static int mouseEventCaps(QMouseEvent *event); + static QVector2D mouseEventVelocity(QMouseEvent *event); + static void setMouseEventCapsAndVelocity(QMouseEvent *event, int caps, const QVector2D &velocity); + static void setMouseEventCapsAndVelocity(QMouseEvent *event, QMouseEvent *other); + const QDrawHelperGammaTables *gammaTables(); // hook reimplemented in QApplication to apply the QStyle function on the QIcon -- cgit v1.2.3