Browse Source

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

ChrisTerBeke 6 years ago
parent
commit
5e9fe3fe50

+ 14 - 17
cura/PrinterOutputDevice.py

@@ -81,28 +81,28 @@ class PrinterOutputDevice(QObject, OutputDevice):
         self._printers = []  # type: List[PrinterOutputModel]
         self._unique_configurations = []   # type: List[ConfigurationModel]
 
-        self._monitor_view_qml_path = "" #type: str
-        self._monitor_component = None #type: Optional[QObject]
-        self._monitor_item = None #type: Optional[QObject]
+        self._monitor_view_qml_path = ""  # type: str
+        self._monitor_component = None  # type: Optional[QObject]
+        self._monitor_item = None  # type: Optional[QObject]
 
-        self._control_view_qml_path = "" #type: str
-        self._control_component = None #type: Optional[QObject]
-        self._control_item = None #type: Optional[QObject]
+        self._control_view_qml_path = ""  # type: str
+        self._control_component = None  # type: Optional[QObject]
+        self._control_item = None  # type: Optional[QObject]
 
-        self._accepts_commands = False #type: bool
+        self._accepts_commands = False  # type: bool
 
-        self._update_timer = QTimer() #type: QTimer
+        self._update_timer = QTimer()  # type: QTimer
         self._update_timer.setInterval(2000)  # TODO; Add preference for update interval
         self._update_timer.setSingleShot(False)
         self._update_timer.timeout.connect(self._update)
 
-        self._connection_state = ConnectionState.Closed #type: ConnectionState
-        self._connection_type = connection_type
+        self._connection_state = ConnectionState.Closed  # type: ConnectionState
+        self._connection_type = connection_type  # type: ConnectionType
 
-        self._firmware_updater = None #type: Optional[FirmwareUpdater]
-        self._firmware_name = None #type: Optional[str]
-        self._address = "" #type: str
-        self._connection_text = "" #type: str
+        self._firmware_updater = None  # type: Optional[FirmwareUpdater]
+        self._firmware_name = None  # type: Optional[str]
+        self._address = ""  # type: str
+        self._connection_text = ""  # type: str
         self.printersChanged.connect(self._onPrintersChanged)
         QtApplication.getInstance().getOutputDeviceManager().outputDevicesChanged.connect(self._updateUniqueConfigurations)
 
@@ -131,9 +131,6 @@ class PrinterOutputDevice(QObject, OutputDevice):
             self._connection_state = connection_state
             self.connectionStateChanged.emit(self._id)
 
-    def getConnectionType(self) -> "ConnectionType":
-        return self._connection_type
-
     @pyqtProperty(int, constant = True)
     def connectionType(self) -> "ConnectionType":
         return self._connection_type

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

@@ -138,11 +138,11 @@ class DiscoverUM3Action(MachineAction):
 
                 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)
+                    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.connectionType.value)
             else:
                 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:
             # Ensure that the connection states are refreshed.

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

@@ -288,7 +288,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", device.getConnectionType().value)
+            global_container_stack.setMetaDataEntry("connection_type", device.connectionType.value)
             device.connect()
             device.connectionStateChanged.connect(self._onDeviceConnectionStateChanged)