mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-07 15:07:28 -06:00
Separate name from address in properties
This way we can display them separately. Contributes to issue CURA-3161.
This commit is contained in:
parent
5c2f1a935a
commit
cda5ee1dca
2 changed files with 22 additions and 6 deletions
|
@ -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.
|
# Cura is released under the terms of the AGPLv3 or higher.
|
||||||
|
|
||||||
from UM.i18n import i18nCatalog
|
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.setPriority(2) # Make sure the output device gets selected above local file output
|
||||||
self.setName(key)
|
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.setDescription(i18n_catalog.i18nc("@properties:tooltip", "Print over network"))
|
||||||
self.setIconName("print")
|
self.setIconName("print")
|
||||||
|
|
||||||
|
@ -220,6 +220,11 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice):
|
||||||
def getKey(self):
|
def getKey(self):
|
||||||
return self._key
|
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)
|
## Name of the printer (as returned from the zeroConf properties)
|
||||||
@pyqtProperty(str, constant = True)
|
@pyqtProperty(str, constant = True)
|
||||||
def name(self):
|
def name(self):
|
||||||
|
|
|
@ -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 UM.OutputDevice.OutputDevicePlugin import OutputDevicePlugin
|
||||||
from . import NetworkPrinterOutputDevice
|
from . import NetworkPrinterOutputDevice
|
||||||
|
|
||||||
|
@ -75,9 +78,13 @@ class NetworkPrinterOutputDevicePlugin(OutputDevicePlugin):
|
||||||
self._manual_instances.append(address)
|
self._manual_instances.append(address)
|
||||||
self._preferences.setValue("um3networkprinting/manual_instances", ",".join(self._manual_instances))
|
self._preferences.setValue("um3networkprinting/manual_instances", ",".join(self._manual_instances))
|
||||||
|
|
||||||
name = address
|
|
||||||
instance_name = "manual:%s" % 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:
|
if instance_name not in self._printers:
|
||||||
# Add a preliminary printer instance
|
# Add a preliminary printer instance
|
||||||
|
@ -112,10 +119,14 @@ class NetworkPrinterOutputDevicePlugin(OutputDevicePlugin):
|
||||||
if status_code == 200:
|
if status_code == 200:
|
||||||
system_info = json.loads(bytes(reply.readAll()).decode("utf-8"))
|
system_info = json.loads(bytes(reply.readAll()).decode("utf-8"))
|
||||||
address = reply.url().host()
|
address = reply.url().host()
|
||||||
name = ("%s (%s)" % (system_info["name"], address))
|
|
||||||
|
|
||||||
instance_name = "manual:%s" % 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:
|
if instance_name in self._printers:
|
||||||
# Only replace the printer if it is still in the list of (manual) printers
|
# Only replace the printer if it is still in the list of (manual) printers
|
||||||
self.removePrinter(instance_name)
|
self.removePrinter(instance_name)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue