Commit 34ac47af authored by Anjani Kumar's avatar Anjani Kumar
Browse files

Add QT_VERSION checks for QWheelEvent

parent b4d1e739
......@@ -721,7 +721,15 @@ void GLViewerWidget::wheelEvent(QWheelEvent* e)
case GLViewerWidget::Private::zoomImage:
{
setCursor(d->zoomCursor);
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
zoom(e->angleDelta().y(), e->position().toPoint(), d->zoomfactor_scrollwheel);
#else
zoom(e->angleDelta().y(), e->pos(), d->zoomfactor_scrollwheel);
#endif
break;
}
......
......@@ -397,14 +397,23 @@ void GraphicsDImgView::wheelEvent(QWheelEvent* e)
else if (e->modifiers() & Qt::ControlModifier)
{
// When zooming with the mouse-wheel, the image center is kept fixed.
QPoint point;
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
point = e->position().toPoint();
#else
point = e->pos();
#endif
if (e->angleDelta().y() < 0)
{
d->layout->decreaseZoom(e->position().toPoint());
d->layout->decreaseZoom(point);
}
else if (e->angleDelta().y() > 0)
{
d->layout->increaseZoom(e->position().toPoint());
d->layout->increaseZoom(point);
}
return;
......
......@@ -939,9 +939,16 @@ void ItemViewCategorized::wheelEvent(QWheelEvent* event)
if (verticalScrollBarPolicy() == Qt::ScrollBarAlwaysOff && event->angleDelta().y() != 0)
{
#if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0))
QWheelEvent n(event->position(), event->globalPosition(), event->pixelDelta(),
event->angleDelta(), event->buttons(), event->modifiers(),
event->phase(), event->inverted(), event->source());
#else
QWheelEvent n(event->pos(), event->globalPos(), event->angleDelta().y(),
event->buttons(), event->modifiers(), Qt::Horizontal);
#endif
QApplication::sendEvent(horizontalScrollBar(), &n);
event->setAccepted(n.isAccepted());
}
......
......@@ -559,7 +559,21 @@ void SketchWidget::mouseMoveEvent(QMouseEvent* e)
void SketchWidget::wheelEvent(QWheelEvent* e)
{
if (rect().contains(e->position().toPoint().x(), e->position().toPoint().y()))
int x, y;
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
x = e->position().toPoint().x();
y = e->position().toPoint().y();
#else
x = e->x();
y = e->y();
#endif
if (rect().contains(x, y))
{
int size = d->penWidth;
int decr = (e->modifiers() & Qt::SHIFT) ? 1 : 10;
......
......@@ -228,9 +228,19 @@ bool DWItemDelegateEventListener::eventFilter(QObject* watched, QEvent* event)
case QEvent::Wheel:
{
QWheelEvent* const wheelEvent = static_cast<QWheelEvent*>(event);
#if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0))
QWheelEvent evt(wheelEvent->position(), wheelEvent->globalPosition(),wheelEvent->pixelDelta(),
wheelEvent->angleDelta(), wheelEvent->buttons(), wheelEvent->modifiers(),
wheelEvent->phase(), wheelEvent->inverted(), wheelEvent->source());
#else
QWheelEvent evt(viewport->mapFromGlobal(wheelEvent->globalPos()),
wheelEvent->angleDelta().y(), wheelEvent->buttons(), wheelEvent->modifiers(),
wheelEvent->orientation());
#endif
QApplication::sendEvent(viewport, &evt);
break;
}
......
Markdown is supported
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