mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-28 14:58:36 +00:00
#12434 add event handler for pinch-to-zoom gesture
This commit is contained in:
parent
d4cfa5204c
commit
d432403430
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user