From 4823393a8348674999657670076cf73a612cfb4a Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Fri, 13 Jan 2017 17:49:52 +0100 Subject: Swapping profiles now works --- src/widgets/webviewtabbar.cpp | 17 ++++++++++++++++- src/widgets/webviewtabbar.h | 4 +++- 2 files changed, 19 insertions(+), 2 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/webviewtabbar.cpp b/src/widgets/webviewtabbar.cpp index efc8fef..666c610 100644 --- a/src/widgets/webviewtabbar.cpp +++ b/src/widgets/webviewtabbar.cpp @@ -15,9 +15,14 @@ WebViewTabBar::~WebViewTabBar() m_views.clear(); } -int WebViewTabBar::addTab(QWebEngineView *view) +int WebViewTabBar::addTab(QWebEngineProfile *profile, const QUrl &url) { + QWebEngineView *view = new QWebEngineView(0); + QWebEnginePage *page = new QWebEnginePage(profile); + view->setPage(page); + page->load(url); m_views.append(view); + //connect(view, SIGNAL(titleChanged()), this, SLOT(updateTabText())); connect(view, &QWebEngineView::titleChanged, [this, view](const QString &title) { int index = m_views.indexOf(view); @@ -27,9 +32,19 @@ int WebViewTabBar::addTab(QWebEngineView *view) int index = m_views.indexOf(view); setTabIcon(index, icon); }); + return QTabBar::addTab("New Tab"); } +void WebViewTabBar::setProfile(QWebEngineProfile *profile) +{ + for(QWebEngineView *view : m_views) { + QWebEnginePage *page = new QWebEnginePage(profile); + page->load(view->url()); + view->setPage(page); + } +} + QWebEngineView *WebViewTabBar::currentView() { return m_views.at(currentIndex()); diff --git a/src/widgets/webviewtabbar.h b/src/widgets/webviewtabbar.h index 28a9a18..f4fc6e4 100644 --- a/src/widgets/webviewtabbar.h +++ b/src/widgets/webviewtabbar.h @@ -12,7 +12,9 @@ public: WebViewTabBar(QWidget *parent = 0); ~WebViewTabBar(); - int addTab(QWebEngineView *view); + int addTab(QWebEngineProfile *profile, const QUrl &url); + void setProfile(QWebEngineProfile *profile); + QWebEngineView *currentView(); signals: -- cgit v1.2.1