diff options
author | Aqua-sama <aqua@iserlohn-fortress.net> | 2018-08-07 10:56:12 +0200 |
---|---|---|
committer | Aqua-sama <aqua@iserlohn-fortress.net> | 2018-08-07 10:56:12 +0200 |
commit | 5214a95dcc304ff673adae6ae8be471c3e3bf4bf (patch) | |
tree | 9697047774ce21ff0fbde4eb31d92f9d55f0a261 /src | |
parent | Move SubWindow to src/subwindow (diff) | |
download | smolbote-5214a95dcc304ff673adae6ae8be471c3e3bf4bf.tar.xz |
Add move tab left/right shortcut
Diffstat (limited to 'src')
-rw-r--r-- | src/subwindow/subwindow.cpp | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/src/subwindow/subwindow.cpp b/src/subwindow/subwindow.cpp index 580bf68..56bf821 100644 --- a/src/subwindow/subwindow.cpp +++ b/src/subwindow/subwindow.cpp @@ -21,6 +21,7 @@ #include <webprofile.h> #include "profilemanager.h" #include <configuration.h> +#include <QTabBar> SubWindow::SubWindow(const std::unique_ptr<Configuration> &config, QWidget *parent, Qt::WindowFlags flags) : QMdiSubWindow(parent, flags) @@ -68,7 +69,7 @@ SubWindow::SubWindow(const std::unique_ptr<Configuration> &config, QWidget *pare 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<QString>("window.shortcuts.new").value())); + newTab_button->setShortcut(QKeySequence(config->value<QString>("subwindow.shortcuts.new").value())); connect(newTab_button, &QToolButton::clicked, this, [=]() { auto index = addTab(WebProfile::defaultProfile()->newtab()); tabWidget->setCurrentIndex(index); @@ -76,22 +77,34 @@ SubWindow::SubWindow(const std::unique_ptr<Configuration> &config, QWidget *pare tabWidget->setCornerWidget(newTab_button, Qt::TopRightCorner); // general actions - auto *closeTab_shortcut = new QShortcut(QKeySequence(config->value<QString>("window.shortcuts.close").value()), this); + auto *closeTab_shortcut = new QShortcut(QKeySequence(config->value<QString>("subwindow.shortcuts.close").value()), this); connect(closeTab_shortcut, &QShortcut::activated, this, [=]() { tabWidget->deleteTab(tabWidget->currentIndex()); }); - auto *leftTab_shortcut = new QShortcut(QKeySequence(config->value<QString>("window.shortcuts.left").value()), this); + auto *leftTab_shortcut = new QShortcut(QKeySequence(config->value<QString>("subwindow.shortcuts.left").value()), this); connect(leftTab_shortcut, &QShortcut::activated, this, [=]() { tabWidget->setCurrentIndex(qMax(0, tabWidget->currentIndex() - 1)); }); - auto *rightTab_shortcut = new QShortcut(QKeySequence(config->value<QString>("window.shortcuts.right").value()), this); + auto *moveTabLeft_shortcut = new QShortcut(QKeySequence(config->value<QString>("subwindow.shortcuts.moveLeft").value()), this); + connect(moveTabLeft_shortcut, &QShortcut::activated, this, [=]() { + auto idx = tabWidget->currentIndex(); + tabWidget->tabBar()->moveTab(idx, idx - 1); + }); + + auto *rightTab_shortcut = new QShortcut(QKeySequence(config->value<QString>("subwindow.shortcuts.right").value()), this); connect(rightTab_shortcut, &QShortcut::activated, this, [=]() { tabWidget->setCurrentIndex(qMin(tabWidget->currentIndex() + 1, tabWidget->count() - 1)); }); - auto *fullScreen_shortcut = new QShortcut(QKeySequence(config->value<QString>("window.shortcuts.fullscreen").value()), this); + auto *moveTabRight_shortcut = new QShortcut(QKeySequence(config->value<QString>("subwindow.shortcuts.moveRight").value()), this); + connect(moveTabRight_shortcut, &QShortcut::activated, this, [=]() { + auto idx = tabWidget->currentIndex(); + tabWidget->tabBar()->moveTab(idx, idx + 1); + }); + + auto *fullScreen_shortcut = new QShortcut(QKeySequence(config->value<QString>("subwindow.shortcuts.fullscreen").value()), this); connect(fullScreen_shortcut, &QShortcut::activated, this, [=]() { auto *w = this->window(); if(w->isFullScreen()) |