summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorMichal Klocek <michal.klocek@theqtcompany.com>2015-12-04 17:51:54 +0100
committerSimon Hausmann <simon.hausmann@theqtcompany.com>2015-12-07 13:41:47 +0000
commit99bb80faed580fd3d61171541bc3b1c7601366ff (patch)
treed85f473091f43790184836ac88d58c5e19a2c23e /examples
parent4c303a073b5a408e99b9221aa07a46a3170245f4 (diff)
Fix unclosable tabs in demobrowser
Switching to private profile back and forth brakes interactions with tabs. Connect signals every time new WebPage is created. Change-Id: I1765171116a3b9b9caba6ef2233289f50b315e62 Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
Diffstat (limited to 'examples')
-rw-r--r--examples/webenginewidgets/demobrowser/tabwidget.cpp59
-rw-r--r--examples/webenginewidgets/demobrowser/tabwidget.h2
2 files changed, 36 insertions, 25 deletions
diff --git a/examples/webenginewidgets/demobrowser/tabwidget.cpp b/examples/webenginewidgets/demobrowser/tabwidget.cpp
index 95b79aaa..cb017e62 100644
--- a/examples/webenginewidgets/demobrowser/tabwidget.cpp
+++ b/examples/webenginewidgets/demobrowser/tabwidget.cpp
@@ -461,6 +461,36 @@ int TabWidget::webViewIndex(WebView *webView) const
return index;
}
+void TabWidget::setupPage(QWebEnginePage* page)
+{
+ connect(page, SIGNAL(windowCloseRequested()),
+ this, SLOT(windowCloseRequested()));
+ connect(page, SIGNAL(geometryChangeRequested(QRect)),
+ this, SIGNAL(geometryChangeRequested(QRect)));
+#if defined(QWEBENGINEPAGE_PRINTREQUESTED)
+ connect(page, SIGNAL(printRequested(QWebEngineFrame*)),
+ this, SIGNAL(printRequested(QWebEngineFrame*)));
+#endif
+#if defined(QWEBENGINEPAGE_MENUBARVISIBILITYCHANGEREQUESTED)
+ connect(page, SIGNAL(menuBarVisibilityChangeRequested(bool)),
+ this, SIGNAL(menuBarVisibilityChangeRequested(bool)));
+#endif
+#if defined(QWEBENGINEPAGE_STATUSBARVISIBILITYCHANGEREQUESTED)
+ connect(page, SIGNAL(statusBarVisibilityChangeRequested(bool)),
+ this, SIGNAL(statusBarVisibilityChangeRequested(bool)));
+#endif
+#if defined(QWEBENGINEPAGE_TOOLBARVISIBILITYCHANGEREQUESTED)
+ connect(page, SIGNAL(toolBarVisibilityChangeRequested(bool)),
+ this, SIGNAL(toolBarVisibilityChangeRequested(bool)));
+#endif
+
+ // webview actions
+ for (int i = 0; i < m_actions.count(); ++i) {
+ WebActionMapper *mapper = m_actions[i];
+ mapper->addChild(page->action(mapper->webAction()));
+ }
+}
+
WebView *TabWidget::newTab(bool makeCurrent)
{
// line edit
@@ -508,35 +538,13 @@ WebView *TabWidget::newTab(bool makeCurrent)
this, SLOT(webViewTitleChanged(QString)));
connect(webView, SIGNAL(urlChanged(QUrl)),
this, SLOT(webViewUrlChanged(QUrl)));
- connect(webView->page(), SIGNAL(windowCloseRequested()),
- this, SLOT(windowCloseRequested()));
- connect(webView->page(), SIGNAL(geometryChangeRequested(QRect)),
- this, SIGNAL(geometryChangeRequested(QRect)));
-#if defined(QWEBENGINEPAGE_PRINTREQUESTED)
- connect(webView->page(), SIGNAL(printRequested(QWebEngineFrame*)),
- this, SIGNAL(printRequested(QWebEngineFrame*)));
-#endif
-#if defined(QWEBENGINEPAGE_MENUBARVISIBILITYCHANGEREQUESTED)
- connect(webView->page(), SIGNAL(menuBarVisibilityChangeRequested(bool)),
- this, SIGNAL(menuBarVisibilityChangeRequested(bool)));
-#endif
-#if defined(QWEBENGINEPAGE_STATUSBARVISIBILITYCHANGEREQUESTED)
- connect(webView->page(), SIGNAL(statusBarVisibilityChangeRequested(bool)),
- this, SIGNAL(statusBarVisibilityChangeRequested(bool)));
-#endif
-#if defined(QWEBENGINEPAGE_TOOLBARVISIBILITYCHANGEREQUESTED)
- connect(webView->page(), SIGNAL(toolBarVisibilityChangeRequested(bool)),
- this, SIGNAL(toolBarVisibilityChangeRequested(bool)));
-#endif
+
+
addTab(webView, tr("(Untitled)"));
if (makeCurrent)
setCurrentWidget(webView);
- // webview actions
- for (int i = 0; i < m_actions.count(); ++i) {
- WebActionMapper *mapper = m_actions[i];
- mapper->addChild(webView->page()->action(mapper->webAction()));
- }
+ setupPage(webView->page());
if (count() == 1)
currentChanged(currentIndex());
@@ -642,6 +650,7 @@ void TabWidget::setProfile(QWebEngineProfile *profile)
QWidget *tabWidget = widget(i);
if (WebView *tab = qobject_cast<WebView*>(tabWidget)) {
WebPage* webPage = new WebPage(m_profile, tab);
+ setupPage(webPage);
webPage->load(tab->page()->url());
tab->setPage(webPage);
}
diff --git a/examples/webenginewidgets/demobrowser/tabwidget.h b/examples/webenginewidgets/demobrowser/tabwidget.h
index b0013113..1ba9afe4 100644
--- a/examples/webenginewidgets/demobrowser/tabwidget.h
+++ b/examples/webenginewidgets/demobrowser/tabwidget.h
@@ -220,6 +220,8 @@ private slots:
void fullScreenRequested(QWebEngineFullScreenRequest request);
private:
+ void setupPage(QWebEnginePage* page);
+
QAction *m_recentlyClosedTabsAction;
QAction *m_newTabAction;
QAction *m_closeTabAction;