Skip to content

Commit 49052df

Browse files
committed
[ui] ScriptEditor: ScriptEditor gets new icons
Updated Icons for ScriptEditor Script Editor shows a confirmation dialog before clearing history
1 parent 8207e84 commit 49052df

File tree

2 files changed

+40
-11
lines changed

2 files changed

+40
-11
lines changed

meshroom/ui/qml/Application.qml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1269,6 +1269,7 @@ Page {
12691269
ScriptEditor {
12701270
id: scriptEditor
12711271
anchors.fill: parent
1272+
rootApplication: root
12721273

12731274
visible: graphEditorPanel.currentTab === 2
12741275
}

meshroom/ui/qml/GraphEditor/ScriptEditor.qml

Lines changed: 39 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,26 @@ import ScriptEditor 1.0
1414
Item {
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
@@ -28,7 +46,7 @@ Item {
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

Comments
 (0)