diff --git a/app/browsemainpage.h b/app/browsemainpage.h --- a/app/browsemainpage.h +++ b/app/browsemainpage.h @@ -83,6 +83,7 @@ protected: bool eventFilter(QObject* watched, QEvent* event) override; + void mousePressEvent(QMouseEvent*) override; private: BrowseMainPagePrivate* const d; diff --git a/app/browsemainpage.cpp b/app/browsemainpage.cpp --- a/app/browsemainpage.cpp +++ b/app/browsemainpage.cpp @@ -397,6 +397,17 @@ return QWidget::eventFilter(watched, event); } +void BrowseMainPage::mousePressEvent(QMouseEvent* event) +{ + switch (event->button()) { + case Qt::ForwardButton: + case Qt::BackButton: + return; + default: + QWidget::mousePressEvent(event); + } +} + ThumbnailView* BrowseMainPage::thumbnailView() const { return d->mThumbnailView; 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); @@ -139,6 +143,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 @@ -34,6 +34,7 @@ #include #include #include +#include #ifdef Q_OS_OSX #include #endif @@ -278,6 +279,7 @@ mBrowseMainPage = new BrowseMainPage(parent, q->actionCollection(), mGvCore); mThumbnailView = mBrowseMainPage->thumbnailView(); + mThumbnailView->viewport()->installEventFilter(q); mThumbnailView->setSelectionModel(mContextManager->selectionModel()); mUrlNavigator = mBrowseMainPage->urlNavigator(); @@ -1669,9 +1671,49 @@ return true; } #endif + if (obj == d->mThumbnailView->viewport()) { + switch(event->type()) { + case QEvent::MouseButtonPress: + case QEvent::MouseButtonDblClick: + mouseButtonNavigate(static_cast(event)); + break; + default: ; + } + } 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);