Fixing issue #831. macOS touchpad gestures glitching.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2018-04-16 11:05:57 +03:00
parent 788f27889f
commit 702c256c87

View File

@ -220,21 +220,16 @@ bool GraphicsViewZoom::eventFilter(QObject *object, QEvent *event)
} }
else if (event->type() == QEvent::Wheel) else if (event->type() == QEvent::Wheel)
{ {
QWheelEvent* wheel_event = static_cast<QWheelEvent*>(event); if (QWheelEvent* wheel_event = static_cast<QWheelEvent*>(event))
SCASSERT(wheel_event != nullptr)
if (QGuiApplication::keyboardModifiers() == _modifiers)
{ {
if (wheel_event->orientation() == Qt::Vertical) if (wheel_event->orientation() == Qt::Vertical)
{ {
const double angle = wheel_event->angleDelta().y(); if (QGuiApplication::keyboardModifiers() == _modifiers)
const double factor = qPow(_zoom_factor_base, angle); {
gentle_zoom(factor); gentle_zoom(qPow(_zoom_factor_base, wheel_event->angleDelta().y()));
return true; return true;
} }
} else if (QGuiApplication::keyboardModifiers() == Qt::ShiftModifier)
else
{
if (QGuiApplication::keyboardModifiers() == Qt::ShiftModifier)
{ {
return StartHorizontalScrollings(wheel_event); return StartHorizontalScrollings(wheel_event);
} }
@ -243,6 +238,16 @@ bool GraphicsViewZoom::eventFilter(QObject *object, QEvent *event)
return StartVerticalScrollings(wheel_event); return StartVerticalScrollings(wheel_event);
} }
} }
else
{
if (QGuiApplication::keyboardModifiers() == _modifiers)
{
return true; //ignore
}
return StartHorizontalScrollings(wheel_event);
}
}
} }
return QObject::eventFilter(object, event); return QObject::eventFilter(object, event);
@ -289,11 +294,11 @@ bool GraphicsViewZoom::StartVerticalScrollings(QWheelEvent *wheel_event)
if (not numPixels.isNull()) if (not numPixels.isNull())
{ {
numSteps = numPixels.y(); numSteps = wheel_event->orientation() == Qt::Vertical ? numPixels.y() : numPixels.x();
} }
else if (not numDegrees.isNull()) else if (not numDegrees.isNull())
{ {
numSteps = numDegrees.y() / 15; numSteps = (wheel_event->orientation() == Qt::Vertical ? numDegrees.y() : numDegrees.x()) / 15;
} }
else else
{ {
@ -324,11 +329,11 @@ bool GraphicsViewZoom::StartHorizontalScrollings(QWheelEvent *wheel_event)
if (not numPixels.isNull()) if (not numPixels.isNull())
{ {
numSteps = numPixels.y(); numSteps = wheel_event->orientation() == Qt::Vertical ? numPixels.y() : numPixels.x();
} }
else if (not numDegrees.isNull()) else if (not numDegrees.isNull())
{ {
numSteps = numDegrees.y() / 15; numSteps = (wheel_event->orientation() == Qt::Vertical ? numDegrees.y() : numDegrees.x()) / 15;
} }
else else
{ {