Separate name from address in properties

This way we can display them separately.

Contributes to issue CURA-3161.
This commit is contained in:
Ghostkeeper 2017-02-02 14:27:49 +01:00
parent 5c2f1a935a
commit cda5ee1dca
No known key found for this signature in database
GPG key ID: C5F96EE2BC0F7E75
2 changed files with 22 additions and 6 deletions

View file

@ -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)