summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorAndras Becsi <andras.becsi@digia.com>2014-10-17 16:01:40 +0200
committerAndras Becsi <andras.becsi@digia.com>2014-10-20 10:21:04 +0200
commitacce17434876082ba46c631109b48e641185ca17 (patch)
tree08520f64ec4a8ce2841a0ceb4d6e6c3851eb5b46 /examples
parent181d8fdf4cb45f31dd1692c5c6ea677eaa697929 (diff)
Implement acceptNavigationRequest for the widgets API.
This is the equivalent API for navigationRequested in QtQuick. This patch also enables and updates tests that depended on this API, and removes the ones that we will not support. Change-Id: I28970c11225420a9680fbd767880130492664179 Reviewed-by: Michael Bruning <michael.bruning@digia.com>
Diffstat (limited to 'examples')
-rw-r--r--examples/webenginewidgets/browser/webview.cpp34
-rw-r--r--examples/webenginewidgets/browser/webview.h4
2 files changed, 7 insertions, 31 deletions
diff --git a/examples/webenginewidgets/browser/webview.cpp b/examples/webenginewidgets/browser/webview.cpp
index 5094cfa66..07027fe3a 100644
--- a/examples/webenginewidgets/browser/webview.cpp
+++ b/examples/webenginewidgets/browser/webview.cpp
@@ -97,37 +97,15 @@ BrowserMainWindow *WebPage::mainWindow()
return BrowserApplication::instance()->mainWindow();
}
-#if defined(QWEBENGINEPAGE_ACCEPTNAVIGATIONREQUEST)
-bool WebPage::acceptNavigationRequest(QWebEngineFrame *frame, const QNetworkRequest &request, NavigationType type)
+bool WebPage::acceptNavigationRequest(const QUrl &url, NavigationType type, bool isMainFrame)
{
- // ctrl open in new tab
- // ctrl-shift open in new tab and select
- // ctrl-alt open in new window
- if (type == QWebEnginePage::NavigationTypeLinkClicked
- && (m_keyboardModifiers & Qt::ControlModifier
- || m_pressedButtons == Qt::MidButton)) {
- bool newWindow = (m_keyboardModifiers & Qt::AltModifier);
- WebView *webView;
- if (newWindow) {
- BrowserApplication::instance()->newMainWindow();
- BrowserMainWindow *newMainWindow = BrowserApplication::instance()->mainWindow();
- webView = newMainWindow->currentTab();
- newMainWindow->raise();
- newMainWindow->activateWindow();
- webView->setFocus();
- } else {
- bool selectNewTab = (m_keyboardModifiers & Qt::ShiftModifier);
- webView = mainWindow()->tabWidget()->newTab(selectNewTab);
- }
- webView->load(request);
- m_keyboardModifiers = Qt::NoModifier;
- m_pressedButtons = Qt::NoButton;
- return false;
+ Q_UNUSED(type);
+ if (isMainFrame) {
+ m_loadingUrl = url;
+ emit loadingUrl(m_loadingUrl);
}
- m_loadingUrl = request.url();
- emit loadingUrl(m_loadingUrl);
+ return true;
}
-#endif
bool WebPage::certificateError(const QWebEngineCertificateError &error)
{
diff --git a/examples/webenginewidgets/browser/webview.h b/examples/webenginewidgets/browser/webview.h
index 2cedeb79b..5ed674f6a 100644
--- a/examples/webenginewidgets/browser/webview.h
+++ b/examples/webenginewidgets/browser/webview.h
@@ -65,9 +65,7 @@ public:
BrowserMainWindow *mainWindow();
protected:
-#if defined(QWEBENGINEPAGE_ACCEPTNAVIGATIONREQUEST)
- bool acceptNavigationRequest(QWebEngineFrame *frame, const QNetworkRequest &request, NavigationType type);
-#endif
+ bool acceptNavigationRequest(const QUrl &url, NavigationType type, bool isMainFrame);
QWebEnginePage *createWindow(QWebEnginePage::WebWindowType type);
#if !defined(QT_NO_UITOOLS)
QObject *createPlugin(const QString &classId, const QUrl &url, const QStringList &paramNames, const QStringList &paramValues);