shift timelineview scroll code into base classes

Fixes #2060
This commit is contained in:
itsmattkc
2022-10-24 12:01:47 -07:00
parent f81445527f
commit bdbfb56879
8 changed files with 61 additions and 84 deletions
+50 -1
View File
@@ -31,7 +31,8 @@ namespace olive {
HandMovableView::HandMovableView(QWidget* parent) :
super(parent),
dragging_hand_(false)
dragging_hand_(false),
is_timeline_axes_(false)
{
connect(Core::instance(), &Core::ToolChanged, this, &HandMovableView::ApplicationToolChanged);
}
@@ -166,6 +167,54 @@ void HandMovableView::wheelEvent(QWheelEvent *event)
ZoomIntoCursorPosition(event, multiplier, cursor_pos);
}
} else if (is_timeline_axes_) {
#if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0))
QPoint angle_delta = event->angleDelta();
if (OLIVE_CONFIG("InvertTimelineScrollAxes").toBool() // Check if config is set to invert timeline axes
&& event->source() != Qt::MouseEventSynthesizedBySystem) { // Never flip axes on Apple trackpads though
angle_delta = QPoint(angle_delta.y(), angle_delta.x());
}
QWheelEvent e(
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
event->position(),
event->globalPosition(),
#else
event->pos(),
event->globalPos(),
#endif
event->pixelDelta(),
angle_delta,
event->buttons(),
event->modifiers(),
event->phase(),
event->inverted(),
event->source()
);
#else
Qt::Orientation orientation = event->orientation();
if (OLIVE_CONFIG("InvertTimelineScrollAxes").toBool()) {
orientation = (orientation == Qt::Horizontal) ? Qt::Vertical : Qt::Horizontal;
}
QWheelEvent e(
event->pos(),
event->globalPos(),
event->pixelDelta(),
event->angleDelta(),
event->delta(),
orientation,
event->buttons(),
event->modifiers()
);
#endif
super::wheelEvent(&e);
} else {
super::wheelEvent(event);
}