Make pre-heat button cancel if currently heating

This is based on the timer, which is locally. Eventually we'd want to make the timer update every now and then or so.

Contributes to issue CURA-3161.
This commit is contained in:
Ghostkeeper 2017-02-07 16:46:22 +01:00
parent 9b235aebf2
commit 8d09c53896
No known key found for this signature in database
GPG key ID: C5F96EE2BC0F7E75

View file

@ -323,7 +323,7 @@ Column
Button //The pre-heat button.
{
id: preheatButton
text: catalog.i18nc("@button", "Pre-heat")
text: preheatCountdownTimer.running ? catalog.i18nc("@button Cancel pre-heating", "Cancel") : catalog.i18nc("@button", "Pre-heat")
tooltip: catalog.i18nc("@tooltip of pre-heat", "Heat the bed in advance before printing. You can continue adjusting your print while it is heating, and you won't have to wait for the bed to heat up when you're ready to print.")
height: UM.Theme.getSize("setting_control").height
enabled: printerConnected
@ -416,13 +416,22 @@ Column
onClicked:
{
connectedPrinter.preheatBed(preheatTemperatureInput.text, connectedPrinter.preheatBedTimeout);
var now = new Date();
var end_time = new Date();
end_time.setTime(now.getTime() + connectedPrinter.preheatBedTimeout * 1000); //*1000 because time is in milliseconds here.
preheatCountdownTimer.endTime = end_time;
preheatCountdownTimer.start();
preheatCountdownTimer.update(); //Update once before the first timer is triggered.
if (!preheatCountdownTimer.running)
{
connectedPrinter.preheatBed(preheatTemperatureInput.text, connectedPrinter.preheatBedTimeout);
var now = new Date();
var end_time = new Date();
end_time.setTime(now.getTime() + connectedPrinter.preheatBedTimeout * 1000); //*1000 because time is in milliseconds here.
preheatCountdownTimer.endTime = end_time;
preheatCountdownTimer.start();
preheatCountdownTimer.update(); //Update once before the first timer is triggered.
}
else
{
connectedPrinter.cancelPreheatBed();
preheatCountdownTimer.endTime = new Date();
preheatCountdownTimer.update();
}
}
}
}