aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMike Skec <skec@protonmail.ch>2020-12-31 11:26:14 +1100
committerFelix Queißner <felix@ib-queissner.de>2020-12-31 10:13:49 +0100
commitedbd2707620bd0d948bc71a554ec35d63b995e45 (patch)
tree5206d713e72b6afe1d9062b1c2cdfc383bf46d86 /src
parent7c3617adb92c05b23a44ca1829c81f9f4139d1a4 (diff)
downloadkristall-edbd2707620bd0d948bc71a554ec35d63b995e45.tar.gz
#51: mouse buttons 4/5 for back/forward
Diffstat (limited to 'src')
-rw-r--r--src/browsertab.cpp4
-rw-r--r--src/browsertab.hpp2
-rw-r--r--src/mainwindow.cpp23
-rw-r--r--src/mainwindow.hpp2
4 files changed, 27 insertions, 4 deletions
diff --git a/src/browsertab.cpp b/src/browsertab.cpp
index 15c4686..65fde7f 100644
--- a/src/browsertab.cpp
+++ b/src/browsertab.cpp
@@ -155,7 +155,7 @@ void BrowserTab::navigateBack(const QModelIndex &history_index)
}
}
-void BrowserTab::navOneBackback()
+void BrowserTab::navOneBackward()
{
navigateBack(history.oneBackward(current_history_index));
}
@@ -1039,7 +1039,7 @@ void BrowserTab::on_requestProgress(qint64 transferred)
void BrowserTab::on_back_button_clicked()
{
- navOneBackback();
+ navOneBackward();
}
void BrowserTab::on_forward_button_clicked()
diff --git a/src/browsertab.hpp b/src/browsertab.hpp
index 6ff1e55..4e7b627 100644
--- a/src/browsertab.hpp
+++ b/src/browsertab.hpp
@@ -55,7 +55,7 @@ public:
void navigateBack(const QModelIndex &history_index);
- void navOneBackback();
+ void navOneBackward();
void navOneForward();
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();
}
}
diff --git a/src/mainwindow.hpp b/src/mainwindow.hpp
index 58c6c3e..6a1dce7 100644
--- a/src/mainwindow.hpp
+++ b/src/mainwindow.hpp
@@ -36,6 +36,8 @@ public:
void updateWindowTitle();
+ void mousePressEvent(QMouseEvent *event) override;
+
private slots:
void on_browser_tabs_currentChanged(int index);