diff --git a/cura/PrinterOutputDevice.py b/cura/PrinterOutputDevice.py index d791e50260..21f03a11ea 100644 --- a/cura/PrinterOutputDevice.py +++ b/cura/PrinterOutputDevice.py @@ -108,6 +108,9 @@ class PrinterOutputDevice(QObject, OutputDevice): printerTypeChanged = pyqtSignal() + # Signal to be emitted when some drastic change occurs in the remaining time (not when the time just passes on normally). + preheatBedRemainingTimeChanged = pyqtSignal() + @pyqtProperty(str, notify=printerTypeChanged) def printerType(self): return self._printer_type @@ -227,7 +230,7 @@ class PrinterOutputDevice(QObject, OutputDevice): # # This is formatted in M:SS format. # \return The duration of the time-out to pre-heat the bed, formatted. - @pyqtProperty(str) + @pyqtProperty(str, notify = preheatBedRemainingTimeChanged) def preheatBedRemainingTime(self): period = self._preheat_bed_timer.remainingTime() if period <= 0: diff --git a/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py b/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py index 11f7415400..a95a63995d 100644 --- a/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py +++ b/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py @@ -264,6 +264,7 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice): put_request.setHeader(QNetworkRequest.ContentTypeHeader, "application/json") self._manager.put(put_request, data.encode()) self._preheat_bed_timer.start(self._preheat_bed_timeout * 1000) #Times 1000 because it needs to be provided as milliseconds. + self.preheatBedRemainingTimeChanged.emit() ## Cancels pre-heating the heated bed of the printer. # @@ -274,6 +275,7 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice): self.preheatBed(temperature = 0, duration = 0) self._preheat_bed_timer.stop() self._preheat_bed_timer.setInterval(0) + self.preheatBedRemainingTimeChanged.emit() ## Changes the target bed temperature on the printer. # diff --git a/plugins/USBPrinting/USBPrinterOutputDevice.py b/plugins/USBPrinting/USBPrinterOutputDevice.py index 1af9e8b8fb..754053306a 100644 --- a/plugins/USBPrinting/USBPrinterOutputDevice.py +++ b/plugins/USBPrinting/USBPrinterOutputDevice.py @@ -652,6 +652,7 @@ class USBPrinterOutputDevice(PrinterOutputDevice): def preheatBed(self, temperature, duration): Logger.log("i", "Pre-heating the bed to %i degrees.", temperature) self._setTargetBedTemperature(temperature) + self.preheatBedRemainingTimeChanged.emit() ## Cancels pre-heating the heated bed of the printer. # @@ -659,4 +660,5 @@ class USBPrinterOutputDevice(PrinterOutputDevice): @pyqtSlot() def cancelPreheatBed(self): Logger.log("i", "Cancelling pre-heating of the bed.") - self._setTargetBedTemperature(0) \ No newline at end of file + self._setTargetBedTemperature(0) + self.preheatBedRemainingTimeChanged.emit() \ No newline at end of file diff --git a/resources/qml/PrintMonitor.qml b/resources/qml/PrintMonitor.qml index e5942d1c31..0b9d73081b 100644 --- a/resources/qml/PrintMonitor.qml +++ b/resources/qml/PrintMonitor.qml @@ -282,7 +282,7 @@ Column { id: preheatUpdateTimer interval: 100 //Update every 100ms. You want to update every 1s, but then you have one timer for the updating running out of sync with the actual date timer and you might skip seconds. - running: false + running: connectedPrinter.preheatBedRemainingTime != "" repeat: true onTriggered: update() property var endTime: new Date() //Set initial endTime to be the current date, so that the endTime has initially already passed and the timer text becomes invisible if you were to update. @@ -302,7 +302,7 @@ Column Label { id: preheatCountdown - text: "" + text: connectedPrinter != null ? connectedPrinter.preheatBedRemainingTime : "" visible: text != "" //Has no direct effect, but just so that we can link visibility of clock icon to visibility of the countdown text. font: UM.Theme.getFont("default") color: UM.Theme.getColor("text")