From c90f5caef1a8302f064b600410c6f43d6351457d Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Mon, 3 Apr 2017 11:43:12 +0200 Subject: Added page action tool buttons --- src/widgets/webviewtabbar.cpp | 13 +++++++++++++ src/widgets/webviewtabbar.h | 7 +++++++ 2 files changed, 20 insertions(+) (limited to 'src/widgets') diff --git a/src/widgets/webviewtabbar.cpp b/src/widgets/webviewtabbar.cpp index 71d3c92..9684e11 100644 --- a/src/widgets/webviewtabbar.cpp +++ b/src/widgets/webviewtabbar.cpp @@ -56,6 +56,9 @@ WebViewTabBar::WebViewTabBar(QWidget *parent) : }); addAction(tabRightAction); } + + m_signalMapper = new QSignalMapper(this); + connect(m_signalMapper, SIGNAL(mapped(int)), this, SLOT(webAction(int))); } WebViewTabBar::~WebViewTabBar() @@ -65,6 +68,11 @@ WebViewTabBar::~WebViewTabBar() m_views.clear(); } +QSignalMapper *WebViewTabBar::signalMapper() +{ + return m_signalMapper; +} + int WebViewTabBar::addTab(QWebEngineProfile *profile, const QUrl &url) { WebView *view = new WebView(0); @@ -132,3 +140,8 @@ void WebViewTabBar::updateVectorArrangement(int from, int to) { m_views.move(from, to); } + +void WebViewTabBar::webAction(int action) +{ + currentView()->pageAction(static_cast(action))->trigger(); +} diff --git a/src/widgets/webviewtabbar.h b/src/widgets/webviewtabbar.h index f7772e0..bf39efe 100644 --- a/src/widgets/webviewtabbar.h +++ b/src/widgets/webviewtabbar.h @@ -23,6 +23,7 @@ #include #include "webengine/webview.h" +#include class WebViewTabBar : public QTabBar { @@ -33,6 +34,8 @@ public: ~WebViewTabBar(); void setProfile(QWebEngineProfile *profile); + + QSignalMapper *signalMapper(); WebView *currentView(); signals: @@ -42,6 +45,8 @@ public slots: int addTab(QWebEngineProfile *profile, const QUrl &url); void removeTab(int index); + void webAction(int action); + protected: QSize tabSizeHint(int index) const; @@ -54,6 +59,8 @@ private slots: private: // store all views in a vector since tabs can only store a QVariant, and that can't easily take a pointer QVector m_views; + + QSignalMapper *m_signalMapper; }; #endif // WEBVIEWTABBAR_H -- cgit v1.2.1