aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2017-09-30 11:34:05 +0200
committerAqua-sama <aqua@iserlohn-fortress.net>2017-09-30 11:34:05 +0200
commit1e3b29b9ac6a6b467bc28ae6c6b20b9dbdd92d03 (patch)
tree4dbc2ed2756da43fe3c1df21087cbc24371c1570
parentFixed bug with tab bar not showing up (diff)
downloadsmolbote-1e3b29b9ac6a6b467bc28ae6c6b20b9dbdd92d03.tar.xz
Cleaned up WebViewTabBar
-rw-r--r--src/mainwindow.cpp6
-rw-r--r--src/widgets/webviewtabbar.cpp26
-rw-r--r--src/widgets/webviewtabbar.h12
3 files changed, 4 insertions, 40 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 050384b..4b43f49 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -87,8 +87,10 @@ MainWindow::MainWindow(QWidget *parent) :
QToolButton *homepageButton = new QToolButton(this);
homepageButton->setIcon(style()->standardIcon(QStyle::SP_DirHomeIcon));
- connect(homepageButton, SIGNAL(clicked()), tabBar->signalMapper(), SLOT(map()));
- tabBar->signalMapper()->setMapping(homepageButton, WebViewTabBar::Homepage);
+ connect(homepageButton, &QToolButton::clicked, this, [&]() {
+ tabBar->currentView()->load(tabBar->profile()->homepage());
+ });
+
navigationToolBar->addWidget(m_backButton);
navigationToolBar->addWidget(m_forwardButton);
navigationToolBar->addWidget(m_reloadButton);
diff --git a/src/widgets/webviewtabbar.cpp b/src/widgets/webviewtabbar.cpp
index e662837..1367e40 100644
--- a/src/widgets/webviewtabbar.cpp
+++ b/src/widgets/webviewtabbar.cpp
@@ -56,9 +56,6 @@ WebViewTabBar::WebViewTabBar(WebEngineProfile *profile, QWidget *parent) :
connect(tabRightShortcut, &QShortcut::activated, [this]() {
this->setCurrentIndex(currentIndex()+1);
});
-
- m_signalMapper = new QSignalMapper(this);
- connect(m_signalMapper, SIGNAL(mapped(int)), this, SLOT(webAction(int)));
}
WebViewTabBar::~WebViewTabBar()
@@ -68,11 +65,6 @@ WebViewTabBar::~WebViewTabBar()
m_views.clear();
}
-QSignalMapper *WebViewTabBar::signalMapper()
-{
- return m_signalMapper;
-}
-
int WebViewTabBar::addTab(const QUrl &url)
{
WebView *view = new WebView(0);
@@ -166,21 +158,3 @@ void WebViewTabBar::updateVectorArrangement(int from, int to)
{
m_views.move(from, to);
}
-
-void WebViewTabBar::webAction(int action)
-{
- switch (action) {
- case WebActions::Back:
- currentView()->pageAction(QWebEnginePage::Back)->trigger();
- break;
- case WebActions::Forward:
- currentView()->pageAction(QWebEnginePage::Forward)->trigger();
- break;
- case WebActions::Reload:
- currentView()->pageAction(QWebEnginePage::Reload)->trigger();
- break;
- case WebActions::Homepage:
- currentView()->load(m_profile->homepage());
- break;
- }
-}
diff --git a/src/widgets/webviewtabbar.h b/src/widgets/webviewtabbar.h
index 4682a94..d73608c 100644
--- a/src/widgets/webviewtabbar.h
+++ b/src/widgets/webviewtabbar.h
@@ -23,7 +23,6 @@
#include <QTabBar>
#include "webengine/webview.h"
-#include <QSignalMapper>
#include "webengine/webengineprofile.h"
class WebViewTabBar : public QTabBar
@@ -31,20 +30,12 @@ class WebViewTabBar : public QTabBar
Q_OBJECT
public:
- enum WebActions {
- Back = QWebEnginePage::Back,
- Forward = QWebEnginePage::Forward,
- Reload = QWebEnginePage::Reload,
- Homepage
- };
-
explicit WebViewTabBar(WebEngineProfile *profile = nullptr, QWidget *parent = 0);
~WebViewTabBar();
void setProfile(WebEngineProfile *profile);
WebEngineProfile *profile();
- QSignalMapper *signalMapper();
WebView *currentView();
signals:
@@ -54,8 +45,6 @@ public slots:
int addTab(const QUrl &url);
void removeTab(int index);
- void webAction(int action);
-
protected:
void contextMenuEvent(QContextMenuEvent *event);
QSize tabSizeHint(int index) const;
@@ -70,7 +59,6 @@ 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;
- QSignalMapper *m_signalMapper;
WebEngineProfile *m_profile = nullptr;
};