diff options
Diffstat (limited to 'examples/quick/controls/texteditor/qml/main.qml')
-rw-r--r-- | examples/quick/controls/texteditor/qml/main.qml | 34 |
1 files changed, 31 insertions, 3 deletions
diff --git a/examples/quick/controls/texteditor/qml/main.qml b/examples/quick/controls/texteditor/qml/main.qml index 4e11a4f5..cefbf434 100644 --- a/examples/quick/controls/texteditor/qml/main.qml +++ b/examples/quick/controls/texteditor/qml/main.qml @@ -157,8 +157,13 @@ ApplicationWindow { FileDialog { id: fileDialog - nameFilters: ["Text files (*.txt)", "HTML files (*.html)"] - onAccepted: document.fileUrl = fileUrl + nameFilters: ["Text files (*.txt)", "HTML files (*.html, *.htm)"] + onAccepted: { + if (fileDialog.selectExisting) + document.fileUrl = fileUrl + else + document.saveAs(fileUrl, selectedNameFilter) + } } ColorDialog { @@ -172,13 +177,28 @@ ApplicationWindow { iconSource: "images/fileopen.png" iconName: "document-open" text: "Open" - onTriggered: fileDialog.open() + onTriggered: { + fileDialog.selectExisting = true + fileDialog.open() + } + } + + Action { + id: fileSaveAsAction + iconSource: "images/filesave.png" + iconName: "document-save" + text: "Save As…" + onTriggered: { + fileDialog.selectExisting = false + fileDialog.open() + } } menuBar: MenuBar { Menu { title: "&File" MenuItem { action: fileOpenAction } + MenuItem { action: fileSaveAsAction } MenuItem { text: "Quit"; onTriggered: Qt.quit() } } Menu { @@ -303,6 +323,10 @@ ApplicationWindow { Component.onCompleted: forceActiveFocus() } + MessageDialog { + id: errorDialog + } + DocumentHandler { id: document target: textArea @@ -325,5 +349,9 @@ ApplicationWindow { fontFamilyComboBox.special = false } } + onError: { + errorDialog.text = message + errorDialog.visible = true + } } } |