Adds an idle-state for the safebutton

When there is no model, the safebutton goes back into the idle state

contributes to #128
This commit is contained in:
Tamara Hogenhout 2015-07-10 18:43:47 +02:00
parent a687c9c89e
commit 81aa047ae3

View file

@ -14,6 +14,7 @@ Rectangle {
property Action saveAction; property Action saveAction;
property real progress: UM.Backend.progress; property real progress: UM.Backend.progress;
property bool activity: Printer.getPlatformActivity;
Behavior on progress { NumberAnimation { duration: 250; } } Behavior on progress { NumberAnimation { duration: 250; } }
property string currentDevice: "local_file" property string currentDevice: "local_file"
@ -76,7 +77,7 @@ Rectangle {
color: UM.Theme.colors.save_button_estimated_text; color: UM.Theme.colors.save_button_estimated_text;
font: UM.Theme.fonts.small; font: UM.Theme.fonts.small;
text: text:
if(base.progress < 0) { if(base.activity == false) {
//: Save button label //: Save button label
return qsTr("Please load a 3D model"); return qsTr("Please load a 3D model");
} else if (base.progress < 0.99) { } else if (base.progress < 0.99) {
@ -97,7 +98,7 @@ Rectangle {
anchors.leftMargin: UM.Theme.sizes.save_button_text_margin.width; anchors.leftMargin: UM.Theme.sizes.save_button_text_margin.width;
color: UM.Theme.colors.save_button_printtime_text; color: UM.Theme.colors.save_button_printtime_text;
font: UM.Theme.fonts.small; font: UM.Theme.fonts.small;
visible: base.progress < 0.99 ? false : true visible: base.activity == false || base.progress < 0.99 ? false : true
text: (!base.printDuration || !base.printDuration.valid) ? "" : base.printDuration.getDisplayString(UM.DurationFormat.Long); text: (!base.printDuration || !base.printDuration.valid) ? "" : base.printDuration.getDisplayString(UM.DurationFormat.Long);
} }
Label { Label {
@ -107,11 +108,10 @@ Rectangle {
anchors.leftMargin: UM.Theme.sizes.save_button_text_margin.width; anchors.leftMargin: UM.Theme.sizes.save_button_text_margin.width;
color: base.printDuration.days > 0 ? UM.Theme.colors.save_button_estimated_text : UM.Theme.colors.save_button_printtime_text; color: base.printDuration.days > 0 ? UM.Theme.colors.save_button_estimated_text : UM.Theme.colors.save_button_printtime_text;
font: UM.Theme.fonts.small; font: UM.Theme.fonts.small;
property bool mediumLengthDuration: base.printDuration.hours > 9 && base.printMaterialAmount > 9.99 && base.printDuration.days == 0 property bool mediumLengthDuration: base.printDuration.hours > 9 && base.printMaterialAmount > 9.99 && base.printDuration.days == 0
width: mediumLengthDuration ? 50 : undefined width: mediumLengthDuration ? 50 : undefined
elide: mediumLengthDuration ? Text.ElideRight : Text.ElideNone elide: mediumLengthDuration ? Text.ElideRight : Text.ElideNone
visible: base.progress < 0.99 ? false : true visible: base.activity == false || base.progress < 0.99 ? false : true
//: Print material amount save button label //: Print material amount save button label
text: base.printMaterialAmount < 0 ? "" : qsTr("%1m material").arg(base.printMaterialAmount); text: base.printMaterialAmount < 0 ? "" : qsTr("%1m material").arg(base.printMaterialAmount);
} }
@ -125,7 +125,7 @@ Rectangle {
} }
width: Math.max(infoBox.width * base.progress); width: Math.max(infoBox.width * base.progress);
color: UM.Theme.colors.save_button_active color: UM.Theme.colors.save_button_active
visible: base.progress > 0.99 ? false : true visible: progress > 0.99 ? false : true
} }
Button { Button {
@ -135,7 +135,7 @@ Rectangle {
anchors.left: parent.left anchors.left: parent.left
anchors.leftMargin: UM.Theme.sizes.default_margin.width; anchors.leftMargin: UM.Theme.sizes.default_margin.width;
tooltip: '' tooltip: ''
enabled: progress >= 0.99; enabled: progress > 0.99 && base.activity == true
width: infoBox.width/6*4.5 width: infoBox.width/6*4.5
height: UM.Theme.sizes.save_button_save_to_button.height height: UM.Theme.sizes.save_button_save_to_button.height