From 5854ae544f7757103e18af25631a525aef898ec4 Mon Sep 17 00:00:00 2001 From: Ian Paschal Date: Fri, 27 Jul 2018 15:32:51 +0200 Subject: [PATCH 1/2] Indicate when "Prepare" button has already been clicked Contributes to CURA-5551 --- resources/qml/SaveButton.qml | 51 ++++++++++++++++++++++++++++-------- 1 file changed, 40 insertions(+), 11 deletions(-) diff --git a/resources/qml/SaveButton.qml b/resources/qml/SaveButton.qml index 0e0eec7277..86339b6795 100644 --- a/resources/qml/SaveButton.qml +++ b/resources/qml/SaveButton.qml @@ -48,14 +48,15 @@ Item { } function sliceOrStopSlicing() { - try { - if ([1, 5].indexOf(base.backendState) != -1) { - CuraApplication.backend.forceSlice(); - } else { - CuraApplication.backend.stopSlicing(); - } - } catch (e) { - console.log('Could not start or stop slicing', e) + if ( [ 1, 5 ].indexOf( base.backendState ) != -1 ) + { + prepareButton.preparingToSlice = true; + CuraApplication.backend.forceSlice(); + } + else + { + prepareButton.preparingToSlice = false; + CuraApplication.backend.stopSlicing(); } } @@ -167,10 +168,10 @@ Item { // Prepare button, only shows if auto_slice is off Button { id: prepareButton - + property bool preparingToSlice: false tooltip: [1, 5].indexOf(base.backendState) != -1 ? catalog.i18nc("@info:tooltip","Slice current printjob") : catalog.i18nc("@info:tooltip","Cancel slicing process") // 1 = not started, 2 = Processing - enabled: base.backendState != "undefined" && ([1, 2].indexOf(base.backendState) != -1) && base.activity + enabled: !preparingToSlice && base.backendState != "undefined" && ([1, 2].indexOf(base.backendState) != -1) && base.activity visible: base.backendState != "undefined" && !autoSlice && ([1, 2, 4].indexOf(base.backendState) != -1) && base.activity property bool autoSlice height: UM.Theme.getSize("save_button_save_to_button").height @@ -180,7 +181,23 @@ Item { anchors.rightMargin: UM.Theme.getSize("sidebar_margin").width // 1 = not started, 4 = error, 5 = disabled - text: [1, 4, 5].indexOf(base.backendState) != -1 ? catalog.i18nc("@label:Printjob", "Prepare") : catalog.i18nc("@label:Printjob", "Cancel") + text: { + if ( preparingToSlice ) + { + return catalog.i18nc("@label:Printjob", "Preparing"); + } + else + { + if ( [ 1, 4, 5 ].indexOf( base.backendState ) != -1 ) + { + return catalog.i18nc("@label:Printjob", "Prepare"); + } + else + { + return catalog.i18nc("@label:Printjob", "Cancel") + } + } + } onClicked: { sliceOrStopSlicing(); @@ -237,6 +254,18 @@ Item { } label: Item { } } + + Connections { + target: UM.Backend + onStateChanged: + { + if ( [ 2, 3 ].indexOf( UM.Backend.state) != -1 ) + { + prepareButton.preparingToSlice = false; + } + + } + } } Button { From 2790650686e8d0487381f4adfab3928595f9fb19 Mon Sep 17 00:00:00 2001 From: Ian Paschal Date: Mon, 30 Jul 2018 09:39:10 +0200 Subject: [PATCH 2/2] Code style improvements Contributes to CURA-5551 --- resources/qml/SaveButton.qml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/resources/qml/SaveButton.qml b/resources/qml/SaveButton.qml index 86339b6795..9b5e3befb0 100644 --- a/resources/qml/SaveButton.qml +++ b/resources/qml/SaveButton.qml @@ -48,7 +48,7 @@ Item { } function sliceOrStopSlicing() { - if ( [ 1, 5 ].indexOf( base.backendState ) != -1 ) + if ([1, 5].indexOf(base.backendState) != -1) { prepareButton.preparingToSlice = true; CuraApplication.backend.forceSlice(); @@ -182,13 +182,13 @@ Item { // 1 = not started, 4 = error, 5 = disabled text: { - if ( preparingToSlice ) + if (preparingToSlice) { return catalog.i18nc("@label:Printjob", "Preparing"); } else { - if ( [ 1, 4, 5 ].indexOf( base.backendState ) != -1 ) + if ([1, 4, 5].indexOf(base.backendState) != -1) { return catalog.i18nc("@label:Printjob", "Prepare"); } @@ -259,11 +259,10 @@ Item { target: UM.Backend onStateChanged: { - if ( [ 2, 3 ].indexOf( UM.Backend.state) != -1 ) + if ([2, 3].indexOf(UM.Backend.state) != -1) { prepareButton.preparingToSlice = false; } - } } }