aboutsummaryrefslogtreecommitdiff
path: root/src/mainwindow/window.cpp
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2018-04-19 13:21:48 +0200
committerAqua-sama <aqua@iserlohn-fortress.net>2018-04-19 13:21:48 +0200
commit892daad6789d440f60521197ae0a3f47def59256 (patch)
treedfc32d336b75a5524605f7392e4256db960dfe1b /src/mainwindow/window.cpp
parentRemoved MainWindow::titleChangedConnection (diff)
downloadsmolbote-892daad6789d440f60521197ae0a3f47def59256.tar.xz
Add Window menu
- add new tab button to tab widget - tab shortcuts are read from configuration again - updated manpage some
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