diff --git a/cura/PrinterOutputDevice.py b/cura/PrinterOutputDevice.py index 2aa6fb382e..0141e74ba4 100644 --- a/cura/PrinterOutputDevice.py +++ b/cura/PrinterOutputDevice.py @@ -41,6 +41,9 @@ class PrinterOutputDevice(QObject, OutputDevice): # # Signal to indicate that the hotend of the active printer on the remote changed. hotendIdChanged = pyqtSignal() + # Signal to indicate that the info text about the connection has changed. + connectionTextChanged = pyqtSignal() + def __init__(self, device_id, parent = None): super().__init__(device_id = device_id, parent = parent) @@ -65,11 +68,21 @@ class PrinterOutputDevice(QObject, OutputDevice): self._connection_state = ConnectionState.closed self._address = "" + self._connection_text = "" - @pyqtProperty(str, constant = True) + @pyqtProperty(str, notify = connectionTextChanged) def address(self): return self._address + def setConnectionText(self, connection_text): + if self._connection_text != connection_text: + self._connection_text = connection_text + self.connectionTextChanged.emit() + + @pyqtProperty(str, constant=True) + def connectionText(self): + return self._connection_text + def materialHotendChangedMessage(self, callback): Logger.log("w", "materialHotendChangedMessage needs to be implemented, returning 'Yes'") callback(QMessageBox.Yes) diff --git a/plugins/PostProcessingPlugin/PostProcessingPlugin.py b/plugins/PostProcessingPlugin/PostProcessingPlugin.py index 657e5c5387..fa519f48be 100644 --- a/plugins/PostProcessingPlugin/PostProcessingPlugin.py +++ b/plugins/PostProcessingPlugin/PostProcessingPlugin.py @@ -54,7 +54,11 @@ class PostProcessingPlugin(QObject, Extension): ## Execute all post-processing scripts on the gcode. def execute(self, output_device): scene = Application.getInstance().getController().getScene() - gcode_dict = getattr(scene, "gcode_dict") + gcode_dict = None + + if hasattr(scene, "gcode_dict"): + gcode_dict = getattr(scene, "gcode_dict") + if not gcode_dict: return diff --git a/plugins/UM3NetworkPrinting/ClusterUM3OutputDevice.py b/plugins/UM3NetworkPrinting/ClusterUM3OutputDevice.py index 7bdf6090de..6c0cc554e7 100644 --- a/plugins/UM3NetworkPrinting/ClusterUM3OutputDevice.py +++ b/plugins/UM3NetworkPrinting/ClusterUM3OutputDevice.py @@ -69,6 +69,8 @@ class ClusterUM3OutputDevice(NetworkedPrinterOutputDevice): self.setShortDescription(i18n_catalog.i18nc("@action:button Preceded by 'Ready to'.", "Print over network")) self.setDescription(i18n_catalog.i18nc("@properties:tooltip", "Print over network")) + self.setConnectionText(i18n_catalog.i18nc("@info:status", "Connected over the network")) + self._printer_uuid_to_unique_name_mapping = {} self._finished_jobs = [] diff --git a/plugins/UM3NetworkPrinting/LegacyUM3OutputDevice.py b/plugins/UM3NetworkPrinting/LegacyUM3OutputDevice.py index a63adadd54..647a7f822c 100644 --- a/plugins/UM3NetworkPrinting/LegacyUM3OutputDevice.py +++ b/plugins/UM3NetworkPrinting/LegacyUM3OutputDevice.py @@ -78,10 +78,16 @@ class LegacyUM3OutputDevice(NetworkedPrinterOutputDevice): def _onAuthenticationStateChanged(self): # We only accept commands if we are authenticated. + self._setAcceptsCommands(self._authentication_state == AuthState.Authenticated) + if self._authentication_state == AuthState.Authenticated: - self._setAcceptsCommands(True) - else: - self._setAcceptsCommands(False) + self.setConnectionText(i18n_catalog.i18nc("@info:status", "Connected over the network.")) + elif self._authentication_state == AuthState.AuthenticationRequested: + self.setConnectionText(i18n_catalog.i18nc("@info:status", + "Connected over the network. Please approve the access request on the printer.")) + elif self._authentication_state == AuthState.AuthenticationDenied: + self.setConnectionText(i18n_catalog.i18nc("@info:status", "Connected over the network. No access to control the printer.")) + def _setupMessages(self): self._authentication_requested_message = Message(i18n_catalog.i18nc("@info:status", diff --git a/plugins/USBPrinting/USBPrinterOutputDevice.py b/plugins/USBPrinting/USBPrinterOutputDevice.py index 6c03450a88..d372b54c38 100644 --- a/plugins/USBPrinting/USBPrinterOutputDevice.py +++ b/plugins/USBPrinting/USBPrinterOutputDevice.py @@ -80,6 +80,8 @@ class USBPrinterOutputDevice(PrinterOutputDevice): self._firmware_progress = 0 self._firmware_update_state = FirmwareUpdateState.idle + self.setConnectionText(catalog.i18nc("@info:status", "Connected via USB")) + # Queue for commands that need to be send. Used when command is sent when a print is active. self._command_queue = Queue() diff --git a/resources/qml/Preferences/MachinesPage.qml b/resources/qml/Preferences/MachinesPage.qml index a8e25155e1..889dfa8d5b 100644 --- a/resources/qml/Preferences/MachinesPage.qml +++ b/resources/qml/Preferences/MachinesPage.qml @@ -143,7 +143,7 @@ UM.ManagementPage property bool printerConnected: Cura.MachineManager.printerOutputDevices.length != 0 property var connectedPrinter: printerConnected ? Cura.MachineManager.printerOutputDevices[0] : null property bool printerAcceptsCommands: printerConnected && Cura.MachineManager.printerOutputDevices[0].acceptsCommands - + property var printJob: connectedPrinter != null ? connectedPrinter.activePrintJob: null Label { text: catalog.i18nc("@label", "Printer type:") @@ -178,7 +178,12 @@ UM.ManagementPage return ""; } - switch(Cura.MachineManager.printerOutputDevices[0].jobState) + if (machineInfo.printJob == null) + { + return catalog.i18nc("@label:MonitorStatus", "Waiting for a printjob"); + } + + switch(machineInfo.printJob.state) { case "printing": return catalog.i18nc("@label:MonitorStatus", "Printing..."); @@ -194,10 +199,9 @@ UM.ManagementPage return catalog.i18nc("@label:MonitorStatus", "In maintenance. Please check the printer"); case "abort": // note sure if this jobState actually occurs in the wild return catalog.i18nc("@label:MonitorStatus", "Aborting print..."); - case "ready": // ready to print or getting ready - case "": // ready to print or getting ready - return catalog.i18nc("@label:MonitorStatus", "Waiting for a printjob"); + } + return "" } visible: base.currentItem && base.currentItem.id == Cura.MachineManager.activeMachineId && machineInfo.printerAcceptsCommands wrapMode: Text.WordWrap