From 8a12bf17498591543b683bd250ef6b34ddb2dc94 Mon Sep 17 00:00:00 2001 From: Dale Glass Date: Sun, 5 Jun 2022 13:23:25 +0200 Subject: [PATCH] Replace usage of deprecated QWheelEvent members --- libraries/qml/src/qml/OffscreenSurface.cpp | 10 +++++++--- libraries/script-engine/src/WheelEvent.cpp | 15 +++++++-------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/libraries/qml/src/qml/OffscreenSurface.cpp b/libraries/qml/src/qml/OffscreenSurface.cpp index a5ac734897..097d8d48d5 100644 --- a/libraries/qml/src/qml/OffscreenSurface.cpp +++ b/libraries/qml/src/qml/OffscreenSurface.cpp @@ -173,9 +173,13 @@ bool OffscreenSurface::eventFilter(QObject* originalDestination, QEvent* event) case QEvent::Wheel: { QWheelEvent* wheelEvent = static_cast(event); - QPointF transformedPos = mapToVirtualScreen(wheelEvent->pos()); - QWheelEvent mappedEvent(transformedPos, wheelEvent->delta(), wheelEvent->buttons(), wheelEvent->modifiers(), - wheelEvent->orientation()); + QPointF transformedPos = mapToVirtualScreen(wheelEvent->position()); + + + QWheelEvent mappedEvent(transformedPos, wheelEvent->globalPosition(), wheelEvent->pixelDelta(), wheelEvent->angleDelta(), + wheelEvent->buttons(), wheelEvent->modifiers(), wheelEvent->phase(), + wheelEvent->inverted(), wheelEvent->source()); + mappedEvent.ignore(); if (QCoreApplication::sendEvent(_sharedObject->getWindow(), &mappedEvent)) { return mappedEvent.isAccepted(); diff --git a/libraries/script-engine/src/WheelEvent.cpp b/libraries/script-engine/src/WheelEvent.cpp index 690d65847b..4d7a2bc479 100644 --- a/libraries/script-engine/src/WheelEvent.cpp +++ b/libraries/script-engine/src/WheelEvent.cpp @@ -27,25 +27,24 @@ WheelEvent::WheelEvent() : isMeta(false), isAlt(false) { - + } WheelEvent::WheelEvent(const QWheelEvent& event) { - x = event.x(); - y = event.y(); - - delta = event.delta(); - if (event.orientation() == Qt::Horizontal) { + x = event.position().x(); + y = event.position().y(); + + if (event.angleDelta().x() != 0) { orientation = "HORIZONTAL"; } else { orientation = "VERTICAL"; } - + // button pressed state isLeftButton = (event.buttons().testFlag(Qt::LeftButton)); isRightButton = (event.buttons().testFlag(Qt::RightButton)); isMiddleButton = (event.buttons().testFlag(Qt::MiddleButton)); - + // keyboard modifiers isShifted = event.modifiers().testFlag(Qt::ShiftModifier); isMeta = event.modifiers().testFlag(Qt::MetaModifier);