mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-17 03:37:48 -06:00
Update printer information when switching global container stacks
This was just evaluated once during the creating of a USB connection. But you can switch out the printer without breaking/making a USB connection, so in that case we have to update it here. Contributes to issue CURA-5749.
This commit is contained in:
parent
287689a073
commit
99fc372b32
2 changed files with 10 additions and 6 deletions
|
@ -172,7 +172,7 @@ class PrinterOutputModel(QObject):
|
||||||
def getController(self):
|
def getController(self):
|
||||||
return self._controller
|
return self._controller
|
||||||
|
|
||||||
@pyqtProperty(str, notify=nameChanged)
|
@pyqtProperty(str, notify = nameChanged)
|
||||||
def name(self):
|
def name(self):
|
||||||
return self._name
|
return self._name
|
||||||
|
|
||||||
|
|
|
@ -273,14 +273,18 @@ class USBPrinterOutputDevice(PrinterOutputDevice):
|
||||||
except SerialException:
|
except SerialException:
|
||||||
Logger.log("w", "An exception occured while trying to create serial connection")
|
Logger.log("w", "An exception occured while trying to create serial connection")
|
||||||
return
|
return
|
||||||
container_stack = CuraApplication.getInstance().getGlobalContainerStack()
|
CuraApplication.getInstance().globalContainerStackChanged.connect(self._onGlobalContainerStackChanged)
|
||||||
num_extruders = container_stack.getProperty("machine_extruder_count", "value")
|
self._onGlobalContainerStackChanged()
|
||||||
# Ensure that a printer is created.
|
|
||||||
self._printers = [PrinterOutputModel(output_controller=GenericOutputController(self), number_of_extruders=num_extruders)]
|
|
||||||
self._printers[0].updateName(container_stack.getName())
|
|
||||||
self.setConnectionState(ConnectionState.connected)
|
self.setConnectionState(ConnectionState.connected)
|
||||||
self._update_thread.start()
|
self._update_thread.start()
|
||||||
|
|
||||||
|
def _onGlobalContainerStackChanged(self):
|
||||||
|
container_stack = CuraApplication.getInstance().getGlobalContainerStack()
|
||||||
|
num_extruders = container_stack.getProperty("machine_extruder_count", "value")
|
||||||
|
#Ensure that a printer is created.
|
||||||
|
self._printers = [PrinterOutputModel(output_controller = GenericOutputController(self), number_of_extruders = num_extruders)]
|
||||||
|
self._printers[0].updateName(container_stack.getName())
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
super().close()
|
super().close()
|
||||||
if self._serial is not None:
|
if self._serial is not None:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue