mainwindow: Allow CTRL + mouse wheel to zoom on previews

Tento commit je obsažen v:
Albert S. 2022-08-21 18:42:32 +02:00
rodič 0c1b57d911
revize fe610d3068

Zobrazit soubor

@ -75,6 +75,7 @@ MainWindow::MainWindow(QWidget *parent, QString socketPath)
ui->btnOpenFailed->setSizePolicy(policy); ui->btnOpenFailed->setSizePolicy(policy);
ui->txtSearch->installEventFilter(this); ui->txtSearch->installEventFilter(this);
ui->scrollArea->viewport()->installEventFilter(this);
this->ipcClientThread.start(); 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); return QMainWindow::eventFilter(object, event);
} }