Browse Source

Fix review comments

CURA-6011
Jaime van Kessel 6 years ago
parent
commit
84a7f2e5a2

+ 1 - 1
cura/PrintersModel.py

@@ -54,7 +54,7 @@ class PrintersModel(ListModel):
 
         for container_stack in container_stacks:
             connection_type = container_stack.getMetaDataEntry("connection_type")
-            has_remote_connection = connection_type in [str(ConnectionType.NetworkConnection), str(ConnectionType.CloudConnection)]
+            has_remote_connection = connection_type in [ConnectionType.NetworkConnection.value, ConnectionType.CloudConnection.value]
 
             if container_stack.getMetaDataEntry("hidden", False) in ["True", True]:
                 continue

+ 2 - 2
cura/Settings/MachineManager.py

@@ -521,11 +521,11 @@ class MachineManager(QObject):
     def printerConnected(self):
         return bool(self._printer_output_devices)
 
-    @pyqtProperty(bool, notify=printerConnectedStatusChanged)
+    @pyqtProperty(bool, notify = printerConnectedStatusChanged)
     def activeMachineHasRemoteConnection(self) -> bool:
         if self._global_container_stack:
             connection_type = self._global_container_stack.getMetaDataEntry("connection_type")
-            return connection_type in [str(ConnectionType.NetworkConnection), str(ConnectionType.CloudConnection)]
+            return connection_type in [ConnectionType.NetworkConnection.value, ConnectionType.CloudConnection.value]
         return False
 
     def activeMachineNetworkKey(self) -> str:

+ 5 - 5
plugins/UM3NetworkPrinting/src/DiscoverUM3Action.py

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

+ 1 - 1
plugins/UM3NetworkPrinting/src/UM3OutputDevicePlugin.py

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

+ 1 - 1
plugins/USBPrinting/USBPrinterOutputDevice.py

@@ -29,7 +29,7 @@ catalog = i18nCatalog("cura")
 
 class USBPrinterOutputDevice(PrinterOutputDevice):
     def __init__(self, serial_port: str, baud_rate: Optional[int] = None) -> None:
-        super().__init__(serial_port, connection_type=ConnectionType.UsbConnection)
+        super().__init__(serial_port, connection_type = ConnectionType.UsbConnection)
         self.setName(catalog.i18nc("@item:inmenu", "USB printing"))
         self.setShortDescription(catalog.i18nc("@action:button Preceded by 'Ready to'.", "Print via USB"))
         self.setDescription(catalog.i18nc("@info:tooltip", "Print via USB"))