From 2080ac3ad0878dc04865bf957c84f8f0b5b551ac Mon Sep 17 00:00:00 2001 From: Szabolcs David Date: Thu, 24 Sep 2015 06:20:22 -0700 Subject: Implement unload dialogs This fixes the assertion that occurs when the application should show "Are you sure you want to leave this page?" dialog. We can reuse the already existing confirm dialog implementations. Change-Id: I22466d450f39b54d9becbb69e1ecadb3b98697b0 Reviewed-by: Joerg Bornemann --- src/webenginewidgets/api/qwebenginepage.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/webenginewidgets/api/qwebenginepage.cpp') diff --git a/src/webenginewidgets/api/qwebenginepage.cpp b/src/webenginewidgets/api/qwebenginepage.cpp index 677f67cbe..5d91b3b7f 100644 --- a/src/webenginewidgets/api/qwebenginepage.cpp +++ b/src/webenginewidgets/api/qwebenginepage.cpp @@ -904,6 +904,9 @@ void QWebEnginePagePrivate::javascriptDialog(QSharedPointertextProvided(promptResult); break; + case UnloadDialog: + accepted = (QMessageBox::information(view, QCoreApplication::translate("QWebEnginePage", "Are you sure you want to leave this page?"), controller->message(), QMessageBox::Yes, QMessageBox::No) == QMessageBox::Yes); + break; case InternalAuthorizationDialog: accepted = (QMessageBox::question(view, controller->title(), controller->message(), QMessageBox::Yes, QMessageBox::No) == QMessageBox::Yes); break; -- cgit v1.2.3 From 2e9c6cd0bd6789a4f46fe0bcfbd522f0dd3eb4cb Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Fri, 9 Oct 2015 10:50:56 +0200 Subject: 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 --- src/webenginewidgets/api/qwebenginepage.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/webenginewidgets/api/qwebenginepage.cpp') diff --git a/src/webenginewidgets/api/qwebenginepage.cpp b/src/webenginewidgets/api/qwebenginepage.cpp index 5d91b3b7f..bb0917918 100644 --- a/src/webenginewidgets/api/qwebenginepage.cpp +++ b/src/webenginewidgets/api/qwebenginepage.cpp @@ -224,6 +224,11 @@ void QWebEnginePagePrivate::close() Q_EMIT q->windowCloseRequested(); } +void QWebEnginePagePrivate::windowCloseRejected() +{ + // Do nothing for now. +} + void QWebEnginePagePrivate::didRunJavaScript(quint64 requestId, const QVariant& result) { m_callbacks.invoke(requestId, result); @@ -639,6 +644,9 @@ QAction *QWebEnginePage::action(WebAction action) const case ExitFullScreen: text = tr("Exit Full Screen Mode"); break; + case RequestClose: + text = tr("Close Page"); + break; default: break; } @@ -809,6 +817,9 @@ void QWebEnginePage::triggerAction(WebAction action, bool) case ExitFullScreen: d->adapter->exitFullScreen(); break; + case RequestClose: + d->adapter->requestClose(); + break; default: Q_UNREACHABLE(); } -- cgit v1.2.3