commit d4324034300f73f76e5ac34fb1e7653fa6e2ddf5 Author: Stephan Witt <sw...@lyx.org> Date: Mon Jan 3 07:37:03 2022 +0100
#12434 add event handler for pinch-to-zoom gesture --- src/frontends/qt/GuiView.cpp | 20 ++++++++++++++++++++ 1 files changed, 20 insertions(+), 0 deletions(-) diff --git a/src/frontends/qt/GuiView.cpp b/src/frontends/qt/GuiView.cpp index ffcbc3d..791a2c2 100644 --- a/src/frontends/qt/GuiView.cpp +++ b/src/frontends/qt/GuiView.cpp @@ -110,6 +110,8 @@ #include <QTimer> #include <QUrl> #include <QWindowStateChangeEvent> +#include <QGestureEvent> +#include <QPinchGesture> // sync with GuiAlert.cpp @@ -694,6 +696,9 @@ GuiView::GuiView(int id) connect(statusBar(), SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showZoomContextMenu())); + // enable pinch to zoom + grabGesture(Qt::PinchGesture); + int const iconheight = max(int(d.normalIconSize), fm.height()); QSize const iconsize(iconheight, iconheight); @@ -1621,6 +1626,21 @@ bool GuiView::event(QEvent * e) return QMainWindow::event(e); } + case QEvent::Gesture: { + QGestureEvent *ge = static_cast<QGestureEvent*>(e); + QGesture *gp = ge->gesture(Qt::PinchGesture); + if (gp) { + QPinchGesture *pinch = static_cast<QPinchGesture *>(gp); + QPinchGesture::ChangeFlags changeFlags = pinch->changeFlags(); + if (changeFlags & QPinchGesture::ScaleFactorChanged) { + qreal factor = lyxrc.currentZoom*pinch->scaleFactor(); + //factor = ceil(factor/20)*20; + zoomValueChanged(factor); + } + } + return QMainWindow::event(e); + } + default: return QMainWindow::event(e); } -- lyx-cvs mailing list lyx-cvs@lists.lyx.org http://lists.lyx.org/mailman/listinfo/lyx-cvs