LibreVNA-GUI:Traces:tracepolot: Fix getting QWheelEvent position

This commit is contained in:
Alexander Voronov 2023-03-25 00:24:38 +03:00
parent 3f39a736e0
commit 84953d23d1

View File

@ -413,11 +413,12 @@ void TracePlot::leaveEvent(QEvent *event)
void TracePlot::wheelEvent(QWheelEvent *event)
{
auto &pref = Preferences::getInstance();
if(pref.Graphs.enablePanAndZoom && positionWithinGraphArea(event->pos())) {
QPoint position(event->position().x(), event->position().y());
if(pref.Graphs.enablePanAndZoom && positionWithinGraphArea(position)) {
bool horizontally = !(QApplication::keyboardModifiers() & Qt::ShiftModifier);
bool vertically = !(QApplication::keyboardModifiers() & Qt::ControlModifier);
double factor = pow(pref.Graphs.zoomFactor, (double) event->angleDelta().y() / 120.0);
zoom(event->pos(), factor, horizontally, vertically);
zoom(position, factor, horizontally, vertically);
event->accept();
}
}