diff --git a/app/mainwindow.h b/app/mainwindow.h --- a/app/mainwindow.h +++ b/app/mainwindow.h @@ -30,6 +30,8 @@ class QUrl; +class QMouseEvent; + namespace Gwenview { @@ -79,6 +81,8 @@ void saveProperties(KConfigGroup&) override; void readProperties(const KConfigGroup&) override; bool eventFilter(QObject *, QEvent *) override; + void mousePressEvent(QMouseEvent *) override; + void mouseDoubleClickEvent(QMouseEvent *) override; private Q_SLOTS: void setActiveViewModeAction(QAction* action); @@ -137,6 +141,8 @@ void saveConfig(); void configureShortcuts(); + void mouseButtonNavigate(QMouseEvent *); + void folderViewUrlChanged(const QUrl &url); }; diff --git a/app/mainwindow.cpp b/app/mainwindow.cpp --- a/app/mainwindow.cpp +++ b/app/mainwindow.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #ifdef Q_OS_OSX #include #endif @@ -1654,6 +1655,37 @@ return false; } +void MainWindow::mousePressEvent(QMouseEvent *event) +{ + mouseButtonNavigate(event); + KXmlGuiWindow::mousePressEvent(event); +} + +void MainWindow::mouseDoubleClickEvent(QMouseEvent *event) +{ + mouseButtonNavigate(event); + KXmlGuiWindow::mouseDoubleClickEvent(event); +} + +void MainWindow::mouseButtonNavigate(QMouseEvent *event) +{ + switch(event->button()) { + case Qt::ForwardButton: + if (d->mGoToNextAction->isEnabled()) { + d->mGoToNextAction->trigger(); + return; + } + break; + case Qt::BackButton: + if (d->mGoToPreviousAction->isEnabled()) { + d->mGoToPreviousAction->trigger(); + return; + } + break; + default: ; + } +} + void MainWindow::setDistractionFreeMode(bool value) { d->mFullScreenContent->setDistractionFreeMode(value);