mainwindow: Allow CTRL + mouse wheel to zoom on previews

This commit is contained in:
Albert S. 2022-08-21 18:42:32 +02:00
parent 0c1b57d911
commit fe610d3068
1 changed files with 27 additions and 0 deletions

View File

@ -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<QWheelEvent *>(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);
}