aboutsummaryrefslogtreecommitdiff
path: root/src/mainwindow/window.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mainwindow/window.cpp')
-rw-r--r--src/mainwindow/window.cpp37
1 files changed, 36 insertions, 1 deletions
diff --git a/src/mainwindow/window.cpp b/src/mainwindow/window.cpp
index 0c52076..735df4a 100644
--- a/src/mainwindow/window.cpp
+++ b/src/mainwindow/window.cpp
@@ -11,8 +11,11 @@
#include "webengine/webview.h"
#include "widgets/tabwidget.h"
#include <QUrl>
+#include <QToolButton>
+#include <QStyle>
+#include <QAction>
-Window::Window(QWidget *parent, Qt::WindowFlags flags)
+Window::Window(const QHash<QString, QString> &config, QWidget *parent, Qt::WindowFlags flags)
: QMdiSubWindow(parent, flags)
, tabWidget(new TabWidget(this))
{
@@ -22,6 +25,38 @@ Window::Window(QWidget *parent, Qt::WindowFlags flags)
resize(800, 600);
setWidget(tabWidget);
+ // new tab button
+ auto *newTab_button = new QToolButton(this);
+ newTab_button->setIcon(style()->standardIcon(QStyle::SP_FileIcon));
+ newTab_button->setToolTip(tr("Add tab"));
+ newTab_button->setShortcut(QKeySequence(config.value("window.shortcuts.new")));
+ connect(newTab_button, &QToolButton::clicked, this, [=]() {
+ addTab(WebProfile::defaultProfile()->newtab());
+ });
+ tabWidget->setCornerWidget(newTab_button, Qt::TopRightCorner);
+
+ // general actions
+ auto *closeTab_action = new QAction(this);
+ closeTab_action->setShortcut(QKeySequence(config.value("window.shortcuts.close")));
+ connect(closeTab_action, &QAction::triggered, this, [=]() {
+ tabWidget->deleteTab(tabWidget->currentIndex());
+ });
+ addAction(closeTab_action);
+
+ auto *leftTab_action = new QAction(this);
+ leftTab_action->setShortcut(QKeySequence(config.value("window.shortcuts.left")));
+ connect(leftTab_action, &QAction::triggered, this, [=]() {
+ tabWidget->setCurrentIndex(qMax(0, tabWidget->currentIndex() - 1));
+ });
+ addAction(leftTab_action);
+
+ auto *rightTab_action = new QAction(this);
+ rightTab_action->setShortcut(QKeySequence(config.value("window.shortcuts.right")));
+ connect(rightTab_action, &QAction::triggered, this, [=]() {
+ tabWidget->setCurrentIndex(qMin(tabWidget->currentIndex() + 1, tabWidget->count() - 1));
+ });
+ addAction(rightTab_action);
+
connect(tabWidget, &TabWidget::currentChanged, [this](int index) {
if(index < 0) {
// last tab has been closed