diff options
author | Joerg Bornemann <joerg.bornemann@theqtcompany.com> | 2015-10-09 10:50:56 +0200 |
---|---|---|
committer | Joerg Bornemann <joerg.bornemann@theqtcompany.com> | 2015-10-09 11:24:35 +0000 |
commit | 2e9c6cd0bd6789a4f46fe0bcfbd522f0dd3eb4cb (patch) | |
tree | 0314d272fae1d2edc86892f2ef185713a80bb9e7 /src/webengine | |
parent | 84ae0d9c56e9638e5dcf676e1b3fd95571ad1973 (diff) |
add RequestClose web action
Web pages can set the onbeforeunload handler to let the user confirm
whether to leave the page or not. Until now, only when leaving the
page via a link, a confirmation was shown.
Before actually closing a web page, applications can now trigger
the RequestClose web action. This will give the use the chance to
confirm or deny the close request.
If the request is confirmed, the signal windowCloseRequested is
emitted.
Task-number: QTBUG-36155
Change-Id: Icc1fabc37a2ac537f674c2f00bc8966e4dc4e610
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@theqtcompany.com>
Diffstat (limited to 'src/webengine')
-rw-r--r-- | src/webengine/api/qquickwebenginetestsupport_p.h | 1 | ||||
-rw-r--r-- | src/webengine/api/qquickwebengineview.cpp | 11 | ||||
-rw-r--r-- | src/webengine/api/qquickwebengineview_p.h | 1 | ||||
-rw-r--r-- | src/webengine/api/qquickwebengineview_p_p.h | 1 |
4 files changed, 14 insertions, 0 deletions
diff --git a/src/webengine/api/qquickwebenginetestsupport_p.h b/src/webengine/api/qquickwebenginetestsupport_p.h index 9690e538d..d4b50ac2d 100644 --- a/src/webengine/api/qquickwebenginetestsupport_p.h +++ b/src/webengine/api/qquickwebenginetestsupport_p.h @@ -80,6 +80,7 @@ public: Q_SIGNALS: void validationMessageShown(const QString &mainText, const QString &subText); + void windowCloseRejected(); private: QScopedPointer<QQuickWebEngineErrorPage> m_errorPage; diff --git a/src/webengine/api/qquickwebengineview.cpp b/src/webengine/api/qquickwebengineview.cpp index 96a80a940..3a05477a1 100644 --- a/src/webengine/api/qquickwebengineview.cpp +++ b/src/webengine/api/qquickwebengineview.cpp @@ -508,6 +508,14 @@ void QQuickWebEngineViewPrivate::close() emit q->windowCloseRequested(); } +void QQuickWebEngineViewPrivate::windowCloseRejected() +{ +#ifdef ENABLE_QML_TESTSUPPORT_API + if (m_testSupport) + Q_EMIT m_testSupport->windowCloseRejected(); +#endif +} + void QQuickWebEngineViewPrivate::requestFullScreen(bool fullScreen) { Q_Q(QQuickWebEngineView); @@ -1298,6 +1306,9 @@ void QQuickWebEngineView::triggerWebAction(WebAction action) case ExitFullScreen: d->adapter->exitFullScreen(); break; + case RequestClose: + d->adapter->requestClose(); + break; default: Q_UNREACHABLE(); } diff --git a/src/webengine/api/qquickwebengineview_p.h b/src/webengine/api/qquickwebengineview_p.h index 6efb2b6f9..d1d8dacbb 100644 --- a/src/webengine/api/qquickwebengineview_p.h +++ b/src/webengine/api/qquickwebengineview_p.h @@ -226,6 +226,7 @@ public: InspectElement, ExitFullScreen, + RequestClose, WebActionCount }; diff --git a/src/webengine/api/qquickwebengineview_p_p.h b/src/webengine/api/qquickwebengineview_p_p.h index 0140111b9..271ab63be 100644 --- a/src/webengine/api/qquickwebengineview_p_p.h +++ b/src/webengine/api/qquickwebengineview_p_p.h @@ -143,6 +143,7 @@ public: virtual void unhandledKeyEvent(QKeyEvent *event) Q_DECL_OVERRIDE; virtual void adoptNewWindow(QtWebEngineCore::WebContentsAdapter *newWebContents, WindowOpenDisposition disposition, bool userGesture, const QRect &) Q_DECL_OVERRIDE; virtual void close() Q_DECL_OVERRIDE; + virtual void windowCloseRejected() Q_DECL_OVERRIDE; virtual void requestFullScreen(bool) Q_DECL_OVERRIDE; virtual bool isFullScreen() const Q_DECL_OVERRIDE; virtual bool contextMenuRequested(const QtWebEngineCore::WebEngineContextMenuData &) Q_DECL_OVERRIDE; |