mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-20 02:59:06 +08:00
Merge pull request #5611 from Ultimaker/CURA-6449_fix_non_host_printers
CURA-6449 Disable printers that are not host of a group
This commit is contained in:
commit
4c214f5b2d
@ -67,12 +67,25 @@ class DiscoveredPrinter(QObject):
|
||||
|
||||
@pyqtProperty(bool, notify = machineTypeChanged)
|
||||
def isUnknownMachineType(self) -> bool:
|
||||
return self.readableMachineType.lower() == "unknown"
|
||||
from cura.CuraApplication import CuraApplication
|
||||
readable_type = CuraApplication.getInstance().getMachineManager().getMachineTypeNameFromId(self._machine_type)
|
||||
return not readable_type
|
||||
|
||||
@pyqtProperty(QObject, constant = True)
|
||||
def device(self) -> "NetworkedPrinterOutputDevice":
|
||||
return self._device
|
||||
|
||||
@pyqtProperty(bool, constant = True)
|
||||
def isHostOfGroup(self) -> bool:
|
||||
return getattr(self._device, "clusterSize", 1) > 0
|
||||
|
||||
@pyqtProperty(str, constant = True)
|
||||
def sectionName(self) -> str:
|
||||
if self.isUnknownMachineType or not self.isHostOfGroup:
|
||||
return catalog.i18nc("@label", "The printer(s) below cannot be connected because they are part of a group")
|
||||
else:
|
||||
return catalog.i18nc("@label", "Available networked printers")
|
||||
|
||||
|
||||
#
|
||||
# Discovered printers are all the printers that were found on the network, which provide a more convenient way
|
||||
@ -92,7 +105,7 @@ class DiscoveredPrintersModel(QObject):
|
||||
def discoveredPrinters(self) -> List["DiscoveredPrinter"]:
|
||||
item_list = list(
|
||||
x for x in self._discovered_printer_by_ip_dict.values() if not parseBool(x.device.getProperty("temporary")))
|
||||
item_list.sort(key = lambda x: x.device.name)
|
||||
item_list.sort(key = lambda x: (int(not x.isUnknownMachineType), getattr(x.device, "clusterSize", 1), x.device.name), reverse = True)
|
||||
return item_list
|
||||
|
||||
def addDiscoveredPrinter(self, ip_address: str, key: str, name: str, create_callback: Callable[[str], None],
|
||||
|
@ -53,7 +53,7 @@ Button
|
||||
verticalCenter: parent.verticalCenter
|
||||
}
|
||||
text: machineSelectorButton.text
|
||||
color: UM.Theme.getColor("text")
|
||||
color: enabled ? UM.Theme.getColor("text") : UM.Theme.getColor("small_button_text")
|
||||
font: UM.Theme.getFont("medium")
|
||||
visible: text != ""
|
||||
renderType: Text.NativeRendering
|
||||
|
@ -68,6 +68,10 @@ Item
|
||||
anchors.fill: parent
|
||||
model: CuraApplication.getDiscoveredPrintersModel().discoveredPrinters
|
||||
|
||||
section.property: "modelData.sectionName"
|
||||
section.criteria: ViewSection.FullString
|
||||
section.delegate: sectionHeading
|
||||
|
||||
Component.onCompleted:
|
||||
{
|
||||
// Select the first one that's not "unknown" by default.
|
||||
@ -81,6 +85,23 @@ Item
|
||||
}
|
||||
}
|
||||
|
||||
Component
|
||||
{
|
||||
id: sectionHeading
|
||||
|
||||
Label
|
||||
{
|
||||
anchors.left: parent.left
|
||||
anchors.leftMargin: UM.Theme.getSize("default_margin").width
|
||||
height: UM.Theme.getSize("setting_control").height
|
||||
text: section
|
||||
font: UM.Theme.getFont("default")
|
||||
color: UM.Theme.getColor("small_button_text")
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
renderType: Text.NativeRendering
|
||||
}
|
||||
}
|
||||
|
||||
delegate: Cura.MachineSelectorButton
|
||||
{
|
||||
text: modelData.device.name
|
||||
@ -88,7 +109,7 @@ Item
|
||||
width: networkPrinterListView.width
|
||||
outputDevice: modelData.device
|
||||
|
||||
enabled: !modelData.isUnknownMachineType
|
||||
enabled: !modelData.isUnknownMachineType && modelData.isHostOfGroup
|
||||
|
||||
printerTypeLabelAutoFit: true
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user