X-Git-Url: http://sigrok.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=pv%2Fviews%2Ftrace%2Fviewport.cpp;h=7ab24eadd3ffd9bd4f8edd30679d8cde0de74f08;hb=f375439ffd21c497f7170dc4d5eca94e816116ce;hp=a2d0b99ae34769ff8cf37b86525dcbc532b2a1d3;hpb=e6c8d58bde2c32f0ee8b73c5577505736caf8e23;p=pulseview.git diff --git a/pv/views/trace/viewport.cpp b/pv/views/trace/viewport.cpp index a2d0b99a..7ab24ead 100644 --- a/pv/views/trace/viewport.cpp +++ b/pv/views/trace/viewport.cpp @@ -225,29 +225,51 @@ void Viewport::wheelEvent(QWheelEvent *event) { assert(event); +#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0) + int delta = (event->angleDelta().x() != 0) ? event->angleDelta().x() : event->angleDelta().y(); +#else + int delta = event->delta(); +#endif + +#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0) + if (event->angleDelta().y() != 0) { +#else if (event->orientation() == Qt::Vertical) { +#endif if (event->modifiers() & Qt::ControlModifier) { // Vertical scrolling with the control key pressed // is intrepretted as vertical scrolling view_.set_v_offset(-view_.owner_visual_v_offset() - - (event->delta() * height()) / (8 * 120)); + (delta * height()) / (8 * 120)); + } else if (event->modifiers() & Qt::ShiftModifier) { + // Vertical scrolling with the shift key pressed + // acts as horizontal scrolling like in Gimp + // and Inkscape. + view_.set_scale_offset(view_.scale(), + - delta * view_.scale() + view_.offset()); } else { // Vertical scrolling is interpreted as zooming in/out - view_.zoom(event->delta() / 120.0, event->x()); +#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0) + view_.zoom(delta / 120.0, event->position().x()); +#else + view_.zoom(delta / 120.0, event->x()); +#endif } +#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0) + } else if (event->angleDelta().x() != 0) { +#else } else if (event->orientation() == Qt::Horizontal) { +#endif // Horizontal scrolling is interpreted as moving left/right view_.set_scale_offset(view_.scale(), - event->delta() * view_.scale() + view_.offset()); + delta * view_.scale() + view_.offset()); } } void Viewport::on_setting_changed(const QString &key, const QVariant &value) { - if (key == GlobalSettings::Key_View_AllowVerticalDragging) { - GlobalSettings settings; - allow_vertical_dragging_ = settings.value(GlobalSettings::Key_View_AllowVerticalDragging).toBool(); - } + if (key == GlobalSettings::Key_View_AllowVerticalDragging) + allow_vertical_dragging_ = value.toBool(); } } // namespace trace