diff --git a/YACReaderLibrary/library_window.cpp b/YACReaderLibrary/library_window.cpp index 2ce6ab4e..fa85756f 100644 --- a/YACReaderLibrary/library_window.cpp +++ b/YACReaderLibrary/library_window.cpp @@ -139,6 +139,29 @@ void LibraryWindow::afterLaunchTasks() } } +bool LibraryWindow::eventFilter(QObject *object, QEvent *event) +{ + if (this->isActiveWindow()) { + if (event->type() == QEvent::MouseButtonRelease) { + auto mouseEvent = static_cast(event); + + if (mouseEvent->button() == Qt::ForwardButton) { + forwardAction->trigger(); + event->accept(); + return true; + } + + if (mouseEvent->button() == Qt::BackButton) { + backAction->trigger(); + event->accept(); + return true; + } + } + } + + return QMainWindow::eventFilter(object, event); +} + void LibraryWindow::createSettings() { settings = new QSettings(YACReader::getSettingsPath() + "/YACReaderLibrary.ini", QSettings::IniFormat); // TODO unificar la creación del fichero de config con el servidor diff --git a/YACReaderLibrary/library_window.h b/YACReaderLibrary/library_window.h index fc12dad1..acbf4ee2 100644 --- a/YACReaderLibrary/library_window.h +++ b/YACReaderLibrary/library_window.h @@ -434,6 +434,8 @@ public slots: void afterLaunchTasks(); + bool eventFilter(QObject *object, QEvent *event) override; + private: //! @brief Exits search mode if it is active. //! @return true If the search mode was active when this function was called. diff --git a/YACReaderLibrary/main.cpp b/YACReaderLibrary/main.cpp index 170d71a9..127242dd 100644 --- a/YACReaderLibrary/main.cpp +++ b/YACReaderLibrary/main.cpp @@ -269,6 +269,8 @@ int main(int argc, char **argv) } #endif + app.installEventFilter(mw); + int ret = app.exec(); QLOG_INFO() << "YACReaderLibrary closed with exit code :" << ret;