From fe610d30688adbb2ab46d16d167d733048ae3d78 Mon Sep 17 00:00:00 2001 From: Albert S Date: Sun, 21 Aug 2022 18:42:32 +0200 Subject: [PATCH] mainwindow: Allow CTRL + mouse wheel to zoom on previews --- gui/mainwindow.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index 075a6ce..4f5d7b0 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -75,6 +75,7 @@ MainWindow::MainWindow(QWidget *parent, QString socketPath) ui->btnOpenFailed->setSizePolicy(policy); ui->txtSearch->installEventFilter(this); + ui->scrollArea->viewport()->installEventFilter(this); this->ipcClientThread.start(); } @@ -494,6 +495,32 @@ bool MainWindow::eventFilter(QObject *object, QEvent *event) } } } + if(object == ui->scrollArea->viewport()) + { + if(event->type() == QEvent::Wheel) + { + QWheelEvent *wheelEvent = static_cast(event); + if(wheelEvent->modifiers() & Qt::ControlModifier) + { + if(wheelEvent->angleDelta().y() > 0) + { + if(ui->comboScale->currentIndex() < ui->comboScale->count() - 1) + { + ui->comboScale->setCurrentIndex(ui->comboScale->currentIndex() + 1); + } + } + + else + { + if(ui->comboScale->currentIndex() > 0) + { + ui->comboScale->setCurrentIndex(ui->comboScale->currentIndex() - 1); + } + } + return true; + } + } + } return QMainWindow::eventFilter(object, event); }