Commit f9cc9f3c authored by Nicolas Fella's avatar Nicolas Fella Committed by Albert Astals Cid
Browse files

Port away from deprecated QWheelEvent ctor

Instead of messing with the orientation enum swap the x and y of the delta to achieve the same thing

Also make it Qt6-proof
parent c7898996
Pipeline #167827 passed with stage
in 3 minutes and 39 seconds
......@@ -169,7 +169,12 @@ void mapWidget::wheelEvent(QWheelEvent *e)
if ( e->modifiers() == Qt::NoModifier ) QGraphicsView::wheelEvent(e);
else if ( e->modifiers() == Qt::ShiftModifier )
{
QWheelEvent reorientedEvent(e->pos(), e->delta(), e->buttons(), Qt::NoModifier, Qt::Orientation(3 -int(e->orientation())));
// Scroll horizontally by swapping x and y for the delta
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
QWheelEvent reorientedEvent(e->position(), e->globalPosition(), e->pixelDelta().transposed(), -e->angleDelta().transposed(), e->buttons(), Qt::NoModifier, e->phase(), e->inverted(), e->source(), e->pointingDevice());
#else
QWheelEvent reorientedEvent(e->pos(), e->globalPos(), e->pixelDelta().transposed(), e->angleDelta().transposed(), e->buttons(), Qt::NoModifier, e->phase(), e->inverted(), e->source());
#endif
QGraphicsView::wheelEvent(&reorientedEvent);
}
else if ( e->modifiers() == Qt::ControlModifier )
......
......@@ -343,7 +343,12 @@ void placeMapWidget::wheelEvent(QWheelEvent *e)
if ( e->modifiers() == Qt::NoModifier ) QGraphicsView::wheelEvent(e);
else if ( e->modifiers() == Qt::ShiftModifier )
{
QWheelEvent reorientedEvent(e->pos(), e->delta(), e->buttons(), Qt::NoModifier, Qt::Orientation(3 -int(e->orientation())));
// Scroll horizontally by swapping x and y for the delta
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
QWheelEvent reorientedEvent(e->position(), e->globalPosition(), e->pixelDelta().transposed(), -e->angleDelta().transposed(), e->buttons(), Qt::NoModifier, e->phase(), e->inverted(), e->source(), e->pointingDevice());
#else
QWheelEvent reorientedEvent(e->pos(), e->globalPos(), e->pixelDelta().transposed(), e->angleDelta().transposed(), e->buttons(), Qt::NoModifier, e->phase(), e->inverted(), e->source());
#endif
QGraphicsView::wheelEvent(&reorientedEvent);
}
else if ( e->modifiers() == Qt::ControlModifier )
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment