diff options
| author | Mike Skec <skec@protonmail.ch> | 2020-12-31 11:26:14 +1100 |
|---|---|---|
| committer | Felix Queißner <felix@ib-queissner.de> | 2020-12-31 10:13:49 +0100 |
| commit | edbd2707620bd0d948bc71a554ec35d63b995e45 (patch) | |
| tree | 5206d713e72b6afe1d9062b1c2cdfc383bf46d86 /src/mainwindow.cpp | |
| parent | 7c3617adb92c05b23a44ca1829c81f9f4139d1a4 (diff) | |
#51: mouse buttons 4/5 for back/forward
Diffstat (limited to 'src/mainwindow.cpp')
| -rw-r--r-- | src/mainwindow.cpp | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index b88751c..622af0a 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -11,6 +11,7 @@ #include <QTextStream> #include <QFileDialog> #include <QInputDialog> +#include <QMouseEvent> #include "ioutil.hpp" #include "kristall.hpp" @@ -160,6 +161,26 @@ void MainWindow::updateWindowTitle() this->setWindowTitle(QString("%0 - %1").arg(tab->page_title, "Kristall")); } +void MainWindow::mousePressEvent(QMouseEvent *event) +{ + QMainWindow::mousePressEvent(event); + + BrowserTab * tab = qobject_cast<BrowserTab*>(this->ui->browser_tabs->currentWidget()); + if (tab == nullptr) return; + + // Navigate back/forward on mouse buttons 4/5 + if (event->buttons() == Qt::ForwardButton && + tab->history.oneForward(tab->current_history_index).isValid()) + { + tab->navOneForward(); + } + else if (event->buttons() == Qt::BackButton && + tab->history.oneBackward(tab->current_history_index).isValid()) + { + tab->navOneBackward(); + } +} + void MainWindow::on_browser_tabs_currentChanged(int index) { if(index >= 0) { @@ -327,7 +348,7 @@ void MainWindow::on_actionBackward_triggered() { BrowserTab * tab = qobject_cast<BrowserTab*>(this->ui->browser_tabs->currentWidget()); if(tab != nullptr) { - tab->navOneBackback(); + tab->navOneBackward(); } } |
