diff options
author | Kai Koehne <kai.koehne@theqtcompany.com> | 2016-04-06 17:21:16 +0200 |
---|---|---|
committer | Kai Koehne <kai.koehne@qt.io> | 2016-04-20 13:02:34 +0000 |
commit | 7d76c6b2cd8989f134f678789bba2f13ed019153 (patch) | |
tree | 32d2e8b1cef5067bf389ca420c0f0698eba64051 /examples/webenginewidgets/simplebrowser/webview.cpp | |
parent | ddc4c40e2dcba81d36c9a4c445f1540b90403997 (diff) |
SimpleBrowser: Use new QWebEnginePage::icon API
Change-Id: I38d16a57116517aee21f6f84c5fca82192cb1572
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@theqtcompany.com>
Reviewed-by: Peter Varga <pvarga@inf.u-szeged.hu>
Reviewed-by: Michal Klocek <michal.klocek@theqtcompany.com>
Diffstat (limited to 'examples/webenginewidgets/simplebrowser/webview.cpp')
-rw-r--r-- | examples/webenginewidgets/simplebrowser/webview.cpp | 44 |
1 files changed, 1 insertions, 43 deletions
diff --git a/examples/webenginewidgets/simplebrowser/webview.cpp b/examples/webenginewidgets/simplebrowser/webview.cpp index 559daca61..d92545620 100644 --- a/examples/webenginewidgets/simplebrowser/webview.cpp +++ b/examples/webenginewidgets/simplebrowser/webview.cpp @@ -47,7 +47,6 @@ #include <QContextMenuEvent> #include <QMenu> #include <QMessageBox> -#include <QNetworkReply> #include <QTimer> WebView::WebView(QWidget *parent) @@ -59,11 +58,10 @@ WebView::WebView(QWidget *parent) }); connect(this, &QWebEngineView::loadFinished, [this](bool success) { if (!success) { - qWarning() << "Could not load page: " << url(); m_loadProgress = 0; } }); - connect(this, &QWebEngineView::iconUrlChanged, this, &WebView::handleIconUrlChanged); + connect(this, &QWebEngineView::renderProcessTerminated, [this](QWebEnginePage::RenderProcessTerminationStatus termStatus, int statusCode) { QString status; @@ -95,13 +93,6 @@ void WebView::setPage(WebPage *page) QWebEngineView::setPage(page); } -QIcon WebView::icon() const -{ - if (!m_icon.isNull()) - return m_icon; - return QIcon(QLatin1String(":defaulticon.png")); -} - int WebView::loadProgress() const { return m_loadProgress; @@ -120,12 +111,6 @@ bool WebView::isWebActionEnabled(QWebEnginePage::WebAction webAction) const return page()->action(webAction)->isEnabled(); } -QNetworkAccessManager &WebView::networkAccessManager() -{ - static QNetworkAccessManager networkAccessManager; - return networkAccessManager; -} - QWebEngineView *WebView::createWindow(QWebEnginePage::WebWindowType type) { switch (type) { @@ -164,30 +149,3 @@ void WebView::contextMenuEvent(QContextMenuEvent *event) menu->popup(event->globalPos()); } -void WebView::handleIconUrlChanged(const QUrl &url) -{ - QNetworkRequest iconRequest(url); -#ifndef QT_NO_OPENSSL - QSslConfiguration conf = iconRequest.sslConfiguration(); - conf.setPeerVerifyMode(QSslSocket::VerifyNone); - iconRequest.setSslConfiguration(conf); -#endif - QNetworkReply *iconReply = networkAccessManager().get(iconRequest); - iconReply->setParent(this); - connect(iconReply, &QNetworkReply::finished, this, &WebView::handleIconLoaded); -} - -void WebView::handleIconLoaded() -{ - QNetworkReply *iconReply = qobject_cast<QNetworkReply*>(sender()); - if (iconReply && iconReply->error() == QNetworkReply::NoError) { - QByteArray data = iconReply->readAll(); - QPixmap pixmap; - pixmap.loadFromData(data); - m_icon.addPixmap(pixmap); - iconReply->deleteLater(); - } else { - m_icon = QIcon(QStringLiteral(":defaulticon.png")); - } - emit iconChanged(m_icon); -} |