aboutsummaryrefslogtreecommitdiff
path: root/src/widgets/webviewtabbar.cpp
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2017-02-15 16:14:44 +0100
committerAqua-sama <aqua@iserlohn-fortress.net>2017-02-15 16:14:44 +0100
commita2df2e1ebe90a329f7ae0825793de4da53ea0877 (patch)
tree9f4f60ed0d768081b5abd8941f1990ba55e2f55d /src/widgets/webviewtabbar.cpp
parentGlobal bookmarks and downloads dialogs (diff)
downloadsmolbote-a2df2e1ebe90a329f7ae0825793de4da53ea0877.tar.xz
Tab shortcuts
Config location is displayed in about window
Diffstat (limited to 'src/widgets/webviewtabbar.cpp')
-rw-r--r--src/widgets/webviewtabbar.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/widgets/webviewtabbar.cpp b/src/widgets/webviewtabbar.cpp
index c091e56..db44bc9 100644
--- a/src/widgets/webviewtabbar.cpp
+++ b/src/widgets/webviewtabbar.cpp
@@ -19,13 +19,44 @@
******************************************************************************/
#include "webviewtabbar.h"
+#include "settings.h"
+#include <QAction>
WebViewTabBar::WebViewTabBar(QWidget *parent) :
QTabBar(parent)
{
+ setElideMode(Qt::ElideRight);
setTabsClosable(true);
+ setMovable(true);
connect(this, SIGNAL(tabCloseRequested(int)), this, SLOT(handleTabClose(int)));
connect(this, SIGNAL(currentChanged(int)), this, SLOT(handleCurrentChanged(int)));
+ connect(this, SIGNAL(tabMoved(int,int)), this, SLOT(updateVectorArrangement(int,int)));
+
+ Settings settings;
+ if(settings.contains("shortcuts/tabClose")) {
+ QAction *tabCloseAction = new QAction(this);
+ tabCloseAction->setShortcut(QKeySequence::fromString(settings.value("shortcuts/tabClose").toString()));
+ connect(tabCloseAction, &QAction::triggered, [this]() {
+ this->handleTabClose(currentIndex());
+ });
+ addAction(tabCloseAction);
+ }
+ if(settings.contains("shortcuts/tabLeft")) {
+ QAction *tabLeftAction = new QAction(this);
+ tabLeftAction->setShortcut(QKeySequence::fromString(settings.value("shortcuts/tabLeft").toString()));
+ connect(tabLeftAction, &QAction::triggered, [this]() {
+ this->setCurrentIndex(currentIndex()-1);
+ });
+ addAction(tabLeftAction);
+ }
+ if(settings.contains("shortcuts/tabRight")) {
+ QAction *tabRightAction = new QAction(this);
+ tabRightAction->setShortcut(QKeySequence::fromString(settings.value("shortcuts/tabRight").toString()));
+ connect(tabRightAction, &QAction::triggered, [this]() {
+ this->setCurrentIndex(currentIndex()+1);
+ });
+ addAction(tabRightAction);
+ }
}
WebViewTabBar::~WebViewTabBar()
@@ -83,6 +114,7 @@ void WebViewTabBar::handleCurrentChanged(int index)
void WebViewTabBar::handleTabClose(int index)
{
+ qDebug("removing tab %i", index);
removeTab(index);
m_views.at(index)->deleteLater();
m_views.remove(index);
@@ -93,3 +125,8 @@ void WebViewTabBar::updateTabText(WebView *view, const QString &text)
int index = m_views.indexOf(view);
setTabText(index, text);
}
+
+void WebViewTabBar::updateVectorArrangement(int from, int to)
+{
+ m_views.move(from, to);
+}