Fix some codestyle, make connectionType a property as it's needed in QML

This commit is contained in:
ChrisTerBeke 2018-12-19 11:21:50 +01:00
parent d3419f2e07
commit 5e9fe3fe50
3 changed files with 18 additions and 21 deletions

View file

@ -97,7 +97,7 @@ class PrinterOutputDevice(QObject, OutputDevice):
self._update_timer.timeout.connect(self._update) self._update_timer.timeout.connect(self._update)
self._connection_state = ConnectionState.Closed # type: ConnectionState self._connection_state = ConnectionState.Closed # type: ConnectionState
self._connection_type = connection_type self._connection_type = connection_type # type: ConnectionType
self._firmware_updater = None # type: Optional[FirmwareUpdater] self._firmware_updater = None # type: Optional[FirmwareUpdater]
self._firmware_name = None # type: Optional[str] self._firmware_name = None # type: Optional[str]
@ -131,9 +131,6 @@ class PrinterOutputDevice(QObject, OutputDevice):
self._connection_state = connection_state self._connection_state = connection_state
self.connectionStateChanged.emit(self._id) self.connectionStateChanged.emit(self._id)
def getConnectionType(self) -> "ConnectionType":
return self._connection_type
@pyqtProperty(int, constant = True) @pyqtProperty(int, constant = True)
def connectionType(self) -> "ConnectionType": def connectionType(self) -> "ConnectionType":
return self._connection_type return self._connection_type

View file

@ -138,11 +138,11 @@ class DiscoverUM3Action(MachineAction):
if "connection_type" in meta_data: if "connection_type" in meta_data:
previous_connection_type = meta_data["connection_type"] previous_connection_type = meta_data["connection_type"]
global_container_stack.setMetaDataEntry("connection_type", printer_device.getConnectionType().value) global_container_stack.setMetaDataEntry("connection_type", printer_device.connectionType.value)
CuraApplication.getInstance().getMachineManager().replaceContainersMetadata(key = "connection_type", value = previous_connection_type, new_value = printer_device.getConnectionType().value) CuraApplication.getInstance().getMachineManager().replaceContainersMetadata(key = "connection_type", value = previous_connection_type, new_value = printer_device.connectionType.value)
else: else:
global_container_stack.setMetaDataEntry("um_network_key", printer_device.key) global_container_stack.setMetaDataEntry("um_network_key", printer_device.key)
global_container_stack.setMetaDataEntry("connection_type", printer_device.getConnectionType().value) global_container_stack.setMetaDataEntry("connection_type", printer_device.connectionType.value)
if self._network_plugin: if self._network_plugin:
# Ensure that the connection states are refreshed. # Ensure that the connection states are refreshed.

View file

@ -288,7 +288,7 @@ class UM3OutputDevicePlugin(OutputDevicePlugin):
global_container_stack = Application.getInstance().getGlobalContainerStack() global_container_stack = Application.getInstance().getGlobalContainerStack()
if global_container_stack and device.getId() == global_container_stack.getMetaDataEntry("um_network_key"): if global_container_stack and device.getId() == global_container_stack.getMetaDataEntry("um_network_key"):
global_container_stack.setMetaDataEntry("connection_type", device.getConnectionType().value) global_container_stack.setMetaDataEntry("connection_type", device.connectionType.value)
device.connect() device.connect()
device.connectionStateChanged.connect(self._onDeviceConnectionStateChanged) device.connectionStateChanged.connect(self._onDeviceConnectionStateChanged)