@@ -14,8 +14,26 @@ import ScriptEditor 1.0
1414Item {
1515 id: root
1616
17+ // Defines the parent or the root Application of which this script editor is a part of
18+ property var rootApplication: undefined ;
19+
20+ Component {
21+ id: clearConfirmationDialog
22+
23+ MessageDialog {
24+ title: " Clear history"
25+
26+ preset: " Warning"
27+ text: " This will clear all history of executed scripts."
28+ helperText: " Are you sure you would like to continue?."
29+
30+ standardButtons: Dialog .Ok | Dialog .Cancel
31+ onClosed: destroy ()
32+ }
33+ }
34+
1735 function replace (text , string , replacement ) {
18- /*
36+ /**
1937 * Replaces all occurences of the string in the text
2038 * @param text - overall text
2139 * @param string - the string to be replaced in the text
2846 }
2947
3048 function formatInput (text ) {
31- /*
49+ /**
3250 * Formats the text to be displayed as the input script executed
3351 */
3452
@@ -37,14 +55,23 @@ Item {
3755 }
3856
3957 function formatOutput (text ) {
40- /*
58+ /**
4159 * Formats the text to be displayed as the result of the script executed
4260 */
4361
4462 // Replace the text to be RichText Supportive
4563 return " <font color=#49a1f3>" + " Result: " + replace (text, " \n " , " <br>" ) + " </font><br><br>"
4664 }
4765
66+ function clearHistory () {
67+ /**
68+ * Clears all of the executed history from the script editor
69+ */
70+ ScriptEditorManager .clearHistory ()
71+ input .clear ()
72+ output .clear ()
73+ }
74+
4875 function processScript (text = " " ) {
4976 // Use either the provided/selected or the entire script
5077 text = text || input .text
@@ -117,7 +144,7 @@ Item {
117144
118145 MaterialToolButton {
119146 font .pointSize : 18
120- text: MaterialIcons .download
147+ text: MaterialIcons .file_open
121148 ToolTip .text : " Load Script"
122149
123150 onClicked: {
@@ -127,7 +154,7 @@ Item {
127154
128155 MaterialToolButton {
129156 font .pointSize : 18
130- text: MaterialIcons .upload
157+ text: MaterialIcons .save
131158 ToolTip .text : " Save Script"
132159
133160 onClicked: {
@@ -142,7 +169,7 @@ Item {
142169 MaterialToolButton {
143170 id: executeButton
144171 font .pointSize : 18
145- text: MaterialIcons .slideshow
172+ text: MaterialIcons .play_arrow
146173 ToolTip .text : " Execute Script"
147174
148175 onClicked: {
@@ -152,7 +179,7 @@ Item {
152179
153180 MaterialToolButton {
154181 font .pointSize : 18
155- text: MaterialIcons .cancel_presentation
182+ text: MaterialIcons .backspace
156183 ToolTip .text : " Clear Output Window"
157184
158185 onClicked: {
@@ -196,13 +223,14 @@ Item {
196223
197224 MaterialToolButton {
198225 font .pointSize : 18
199- text: MaterialIcons .backspace
226+ text: MaterialIcons .delete_sweep
200227 ToolTip .text : " Clear History"
201228
202229 onClicked: {
203- ScriptEditorManager .clearHistory ()
204- input .clear ()
205- output .clear ()
230+ // Confirm from the user before clearing out any history
231+ const confirmationDialog = clearConfirmationDialog .createObject (rootApplication ? rootApplication : root);
232+ confirmationDialog .accepted .connect (clearHistory);
233+ confirmationDialog .open ();
206234 }
207235 }
208236
0 commit comments