summaryrefslogtreecommitdiff
path: root/examples/webenginewidgets/browser/webview.cpp
diff options
context:
space:
mode:
authorPierre Rossi <pierre.rossi@theqtcompany.com>2015-05-15 16:10:58 +0200
committerPierre Rossi <pierre.rossi@theqtcompany.com>2015-05-15 16:13:09 +0200
commit2901cf88905cea575c6df41c3cbe06cd09491f60 (patch)
tree4d07d28864a31bd962809c067411f807c32168dd /examples/webenginewidgets/browser/webview.cpp
parentb608101c1403323750f222b3c1a7240611ee65ca (diff)
parent3b585086049089224422e6f839485be5a4235524 (diff)
downloadqtwebengine-2901cf88905cea575c6df41c3cbe06cd09491f60.tar.gz
Merge remote-tracking branch 'origin/5.5' into dev
Change-Id: I1fbcd05760cb287d1d8a0fba344ec7cfe8348c7d
Diffstat (limited to 'examples/webenginewidgets/browser/webview.cpp')
-rw-r--r--examples/webenginewidgets/browser/webview.cpp29
1 files changed, 18 insertions, 11 deletions
diff --git a/examples/webenginewidgets/browser/webview.cpp b/examples/webenginewidgets/browser/webview.cpp
index 29b0440f5..f9e75535f 100644
--- a/examples/webenginewidgets/browser/webview.cpp
+++ b/examples/webenginewidgets/browser/webview.cpp
@@ -68,8 +68,8 @@
#include <QtCore/QDebug>
#include <QtCore/QBuffer>
-WebPage::WebPage(QObject *parent)
- : QWebEnginePage(parent)
+WebPage::WebPage(QWebEngineProfile *profile, QObject *parent)
+ : QWebEnginePage(profile, parent)
, m_keyboardModifiers(Qt::NoModifier)
, m_pressedButtons(Qt::NoButton)
{
@@ -128,10 +128,11 @@ bool WebPage::certificateError(const QWebEngineCertificateError &error)
class PopupWindow : public QWidget {
Q_OBJECT
public:
- PopupWindow()
+ PopupWindow(QWebEngineProfile *profile)
: m_addressBar(new QLineEdit(this))
, m_view(new WebView(this))
{
+ m_view->setPage(new WebPage(profile, m_view));
QVBoxLayout *layout = new QVBoxLayout;
layout->setMargin(0);
setLayout(layout);
@@ -180,7 +181,7 @@ QWebEnginePage *WebPage::createWindow(QWebEnginePage::WebWindowType type)
BrowserMainWindow *mainWindow = BrowserApplication::instance()->mainWindow();
return mainWindow->currentTab()->page();
} else {
- PopupWindow *popup = new PopupWindow;
+ PopupWindow *popup = new PopupWindow(profile());
popup->setAttribute(Qt::WA_DeleteOnClose);
popup->show();
return popup->page();
@@ -304,18 +305,25 @@ void WebPage::proxyAuthenticationRequired(const QUrl &requestUrl, QAuthenticator
WebView::WebView(QWidget* parent)
: QWebEngineView(parent)
, m_progress(0)
- , m_page(new WebPage(this))
+ , m_page(0)
, m_iconReply(0)
{
- setPage(m_page);
-#if defined(QWEBENGINEPAGE_STATUSBARMESSAGE)
- connect(page(), SIGNAL(statusBarMessage(QString)),
- SLOT(setStatusBarText(QString)));
-#endif
connect(this, SIGNAL(loadProgress(int)),
this, SLOT(setProgress(int)));
connect(this, SIGNAL(loadFinished(bool)),
this, SLOT(loadFinished(bool)));
+}
+
+void WebView::setPage(WebPage *_page)
+{
+ if (m_page)
+ m_page->deleteLater();
+ m_page = _page;
+ QWebEngineView::setPage(_page);
+#if defined(QWEBENGINEPAGE_STATUSBARMESSAGE)
+ connect(page(), SIGNAL(statusBarMessage(QString)),
+ SLOT(setStatusBarText(QString)));
+#endif
connect(page(), SIGNAL(loadingUrl(QUrl)),
this, SIGNAL(urlChanged(QUrl)));
connect(page(), SIGNAL(iconUrlChanged(QUrl)),
@@ -324,7 +332,6 @@ WebView::WebView(QWidget* parent)
#if defined(QWEBENGINEPAGE_UNSUPPORTEDCONTENT)
page()->setForwardUnsupportedContent(true);
#endif
-
}
void WebView::contextMenuEvent(QContextMenuEvent *event)