Add forward/back functionality to mouse buttons (#490)

* Add forward/back functionality to mouse buttons
* Prevent other widgets from stealing mouseclicks for buttons 4 & 5
This commit is contained in:
Xaltonon 2018-05-13 00:50:01 -07:00 committed by xarkes
parent 03b762a77a
commit 58226dda0e
3 changed files with 31 additions and 0 deletions

View File

@ -83,6 +83,7 @@ CutterApplication::CutterApplication(int &argc, char **argv) : QApplication(argc
}
mainWindow = new MainWindow();
installEventFilter(mainWindow);
if (args.empty()) {
if (analLevelSpecified) {

View File

@ -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<QMouseEvent*>(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);

View File

@ -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;