@@ -39,10 +39,10 @@ Item {
3939 }
4040
4141 enum ButtonState {
42- LAUNCHABLE ,
43- STOPPABLE ,
44- DELETABLE ,
45- DISABLED
42+ DISABLED = 0 ,
43+ LAUNCHABLE = 1 ,
44+ DELETABLE = 2 ,
45+ STOPPABLE = 3
4646 }
4747
4848 Rectangle {
@@ -105,14 +105,14 @@ Item {
105105 property bool nodeIsLocked: false
106106 property bool canComputeNode: false
107107 property bool canStopNode: false
108+ property bool canRestartNode: false
108109 property bool canSubmitNode: false
109110 property bool nodeSubmitted: false
110111
111112 property int computeButtonState: NodeActions .ButtonState .LAUNCHABLE
112113 property string computeButtonIcon: {
113114 switch (computeButtonState) {
114115 case NodeActions .ButtonState .STOPPABLE : return MaterialIcons .cancel_schedule_send
115- case NodeActions .ButtonState .DELETABLE : return MaterialIcons .delete_
116116 default : return MaterialIcons .send
117117 }
118118 }
@@ -121,10 +121,12 @@ Item {
121121 function getComputeButtonState (node ) {
122122 if (actionHeader .canStopNode )
123123 return NodeActions .ButtonState .STOPPABLE
124- if (! actionHeader .nodeIsLocked && node .globalStatus == " SUCCESS" )
125- return NodeActions .ButtonState .DELETABLE
126- if (! actionHeader .nodeIsLocked && actionHeader .canComputeNode )
127- return NodeActions .ButtonState .LAUNCHABLE
124+ if (! actionHeader .nodeIsLocked ) {
125+ if (node .globalStatus == " SUCCESS" )
126+ return NodeActions .ButtonState .DELETABLE
127+ if (actionHeader .canComputeNode )
128+ return NodeActions .ButtonState .LAUNCHABLE
129+ }
128130 return NodeActions .ButtonState .DISABLED
129131 }
130132
@@ -139,18 +141,24 @@ Item {
139141 function isSubmittedExternally (node ) {
140142 return node .globalExecMode == " EXTERN" && [" RUNNING" , " SUBMITTED" ].includes (node .globalStatus )
141143 }
144+
145+ function isNodeRestartable (node ) {
146+ return actionHeader .computeButtonState == NodeActions .ButtonState .LAUNCHABLE &&
147+ [" ERROR" , " STOPPED" , " KILLED" ].includes (node .globalStatus )
148+ }
142149
143150 function updateProperties (node ) {
144151 if (! node) return
145152 // Update properties values
146153 actionHeader .canComputeNode = uigraph .canComputeNode (node)
147154 actionHeader .canSubmitNode = uigraph .canSubmitNode (node)
148- actionHeader .canStopNode = node .canBeStopped ()
155+ actionHeader .canStopNode = node .canBeStopped () || node . canBeCanceled ()
149156 actionHeader .nodeIsLocked = node .locked
150157 actionHeader .nodeSubmitted = isSubmittedExternally (node)
151158 // Update button states
152159 actionHeader .computeButtonState = getComputeButtonState (node)
153160 actionHeader .submitButtonState = getSubmitButtonState (node)
161+ actionHeader .canRestartNode = isNodeRestartable (node)
154162 }
155163
156164 // Set initial state & position
@@ -196,46 +204,55 @@ Item {
196204 ToolTip .text : " Start/Stop/Restart Compute"
197205 ToolTip .visible : hovered
198206 ToolTip .delay : 1000
199- enabled: actionHeader .computeButtonState != NodeActions .ButtonState .DISABLED
207+ visible: actionHeader .computeButtonState != NodeActions .ButtonState .DELETABLE
208+ enabled: actionHeader .computeButtonState % 2 == 1 // Launchable & Stoppable
200209 background: Rectangle {
201210 color: {
202211 if (! computeButton .enabled ) return activePalette .button
203- switch (actionHeader .computeButtonState ) {
204- case NodeActions .ButtonState .STOPPABLE :
205- if (computeButton .hovered ) return Colors .orange
206- return Qt .darker (Colors .orange , 1.3 )
207- case NodeActions .ButtonState .DELETABLE :
208- if (computeButton .hovered ) return Colors .red
209- return Qt .darker (Colors .red , 1.3 )
210- default : break
211- }
212- if (computeButton .hovered ) return activePalette .highlight
213- return activePalette .button
212+ if (actionHeader .computeButtonState == NodeActions .ButtonState .STOPPABLE )
213+ return computeButton .hovered ? Colors .orange : Qt .darker (Colors .orange , 1.3 )
214+ return computeButton .hovered ? activePalette .highlight : activePalette .button
214215 }
215216 opacity: computeButton .hovered ? 1 : root ._opacity
216217 border .color : computeButton .hovered ? activePalette .highlight : Qt .darker (activePalette .window , 1.3 )
217218 border .width : 1
218219 radius: 3
219220 }
220221 onClicked: {
221- // The remaining issue with this design is that if we computed half the chunks
222- // then the only option we have is to resume the compute
223- // We don't have a restart from zero (delete + start) in this case
224- // But this would require an additional button
225222 switch (actionHeader .computeButtonState ) {
226223 case NodeActions .ButtonState .STOPPABLE :
227224 root .stopComputeRequest (actionHeader .selectedNode )
228225 break
229226 case NodeActions .ButtonState .LAUNCHABLE :
230227 root .computeRequest (actionHeader .selectedNode )
231228 break
232- case NodeActions .ButtonState .DELETABLE :
233- root .deleteDataRequest (actionHeader .selectedNode )
234- break
235229 }
236230 }
237231 }
238232
233+ // Clear node
234+ MaterialToolButton {
235+ id: restartButton
236+ font .pointSize : 16
237+ text: MaterialIcons .delete_
238+ padding: 6
239+ ToolTip .text : " Delete data"
240+ ToolTip .visible : hovered
241+ ToolTip .delay : 1000
242+ visible: actionHeader .canRestartNode || actionHeader .computeButtonState == NodeActions .ButtonState .DELETABLE
243+ enabled: visible
244+ background: Rectangle {
245+ color: computeButton .hovered ? Colors .red : Qt .darker (Colors .red , 1.3 )
246+ opacity: computeButton .hovered ? 1 : root ._opacity
247+ border .color : computeButton .hovered ? activePalette .highlight : Qt .darker (activePalette .window , 1.3 )
248+ border .width : 1
249+ radius: 3
250+ }
251+ onClicked: {
252+ root .deleteDataRequest (actionHeader .selectedNode )
253+ }
254+ }
255+
239256 // Submit button
240257 MaterialToolButton {
241258 id: submitButton
@@ -249,11 +266,10 @@ Item {
249266 enabled: actionHeader .submitButtonState != NodeActions .ButtonState .DISABLED
250267 background: Rectangle {
251268 color: {
269+ if (! submitButton .enabled ) return activePalette .button
252270 if (actionHeader .nodeSubmitted )
253271 return Qt .darker (Colors .statusColors [" SUBMITTED" ], 1.2 )
254- if (! submitButton .enabled ) return activePalette .button
255- if (submitButton .hovered ) return activePalette .highlight
256- return activePalette .button
272+ return submitButton .hovered ? activePalette .highlight : activePalette .button
257273 }
258274 opacity: submitButton .hovered ? 1 : root ._opacity
259275 border .color : submitButton .hovered ? activePalette .highlight : Qt .darker (activePalette .window , 1.3 )
0 commit comments