mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-07 23:17:32 -06:00
Connection states changes are now tied into the UI again
CL-541
This commit is contained in:
parent
9cfe9769d3
commit
0f78b05802
4 changed files with 19 additions and 13 deletions
|
@ -27,7 +27,7 @@ i18n_catalog = i18nCatalog("cura")
|
|||
@signalemitter
|
||||
class PrinterOutputDevice(QObject, OutputDevice):
|
||||
printersChanged = pyqtSignal()
|
||||
connectionStateChanged = pyqtSignal()
|
||||
connectionStateChanged = pyqtSignal(str)
|
||||
|
||||
def __init__(self, device_id, parent = None):
|
||||
super().__init__(device_id = device_id, parent = parent)
|
||||
|
@ -54,8 +54,10 @@ class PrinterOutputDevice(QObject, OutputDevice):
|
|||
def isConnected(self):
|
||||
return self._connection_state != ConnectionState.closed and self._connection_state != ConnectionState.error
|
||||
|
||||
def setConnectionState(self, new_state):
|
||||
self._connection_state = new_state
|
||||
def setConnectionState(self, connection_state):
|
||||
if self._connection_state != connection_state:
|
||||
self._connection_state = connection_state
|
||||
self.connectionStateChanged.emit(self._id)
|
||||
|
||||
def _update(self):
|
||||
pass
|
||||
|
|
|
@ -133,17 +133,17 @@ class MachineManager(QObject):
|
|||
outputDevicesChanged = pyqtSignal()
|
||||
|
||||
def _onOutputDevicesChanged(self) -> None:
|
||||
for printer_output_device in self._printer_output_devices:
|
||||
'''for printer_output_device in self._printer_output_devices:
|
||||
printer_output_device.hotendIdChanged.disconnect(self._onHotendIdChanged)
|
||||
printer_output_device.materialIdChanged.disconnect(self._onMaterialIdChanged)
|
||||
printer_output_device.materialIdChanged.disconnect(self._onMaterialIdChanged)'''
|
||||
|
||||
self._printer_output_devices.clear()
|
||||
|
||||
for printer_output_device in Application.getInstance().getOutputDeviceManager().getOutputDevices():
|
||||
if isinstance(printer_output_device, PrinterOutputDevice):
|
||||
self._printer_output_devices.append(printer_output_device)
|
||||
printer_output_device.hotendIdChanged.connect(self._onHotendIdChanged)
|
||||
printer_output_device.materialIdChanged.connect(self._onMaterialIdChanged)
|
||||
#printer_output_device.hotendIdChanged.connect(self._onHotendIdChanged)
|
||||
#printer_output_device.materialIdChanged.connect(self._onMaterialIdChanged)
|
||||
|
||||
self.outputDevicesChanged.emit()
|
||||
|
||||
|
|
|
@ -84,7 +84,7 @@ class UM3OutputDevicePlugin(OutputDevicePlugin):
|
|||
def _onDeviceConnectionStateChanged(self, key):
|
||||
if key not in self._discovered_devices:
|
||||
return
|
||||
|
||||
print("STATE CHANGED", key)
|
||||
if self._discovered_devices[key].isConnected():
|
||||
self.getOutputDeviceManager().addOutputDevice(self._discovered_devices[key])
|
||||
else:
|
||||
|
@ -95,8 +95,8 @@ class UM3OutputDevicePlugin(OutputDevicePlugin):
|
|||
Logger.log("d", "zeroconf close...")
|
||||
self._zero_conf.close()
|
||||
|
||||
def _onRemoveDevice(self, name):
|
||||
device = self._discovered_devices.pop(name, None)
|
||||
def _onRemoveDevice(self, device_id):
|
||||
device = self._discovered_devices.pop(device_id, None)
|
||||
if device:
|
||||
if device.isConnected():
|
||||
device.disconnect()
|
||||
|
@ -108,10 +108,12 @@ class UM3OutputDevicePlugin(OutputDevicePlugin):
|
|||
# Check what kind of device we need to add; Depending on the firmware we either add a "Connect"/"Cluster"
|
||||
# or "Legacy" UM3 device.
|
||||
cluster_size = int(properties.get(b"cluster_size", -1))
|
||||
if cluster_size > 0:
|
||||
# TODO: For debug purposes; force it to be legacy printer.
|
||||
device = LegacyUM3OutputDevice.LegacyUM3OutputDevice(name, address, properties)
|
||||
'''if cluster_size > 0:
|
||||
device = ClusterUM3OutputDevice.ClusterUM3OutputDevice(name, address, properties)
|
||||
else:
|
||||
device = LegacyUM3OutputDevice.LegacyUM3OutputDevice(name, address, properties)
|
||||
device = LegacyUM3OutputDevice.LegacyUM3OutputDevice(name, address, properties)'''
|
||||
|
||||
self._discovered_devices[device.getId()] = device
|
||||
self.discoveredDevicesChanged.emit()
|
||||
|
|
|
@ -12,7 +12,9 @@ import Cura 1.0 as Cura
|
|||
Column
|
||||
{
|
||||
id: printMonitor
|
||||
property var connectedPrinter: Cura.MachineManager.printerOutputDevices.length >= 1 ? Cura.MachineManager.printerOutputDevices[0] : null
|
||||
property var connectedDevice: Cura.MachineManager.printerOutputDevices.length >= 1 ? Cura.MachineManager.printerOutputDevices[0] : null
|
||||
|
||||
property var activePrinter: connectedDevice != null ? connectedDevice.activePrinter : null
|
||||
|
||||
Cura.ExtrudersModel
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue