diff options
Diffstat (limited to 'examples/widgets/browser/webview.cpp')
-rw-r--r-- | examples/widgets/browser/webview.cpp | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/examples/widgets/browser/webview.cpp b/examples/widgets/browser/webview.cpp index 7eb08d6a3..99ae2b09c 100644 --- a/examples/widgets/browser/webview.cpp +++ b/examples/widgets/browser/webview.cpp @@ -70,8 +70,10 @@ WebPage::WebPage(QObject *parent) #if defined(QWEBENGINEPAGE_SETNETWORKACCESSMANAGER) setNetworkAccessManager(BrowserApplication::networkAccessManager()); #endif +#if defined(QWEBENGINEPAGE_UNSUPPORTEDCONTENT) connect(this, SIGNAL(unsupportedContent(QNetworkReply*)), this, SLOT(handleUnsupportedContent(QNetworkReply*))); +#endif } BrowserMainWindow *WebPage::mainWindow() @@ -85,9 +87,9 @@ BrowserMainWindow *WebPage::mainWindow() return BrowserApplication::instance()->mainWindow(); } +#if defined(QWEBENGINEPAGE_ACCEPTNAVIGATIONREQUEST) bool WebPage::acceptNavigationRequest(QWebEngineFrame *frame, const QNetworkRequest &request, NavigationType type) { -#if defined(QWEBENGINEPAGE_ACCEPTNAVIGATIONREQUEST) // ctrl open in new tab // ctrl-shift open in new tab and select // ctrl-alt open in new window @@ -114,9 +116,8 @@ bool WebPage::acceptNavigationRequest(QWebEngineFrame *frame, const QNetworkRequ } m_loadingUrl = request.url(); emit loadingUrl(m_loadingUrl); -#endif - return QWebEnginePage::acceptNavigationRequest(frame, request, type); } +#endif class PopupWindow : public QWidget { Q_OBJECT @@ -195,9 +196,9 @@ QObject *WebPage::createPlugin(const QString &classId, const QUrl &url, const QS } #endif // !defined(QT_NO_UITOOLS) +#if defined(QWEBENGINEPAGE_UNSUPPORTEDCONTENT) void WebPage::handleUnsupportedContent(QNetworkReply *reply) { -#if defined(QWEBENGINEPAGE_UNSUPPORTEDCONTENT) QString errorString = reply->errorString(); if (m_loadingUrl != reply->url()) { @@ -246,8 +247,8 @@ void WebPage::handleUnsupportedContent(QNetworkReply *reply) if (m_loadingUrl == reply->url()) { mainFrame()->setHtml(html, reply->url()); } -#endif } +#endif WebView::WebView(QWidget* parent) @@ -256,16 +257,20 @@ WebView::WebView(QWidget* parent) , m_page(new WebPage(this)) { 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())); connect(page(), SIGNAL(loadingUrl(QUrl)), this, SIGNAL(urlChanged(QUrl))); +#if defined(QWEBENGINEPAGE_DOWNLOADREQUESTED) connect(page(), SIGNAL(downloadRequested(QNetworkRequest)), this, SLOT(downloadRequested(QNetworkRequest))); +#endif #if defined(QWEBENGINEPAGE_UNSUPPORTEDCONTENT) page()->setForwardUnsupportedContent(true); #endif @@ -310,8 +315,10 @@ void WebView::wheelEvent(QWheelEvent *event) void WebView::openLinkInNewTab() { +#if defined(QWEBENGINEPAGE_WEBACTION_OPENLINKINNEWWINDOW) m_page->m_openInNewTab = true; pageAction(QWebEnginePage::OpenLinkInNewWindow)->trigger(); +#endif } void WebView::setProgress(int progress) |