Browse Source

Separate name from address in properties

This way we can display them separately.

Contributes to issue CURA-3161.
Ghostkeeper 8 years ago
parent
commit
cda5ee1dca

+ 7 - 2
plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py

@@ -1,4 +1,4 @@
-# Copyright (c) 2016 Ultimaker B.V.
+# Copyright (c) 2017 Ultimaker B.V.
 # Cura is released under the terms of the AGPLv3 or higher.
 
 from UM.i18n import i18nCatalog
@@ -100,7 +100,7 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice):
 
         self.setPriority(2) # Make sure the output device gets selected above local file output
         self.setName(key)
-        self.setShortDescription(i18n_catalog.i18nc("@action:button Preceded by 'Ready to'.", "Print over network"))
+        self.setShortDescription(i18n_catalog.i18nc("@action:button Preceded by 'Ready to'.", "print over network"))
         self.setDescription(i18n_catalog.i18nc("@properties:tooltip", "Print over network"))
         self.setIconName("print")
 
@@ -220,6 +220,11 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice):
     def getKey(self):
         return self._key
 
+    ##  The IP address of the printer.
+    @pyqtProperty(str, constant = True)
+    def address(self):
+        return self._properties.get(b"address", b"0.0.0.0").decode("utf-8")
+
     ##  Name of the printer (as returned from the zeroConf properties)
     @pyqtProperty(str, constant = True)
     def name(self):

+ 15 - 4
plugins/UM3NetworkPrinting/NetworkPrinterOutputDevicePlugin.py

@@ -1,3 +1,6 @@
+# Copyright (c) 2017 Ultimaker B.V.
+# Cura is released under the terms of the AGPLv3 or higher.
+
 from UM.OutputDevice.OutputDevicePlugin import OutputDevicePlugin
 from . import NetworkPrinterOutputDevice
 
@@ -75,9 +78,13 @@ class NetworkPrinterOutputDevicePlugin(OutputDevicePlugin):
             self._manual_instances.append(address)
             self._preferences.setValue("um3networkprinting/manual_instances", ",".join(self._manual_instances))
 
-        name = address
         instance_name = "manual:%s" % address
-        properties = { b"name": name.encode("utf-8"), b"manual": b"true", b"incomplete": b"true" }
+        properties = {
+            b"name": address.encode("utf-8"),
+            b"address": address.encode("utf-8"),
+            b"manual": b"true",
+            b"incomplete": b"true"
+        }
 
         if instance_name not in self._printers:
             # Add a preliminary printer instance
@@ -112,10 +119,14 @@ class NetworkPrinterOutputDevicePlugin(OutputDevicePlugin):
                 if status_code == 200:
                     system_info = json.loads(bytes(reply.readAll()).decode("utf-8"))
                     address = reply.url().host()
-                    name = ("%s (%s)" % (system_info["name"], address))
 
                     instance_name = "manual:%s" % address
-                    properties = { b"name": name.encode("utf-8"), b"firmware_version": system_info["firmware"].encode("utf-8"), b"manual": b"true" }
+                    properties = {
+                        b"name": system_info["name"].encode("utf-8"),
+                        b"address": address.encode("utf-8"),
+                        b"firmware_version": system_info["firmware"].encode("utf-8"),
+                        b"manual": b"true"
+                    }
                     if instance_name in self._printers:
                         # Only replace the printer if it is still in the list of (manual) printers
                         self.removePrinter(instance_name)