diff --git a/src/CutterApplication.cpp b/src/CutterApplication.cpp index 9f208670..406cbe15 100644 --- a/src/CutterApplication.cpp +++ b/src/CutterApplication.cpp @@ -83,6 +83,7 @@ CutterApplication::CutterApplication(int &argc, char **argv) : QApplication(argc } mainWindow = new MainWindow(); + installEventFilter(mainWindow); if (args.empty()) { if (analLevelSpecified) { diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index 28dc933d..f8c964fe 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -732,6 +732,33 @@ void MainWindow::projectSaved(const QString &name) addOutput(tr("Project saved: ") + name); } +void MainWindow::mousePressEvent(QMouseEvent *event) +{ + switch (event->button()) { + case Qt::BackButton: + Core()->seekPrev(); + break; + case Qt::ForwardButton: + Core()->seekNext(); + break; + default: + break; + } +} + +bool MainWindow::eventFilter(QObject *, QEvent *event) +{ + if (event->type() == QEvent::MouseButtonPress) { + QMouseEvent *mouseEvent = static_cast(event); + if (mouseEvent->button() == Qt::ForwardButton || mouseEvent->button() == Qt::BackButton) { + mousePressEvent(mouseEvent); + return true; + } + } + + return false; +} + void MainWindow::addToDockWidgetList(QDockWidget *dockWidget) { this->dockWidgets.push_back(dockWidget); diff --git a/src/MainWindow.h b/src/MainWindow.h index f6ae6f86..edf25141 100644 --- a/src/MainWindow.h +++ b/src/MainWindow.h @@ -154,6 +154,9 @@ private slots: void projectSaved(const QString &name); + void mousePressEvent(QMouseEvent *event) override; + bool eventFilter(QObject *object, QEvent *event); + private: CutterCore *core;