From 064a782a54ab1ad8f28a049ddf55db7376edf357 Mon Sep 17 00:00:00 2001
From: Shawn Rutledge <shawn.rutledge@digia.com>
Date: Fri, 10 Oct 2014 15:04:10 +0200
Subject: [PATCH] Dialog examples: handle keys for accept, and more feedback

All dialogs populate the label showing how they were accepted or
rejected.

Change-Id: I0bad4af0864bdf24e56c18aeecd8ca8f6536b6b0
Reviewed-by: J-P Nurmi <jpnurmi@theqtcompany.com>
---
 examples/quick/dialogs/systemdialogs/CustomDialogs.qml | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/examples/quick/dialogs/systemdialogs/CustomDialogs.qml b/examples/quick/dialogs/systemdialogs/CustomDialogs.qml
index cc91fbb42..d11437756 100644
--- a/examples/quick/dialogs/systemdialogs/CustomDialogs.qml
+++ b/examples/quick/dialogs/systemdialogs/CustomDialogs.qml
@@ -123,6 +123,7 @@ Item {
             else
                 lastChosen.text = (clickedButton == StandardButton.Retry ? "(Retry)" : "(Ignore)")
         }
+        onRejected: lastChosen.text = "Rejected"
 
         Calendar {
             id: calendar
@@ -136,6 +137,9 @@ Item {
         modality: dialogModal.checked ? Qt.WindowModal : Qt.NonModal
         title: customizeTitle.checked ? windowTitleField.text : "Customized content"
         onRejected: lastChosen.text = "Rejected"
+        onAccepted: lastChosen.text = "Accepted " +
+                    (clickedButton === StandardButton.Retry ? "(Retry)" : "(OK)")
+        onButtonClicked: if (clickedButton === StandardButton.Retry) lastChosen.text = "Retry"
         contentItem: Rectangle {
             color: "lightskyblue"
             implicitWidth: 400
@@ -145,6 +149,8 @@ Item {
                 color: "navy"
                 anchors.centerIn: parent
             }
+            Keys.onPressed: if (event.key === Qt.Key_R && (event.modifiers & Qt.ControlModifier)) filledDialog.click(StandardButton.Retry)
+            Keys.onEnterPressed: filledDialog.accept()
             Keys.onEscapePressed: filledDialog.reject()
             Keys.onBackPressed: filledDialog.reject() // especially necessary on Android
         }
-- 
GitLab