aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mainwindow.cpp5
-rw-r--r--src/settings.cpp5
-rw-r--r--src/settings.h1
-rw-r--r--src/widgets/webviewtabbar.cpp37
-rw-r--r--src/widgets/webviewtabbar.h2
-rw-r--r--test/config.ini3
6 files changed, 51 insertions, 2 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 45d0b55..1f979ca 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -139,8 +139,9 @@ void MainWindow::about()
"<p><i>yet another Qute browser</i></p>"
"<p>Copyright (C) 2017 Xian Nox</p>"
"<p>This program comes with ABSOLUTELY NO WARRANTY. "
- "This is free software, and you are welcome to redistribute it under the conditions set by the GNU GPLv3.</p>")
- .arg(qApp->applicationVersion()));
+ "This is free software, and you are welcome to redistribute it under the conditions set by the GNU GPLv3.</p>"
+ "<p>Configuration lives in: %2</p>")
+ .arg(qApp->applicationVersion()).arg(Settings::staticFilePath()));
}
void MainWindow::loadProfile(const QString &name)
diff --git a/src/settings.cpp b/src/settings.cpp
index 0d69e23..25cc6c0 100644
--- a/src/settings.cpp
+++ b/src/settings.cpp
@@ -34,6 +34,11 @@ void Settings::setFilePath(const QString &path)
_path = path;
}
+QString Settings::staticFilePath()
+{
+ return _path;
+}
+
QVariant Settings::value(const QString &key, const QVariant &defaultValue) const
{
QString value = QSettings::value(key, defaultValue).toString();
diff --git a/src/settings.h b/src/settings.h
index f10cec7..01eff6b 100644
--- a/src/settings.h
+++ b/src/settings.h
@@ -31,6 +31,7 @@ public:
explicit Settings(QObject *parent = 0);
static void setFilePath(const QString &path);
+ static QString staticFilePath();
QVariant value(const QString &key, const QVariant &defaultValue = QVariant()) const;
//void setValue(const QString &key, const QVariant &value);
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);
+}
diff --git a/src/widgets/webviewtabbar.h b/src/widgets/webviewtabbar.h
index 260100b..9029bf5 100644
--- a/src/widgets/webviewtabbar.h
+++ b/src/widgets/webviewtabbar.h
@@ -48,8 +48,10 @@ private slots:
void handleTabClose(int index);
void updateTabText(WebView *view, const QString &text);
+ void updateVectorArrangement(int from, int to);
private:
+ // store all views in a vector since tabs can only store a QVariant, and that can't easily take a pointer
QVector<WebView*> m_views;
};
diff --git a/test/config.ini b/test/config.ini
index afba450..38bd119 100644
--- a/test/config.ini
+++ b/test/config.ini
@@ -15,3 +15,6 @@ width=1280
[shortcuts]
bookmarks=Ctrl+Shift+B
+tabClose=Ctrl+X
+tabLeft=Shift+Left
+tabRight=Shift+Right