From c08bf215cceda784cd02f8fa20e5b2431e0d9ef9 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Mon, 12 Mar 2018 11:10:08 +0100 Subject: [PATCH] Add a legacy-free QWheelEvent constructor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit qt4Delta and qt4Orientation have been "deprecated" ever since Qt 5.0 (even though widgets continue to depend on those properties). This is mainly for use in Qt Quick right now, but can be used everywhere later on. Change-Id: If0b163766c8ad8efa268edaa4f1ac1e8926f9003 Reviewed-by: Tor Arne Vestbø Reviewed-by: Jan Arve Sæther --- src/gui/kernel/qevent.cpp | 37 +++++++++++++++++++++++++++++++++++++ src/gui/kernel/qevent.h | 8 ++++++-- 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index d219aa94a3..2e2e6b8301 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -960,6 +960,43 @@ QWheelEvent::QWheelEvent(const QPointF &pos, const QPointF& globalPos, invertedScrolling(inverted) {} +/*! + Constructs a wheel event object. + + The \a pos provides the location of the mouse cursor + within the window. The position in global coordinates is specified + by \a globalPos. + + \a pixelDelta contains the scrolling distance in pixels on screen, while + \a angleDelta contains the wheel rotation distance. \a pixelDelta is + optional and can be null. + + The mouse and keyboard states at the time of the event are specified by + \a buttons and \a modifiers. + + The scrolling phase of the event is specified by \a phase. + + If the wheel event comes from a physical mouse wheel, \a source is set to + Qt::MouseEventNotSynthesized. If it comes from a gesture detected by the + operating system, or from a non-mouse hardware device, such that \a + pixelDelta is directly related to finger movement, \a source is set to + Qt::MouseEventSynthesizedBySystem. If it comes from Qt, source would be set + to Qt::MouseEventSynthesizedByQt. + + If the system is configured to invert the delta values delivered with the + event (such as natural scrolling of the touchpad on macOS), \a inverted + should be \c true. Otherwise, \a inverted is \c false + + \sa posF(), globalPosF(), angleDelta(), pixelDelta(), phase() +*/ +QWheelEvent::QWheelEvent(QPointF pos, QPointF globalPos, QPoint pixelDelta, QPoint angleDelta, + Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Qt::ScrollPhase phase, + bool inverted, Qt::MouseEventSource source) + : QInputEvent(Wheel, modifiers), p(pos), g(globalPos), pixelD(pixelDelta), + angleD(angleDelta), mouseState(buttons), ph(phase), src(source), + invertedScrolling(inverted) +{} + #endif // QT_CONFIG(wheelevent) /*! diff --git a/src/gui/kernel/qevent.h b/src/gui/kernel/qevent.h index d95da40368..2a47afaa0b 100644 --- a/src/gui/kernel/qevent.h +++ b/src/gui/kernel/qevent.h @@ -193,6 +193,10 @@ public: 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, bool inverted); + + QWheelEvent(QPointF pos, QPointF globalPos, QPoint pixelDelta, QPoint angleDelta, + Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Qt::ScrollPhase phase, + bool inverted, Qt::MouseEventSource source = Qt::MouseEventNotSynthesized); ~QWheelEvent(); @@ -225,8 +229,8 @@ protected: QPointF g; QPoint pixelD; QPoint angleD; - int qt4D; - Qt::Orientation qt4O; + int qt4D = 0; + Qt::Orientation qt4O = Qt::Vertical; Qt::MouseButtons mouseState; uint ph : 2; uint src: 2;