From f65aea4d98f498a1e97abf84bad24789f2342499 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20Br=C3=BCning?= <michael.bruning@theqtcompany.com>
Date: Tue, 20 Jan 2015 11:18:20 +0100
Subject: [PATCH] Also run the rejected signal handler when closing prompt
 dialogs.

The prompt dialog inherits ApplicationWindow, which emits the
signal "closing" when the window gets closed by pressing the X
button.

Change-Id: I23e5cf6f8e81251869d765d7fd2864257f3c0b89
Task-number: QTBUG-43902
Reviewed-by: Andras Becsi <andras.becsi@theqtcompany.com>
---
 src/webengine/ui_delegates_manager.cpp | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/src/webengine/ui_delegates_manager.cpp b/src/webengine/ui_delegates_manager.cpp
index 48e1bee7e..9e7af3fad 100644
--- a/src/webengine/ui_delegates_manager.cpp
+++ b/src/webengine/ui_delegates_manager.cpp
@@ -310,15 +310,6 @@ void UIDelegatesManager::showDialog(QSharedPointer<JavaScriptDialogController> d
     QQmlProperty titleProp(dialog, QStringLiteral("title"));
     titleProp.write(title);
 
-    if (dialogComponentType == PromptDialog) {
-        QQmlProperty promptProp(dialog, QStringLiteral("prompt"));
-        promptProp.write(dialogController->defaultPrompt());
-        QQmlProperty inputSignal(dialog, QStringLiteral("onInput"));
-        CHECK_QML_SIGNAL_PROPERTY(inputSignal, dialogComponent->url());
-        static int setTextIndex = dialogController->metaObject()->indexOfSlot("textProvided(QString)");
-        QObject::connect(dialog, inputSignal.method(), dialogController.data(), dialogController->metaObject()->method(setTextIndex));
-    }
-
     QQmlProperty acceptSignal(dialog, QStringLiteral("onAccepted"));
     QQmlProperty rejectSignal(dialog, QStringLiteral("onRejected"));
     CHECK_QML_SIGNAL_PROPERTY(acceptSignal, dialogComponent->url());
@@ -328,6 +319,18 @@ void UIDelegatesManager::showDialog(QSharedPointer<JavaScriptDialogController> d
     QObject::connect(dialog, acceptSignal.method(), dialogController.data(), dialogController->metaObject()->method(acceptIndex));
     static int rejectIndex = dialogController->metaObject()->indexOfSlot("reject()");
     QObject::connect(dialog, rejectSignal.method(), dialogController.data(), dialogController->metaObject()->method(rejectIndex));
+
+    if (dialogComponentType == PromptDialog) {
+        QQmlProperty promptProp(dialog, QStringLiteral("prompt"));
+        promptProp.write(dialogController->defaultPrompt());
+        QQmlProperty inputSignal(dialog, QStringLiteral("onInput"));
+        CHECK_QML_SIGNAL_PROPERTY(inputSignal, dialogComponent->url());
+        static int setTextIndex = dialogController->metaObject()->indexOfSlot("textProvided(QString)");
+        QObject::connect(dialog, inputSignal.method(), dialogController.data(), dialogController->metaObject()->method(setTextIndex));
+        QQmlProperty closingSignal(dialog, QStringLiteral("onClosing"));
+        QObject::connect(dialog, closingSignal.method(), dialogController.data(), dialogController->metaObject()->method(rejectIndex));
+    }
+
     dialogComponent->completeCreate();
 
     QObject::connect(dialogController.data(), &JavaScriptDialogController::dialogCloseRequested, dialog, &QObject::deleteLater);
-- 
GitLab