aboutsummaryrefslogtreecommitdiffstats
path: root/examples/quickcontrols2/texteditor/qml/texteditor.qml
diff options
context:
space:
mode:
Diffstat (limited to 'examples/quickcontrols2/texteditor/qml/texteditor.qml')
-rw-r--r--examples/quickcontrols2/texteditor/qml/texteditor.qml19
1 files changed, 17 insertions, 2 deletions
diff --git a/examples/quickcontrols2/texteditor/qml/texteditor.qml b/examples/quickcontrols2/texteditor/qml/texteditor.qml
index a1cb3435..6c95335b 100644
--- a/examples/quickcontrols2/texteditor/qml/texteditor.qml
+++ b/examples/quickcontrols2/texteditor/qml/texteditor.qml
@@ -80,7 +80,7 @@ ApplicationWindow {
}
Shortcut {
sequence: StandardKey.Quit
- onActivated: Qt.quit()
+ onActivated: close()
}
Shortcut {
sequence: StandardKey.Copy
@@ -121,7 +121,7 @@ ApplicationWindow {
}
MenuItem {
text: qsTr("&Quit")
- onTriggered: Qt.quit()
+ onTriggered: close()
}
}
@@ -205,6 +205,14 @@ ApplicationWindow {
id: errorDialog
}
+ MessageDialog {
+ id : quitDialog
+ title: qsTr("Quit?")
+ text: qsTr("The file has been modified. Quit anyway?")
+ buttons: (MessageDialog.Yes | MessageDialog.No)
+ onYesClicked: Qt.quit()
+ }
+
header: ToolBar {
leftPadding: 8
@@ -449,4 +457,11 @@ ApplicationWindow {
onTriggered: colorDialog.open()
}
}
+
+ onClosing: {
+ if (document.modified) {
+ quitDialog.open()
+ close.accepted = false
+ }
+ }
}