From 9e1995b8672136b196bc4dccdb127e20156a630c Mon Sep 17 00:00:00 2001 From: "Felix (xq) Queißner" Date: Sat, 6 Jun 2020 20:12:38 +0200 Subject: Starts to implement history management. --- mainwindow.cpp | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) (limited to 'mainwindow.cpp') 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 +#include +#include 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(this->ui->browser_tabs->currentWidget()); + if(tab != nullptr) { + // tab->reloadPage(); + } +} + +void MainWindow::on_close_tab() +{ + BrowserTab * tab = qobject_cast(this->ui->browser_tabs->currentWidget()); + if(tab != nullptr) { + delete tab; + } +} -- cgit v1.2.3