diff options
Diffstat (limited to 'examples/widgets')
-rw-r--r-- | examples/widgets/browser/browsermainwindow.cpp | 2 | ||||
-rw-r--r-- | examples/widgets/browser/tabwidget.cpp | 18 | ||||
-rw-r--r-- | examples/widgets/browser/urllineedit.cpp | 2 | ||||
-rw-r--r-- | examples/widgets/browser/webview.cpp | 17 | ||||
-rw-r--r-- | examples/widgets/browser/webview.h | 4 |
5 files changed, 38 insertions, 5 deletions
diff --git a/examples/widgets/browser/browsermainwindow.cpp b/examples/widgets/browser/browsermainwindow.cpp index 9a2262314..b51df7a75 100644 --- a/examples/widgets/browser/browsermainwindow.cpp +++ b/examples/widgets/browser/browsermainwindow.cpp @@ -291,6 +291,7 @@ void BrowserMainWindow::setupMenu() // Edit QMenu *editMenu = menuBar()->addMenu(tr("&Edit")); +#if defined(QWEBENGINEPAGE_WEBACTION_UNDO) QAction *m_undo = editMenu->addAction(tr("&Undo")); m_undo->setShortcuts(QKeySequence::Undo); m_tabWidget->addWebAction(m_undo, QWebEnginePage::Undo); @@ -308,6 +309,7 @@ void BrowserMainWindow::setupMenu() m_paste->setShortcuts(QKeySequence::Paste); m_tabWidget->addWebAction(m_paste, QWebEnginePage::Paste); editMenu->addSeparator(); +#endif #if defined(QWEBENGINEPAGE_FINDTEXT) QAction *m_find = editMenu->addAction(tr("&Find")); diff --git a/examples/widgets/browser/tabwidget.cpp b/examples/widgets/browser/tabwidget.cpp index 3c71b2d53..af18b5a37 100644 --- a/examples/widgets/browser/tabwidget.cpp +++ b/examples/widgets/browser/tabwidget.cpp @@ -306,18 +306,26 @@ void TabWidget::currentChanged(int index) WebView *oldWebView = this->webView(m_lineEdits->currentIndex()); if (oldWebView) { +#if defined(QWEBENGINEVIEW_STATUSBARMESSAGE) disconnect(oldWebView, SIGNAL(statusBarMessage(QString)), this, SIGNAL(showStatusBarMessage(QString))); +#endif +#if defined(QWEBENGINEVIEW_LINKHOVERED) disconnect(oldWebView->page(), SIGNAL(linkHovered(QString,QString,QString)), this, SIGNAL(linkHovered(QString))); +#endif disconnect(oldWebView, SIGNAL(loadProgress(int)), this, SIGNAL(loadProgress(int))); } +#if defined(QWEBENGINEVIEW_STATUSBARMESSAGE) connect(webView, SIGNAL(statusBarMessage(QString)), this, SIGNAL(showStatusBarMessage(QString))); +#endif +#if defined(QWEBENGINEVIEW_LINKHOVERED) connect(webView->page(), SIGNAL(linkHovered(QString,QString,QString)), this, SIGNAL(linkHovered(QString))); +#endif connect(webView, SIGNAL(loadProgress(int)), this, SIGNAL(loadProgress(int))); @@ -450,8 +458,10 @@ WebView *TabWidget::newTab(bool makeCurrent) this, SLOT(webViewLoadStarted())); connect(webView, SIGNAL(loadFinished(bool)), this, SLOT(webViewIconChanged())); +#if defined(QWEBENGINEVIEW_ICONCHANGED) connect(webView, SIGNAL(iconChanged()), this, SLOT(webViewIconChanged())); +#endif connect(webView, SIGNAL(titleChanged(QString)), this, SLOT(webViewTitleChanged(QString))); connect(webView, SIGNAL(urlChanged(QUrl)), @@ -460,14 +470,22 @@ WebView *TabWidget::newTab(bool makeCurrent) this, SLOT(windowCloseRequested())); connect(webView->page(), SIGNAL(geometryChangeRequested(QRect)), this, SIGNAL(geometryChangeRequested(QRect))); +#if defined(QWEBENGINEPAGE_PRINTREQUESTED) connect(webView->page(), SIGNAL(printRequested(QWebEngineFrame*)), this, SIGNAL(printRequested(QWebEngineFrame*))); +#endif +#if defined(QWEBENGINEPAGE_MENUBARVISIBILITYCHANGEREQUESTED) connect(webView->page(), SIGNAL(menuBarVisibilityChangeRequested(bool)), this, SIGNAL(menuBarVisibilityChangeRequested(bool))); +#endif +#if defined(QWEBENGINEPAGE_STATUSBARVISIBILITYCHANGEREQUESTED) connect(webView->page(), SIGNAL(statusBarVisibilityChangeRequested(bool)), this, SIGNAL(statusBarVisibilityChangeRequested(bool))); +#endif +#if defined(QWEBENGINEPAGE_TOOLBARVISIBILITYCHANGEREQUESTED) connect(webView->page(), SIGNAL(toolBarVisibilityChangeRequested(bool)), this, SIGNAL(toolBarVisibilityChangeRequested(bool))); +#endif addTab(webView, tr("(Untitled)")); if (makeCurrent) setCurrentWidget(webView); diff --git a/examples/widgets/browser/urllineedit.cpp b/examples/widgets/browser/urllineedit.cpp index 47828d95f..306e56e9a 100644 --- a/examples/widgets/browser/urllineedit.cpp +++ b/examples/widgets/browser/urllineedit.cpp @@ -276,8 +276,10 @@ void UrlLineEdit::setWebView(WebView *webView) this, SLOT(webViewUrlChanged(QUrl))); connect(webView, SIGNAL(loadFinished(bool)), this, SLOT(webViewIconChanged())); +#if defined(QWEBENGINEVIEW_ICONCHANGED) connect(webView, SIGNAL(iconChanged()), this, SLOT(webViewIconChanged())); +#endif connect(webView, SIGNAL(loadProgress(int)), this, SLOT(update())); } 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) diff --git a/examples/widgets/browser/webview.h b/examples/widgets/browser/webview.h index 0dce3e029..4ef4d7e6a 100644 --- a/examples/widgets/browser/webview.h +++ b/examples/widgets/browser/webview.h @@ -64,14 +64,18 @@ public: BrowserMainWindow *mainWindow(); protected: +#if defined(QWEBENGINEPAGE_ACCEPTNAVIGATIONREQUEST) bool acceptNavigationRequest(QWebEngineFrame *frame, const QNetworkRequest &request, NavigationType type); +#endif QWebEnginePage *createWindow(QWebEnginePage::WebWindowType type); #if !defined(QT_NO_UITOOLS) QObject *createPlugin(const QString &classId, const QUrl &url, const QStringList ¶mNames, const QStringList ¶mValues); #endif private slots: +#if defined(QWEBENGINEPAGE_UNSUPPORTEDCONTENT) void handleUnsupportedContent(QNetworkReply *reply); +#endif private: friend class WebView; |