diff options
Diffstat (limited to 'examples/webenginewidgets/simplebrowser/webview.cpp')
-rw-r--r-- | examples/webenginewidgets/simplebrowser/webview.cpp | 48 |
1 files changed, 5 insertions, 43 deletions
diff --git a/examples/webenginewidgets/simplebrowser/webview.cpp b/examples/webenginewidgets/simplebrowser/webview.cpp index de93bc0c4..24835b10b 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) { @@ -133,6 +118,10 @@ QWebEngineView *WebView::createWindow(QWebEnginePage::WebWindowType type) BrowserWindow *mainWindow = qobject_cast<BrowserWindow*>(window()); return mainWindow->tabWidget()->createTab(); } + case QWebEnginePage::WebBrowserBackgroundTab: { + BrowserWindow *mainWindow = qobject_cast<BrowserWindow*>(window()); + return mainWindow->tabWidget()->createTab(false); + } case QWebEnginePage::WebBrowserWindow: { BrowserWindow *mainWindow = new BrowserWindow(); Browser::instance().addWindow(mainWindow); @@ -162,30 +151,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); -} |