summaryrefslogtreecommitdiffstats
path: root/examples/webenginewidgets/demobrowser/webview.cpp
diff options
context:
space:
mode:
authorPeter Varga <pvarga@inf.u-szeged.hu>2016-03-03 17:28:52 +0100
committerPeter Varga <pvarga@inf.u-szeged.hu>2016-03-31 07:40:15 +0000
commit0a4b9df53f0ede439435b0408558e1038c619a67 (patch)
tree0c285ad9a68f90257d013e2df7996ac45b1b4bae /examples/webenginewidgets/demobrowser/webview.cpp
parent76c61aa1400ef2def204c3732e30e08e40631e8d (diff)
Add icon property and iconChanged signal to QWebEnginePage
The new API makes possible to access downloaded icons via QWebEnginePage. Thus the QNAM usage for downloading favicons and the corresponding workaround due to authentication are removed from the demobrowser. Change-Id: I9fdcc7ee7673f7caa239d932f20a51c74b24763f Task-number: QTBUG-51179 Reviewed-by: Leena Miettinen <riitta-leena.miettinen@theqtcompany.com> Reviewed-by: Kai Koehne <kai.koehne@theqtcompany.com>
Diffstat (limited to 'examples/webenginewidgets/demobrowser/webview.cpp')
-rw-r--r--examples/webenginewidgets/demobrowser/webview.cpp45
1 files changed, 8 insertions, 37 deletions
diff --git a/examples/webenginewidgets/demobrowser/webview.cpp b/examples/webenginewidgets/demobrowser/webview.cpp
index cac34577c..8033c3ff5 100644
--- a/examples/webenginewidgets/demobrowser/webview.cpp
+++ b/examples/webenginewidgets/demobrowser/webview.cpp
@@ -281,11 +281,8 @@ void WebPage::authenticationRequired(const QUrl &requestUrl, QAuthenticator *aut
passwordDialog.introLabel->setWordWrap(true);
if (dialog.exec() == QDialog::Accepted) {
- QByteArray key = BrowserApplication::authenticationKey(requestUrl, auth->realm());
auth->setUser(passwordDialog.userNameLineEdit->text());
auth->setPassword(passwordDialog.passwordLineEdit->text());
- auth->setOption("key", key);
- BrowserApplication::instance()->setLastAuthenticator(auth);
} else {
// Set authenticator null if dialog is cancelled
*auth = QAuthenticator();
@@ -312,12 +309,8 @@ void WebPage::proxyAuthenticationRequired(const QUrl &requestUrl, QAuthenticator
proxyDialog.introLabel->setWordWrap(true);
if (dialog.exec() == QDialog::Accepted) {
- QString user = proxyDialog.userNameLineEdit->text();
- QByteArray key = BrowserApplication::proxyAuthenticationKey(user, proxyHost, auth->realm());
- auth->setUser(user);
+ auth->setUser(proxyDialog.userNameLineEdit->text());
auth->setPassword(proxyDialog.passwordLineEdit->text());
- auth->setOption("key", key);
- BrowserApplication::instance()->setLastProxyAuthenticator(auth);
} else {
// Set authenticator null if dialog is cancelled
*auth = QAuthenticator();
@@ -328,7 +321,6 @@ WebView::WebView(QWidget* parent)
: QWebEngineView(parent)
, m_progress(0)
, m_page(0)
- , m_iconReply(0)
{
connect(this, SIGNAL(loadProgress(int)),
this, SLOT(setProgress(int)));
@@ -369,8 +361,8 @@ void WebView::setPage(WebPage *_page)
#endif
connect(page(), SIGNAL(loadingUrl(QUrl)),
this, SIGNAL(urlChanged(QUrl)));
- connect(page(), SIGNAL(iconUrlChanged(QUrl)),
- this, SLOT(onIconUrlChanged(QUrl)));
+ connect(page(), SIGNAL(iconChanged(QIcon)),
+ this, SLOT(onIconChanged(QIcon)));
connect(page(), &WebPage::featurePermissionRequested, this, &WebView::onFeaturePermissionRequested);
#if defined(QWEBENGINEPAGE_UNSUPPORTEDCONTENT)
page()->setForwardUnsupportedContent(true);
@@ -457,33 +449,12 @@ QUrl WebView::url() const
return m_initialUrl;
}
-QIcon WebView::icon() const
+void WebView::onIconChanged(const QIcon &icon)
{
- if (!m_icon.isNull())
- return m_icon;
- return BrowserApplication::instance()->defaultIcon();
-}
-
-void WebView::onIconUrlChanged(const QUrl &url)
-{
- QNetworkRequest iconRequest(url);
- m_iconReply = BrowserApplication::networkAccessManager()->get(iconRequest);
- m_iconReply->setParent(this);
- connect(m_iconReply, SIGNAL(finished()), this, SLOT(iconLoaded()));
-}
-
-void WebView::iconLoaded()
-{
- m_icon = QIcon();
- if (m_iconReply) {
- QByteArray data = m_iconReply->readAll();
- QPixmap pixmap;
- pixmap.loadFromData(data);
- m_icon.addPixmap(pixmap);
- m_iconReply->deleteLater();
- m_iconReply = 0;
- }
- emit iconChanged();
+ if (icon.isNull())
+ emit iconChanged(BrowserApplication::instance()->defaultIcon());
+ else
+ emit iconChanged(icon);
}
void WebView::mousePressEvent(QMouseEvent *event)