aboutsummaryrefslogtreecommitdiff
path: root/mainwindow.cpp
diff options
context:
space:
mode:
authorFelix (xq) Queißner <git@mq32.de>2020-06-06 20:12:38 +0200
committerFelix (xq) Queißner <git@mq32.de>2020-06-06 20:12:38 +0200
commit9e1995b8672136b196bc4dccdb127e20156a630c (patch)
treed6a5bf13f316ffc4659dd30c8981e65ba63ff48e /mainwindow.cpp
parent0fd0f2d919d748280c48383840fe7c4d988bbd00 (diff)
downloadkristall-9e1995b8672136b196bc4dccdb127e20156a630c.tar.gz
Starts to implement history management.
Diffstat (limited to 'mainwindow.cpp')
-rw-r--r--mainwindow.cpp38
1 files changed, 36 insertions, 2 deletions
diff --git a/mainwindow.cpp b/mainwindow.cpp
index 998a7d8..4cab251 100644
--- a/mainwindow.cpp
+++ b/mainwindow.cpp
@@ -3,6 +3,8 @@
#include "browsertab.hpp"
#include <memory>
+#include <QShortcut>
+#include <QKeySequence>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
@@ -19,9 +21,20 @@ MainWindow::MainWindow(QWidget *parent) :
ui->favourites_view->setModel(&favourites);
- this->ui->history_window->setVisible(false);
+ // this->ui->history_window->setVisible(false);
this->ui->clientcert_window->setVisible(false);
this->ui->bookmarks_window->setVisible(true);
+
+
+ auto add_shortcut = [this](QString const & sequence, void (MainWindow::*fun)())
+ {
+ auto * shortcut = new QShortcut(QKeySequence(sequence), this);
+ connect(shortcut, &QShortcut::activated, this, fun);
+ };
+
+ add_shortcut("Ctrl+T", &MainWindow::on_new_tab);
+ add_shortcut("Ctrl+W", &MainWindow::on_close_tab);
+ add_shortcut("F5", &MainWindow::on_refresh);
}
MainWindow::~MainWindow()
@@ -49,7 +62,7 @@ BrowserTab * MainWindow::addEmptyTab(bool focus_new)
BrowserTab * MainWindow::addNewTab(bool focus_new, QUrl const & url)
{
auto tab = addEmptyTab(focus_new);
- tab->navigateTo(url);
+ tab->navigateTo(url, BrowserTab::PushImmediate);
return tab;
}
@@ -127,3 +140,24 @@ void MainWindow::on_tab_locationChanged(const QUrl &url)
this->ui->browser_tabs->setTabToolTip(index, url.toString());
}
}
+
+void MainWindow::on_new_tab()
+{
+ this->addEmptyTab(true);
+}
+
+void MainWindow::on_refresh()
+{
+ BrowserTab * tab = qobject_cast<BrowserTab*>(this->ui->browser_tabs->currentWidget());
+ if(tab != nullptr) {
+ // tab->reloadPage();
+ }
+}
+
+void MainWindow::on_close_tab()
+{
+ BrowserTab * tab = qobject_cast<BrowserTab*>(this->ui->browser_tabs->currentWidget());
+ if(tab != nullptr) {
+ delete tab;
+ }
+}