mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-13 09:47:50 -06:00
Disable printers that are not host of a group
CURA-6449 - Group printers into hosts and non-hosts and of unknown type. - Show available/connectable printers first in the list. - Show sections for connectable and non-connectable printers.
This commit is contained in:
parent
7d644c0d1a
commit
588dd6cd78
3 changed files with 36 additions and 4 deletions
|
@ -66,12 +66,23 @@ class DiscoveredPrinter(QObject):
|
||||||
|
|
||||||
@pyqtProperty(bool, notify = machineTypeChanged)
|
@pyqtProperty(bool, notify = machineTypeChanged)
|
||||||
def isUnknownMachineType(self) -> bool:
|
def isUnknownMachineType(self) -> bool:
|
||||||
return self.readableMachineType.lower() == "unknown"
|
return self.readableMachineType == catalog.i18nc("@label", "Unknown")
|
||||||
|
|
||||||
@pyqtProperty(QObject, constant = True)
|
@pyqtProperty(QObject, constant = True)
|
||||||
def device(self) -> "NetworkedPrinterOutputDevice":
|
def device(self) -> "NetworkedPrinterOutputDevice":
|
||||||
return self._device
|
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 network printers")
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Discovered printers are all the printers that were found on the network, which provide a more convenient way
|
# Discovered printers are all the printers that were found on the network, which provide a more convenient way
|
||||||
|
@ -90,7 +101,7 @@ class DiscoveredPrintersModel(QObject):
|
||||||
@pyqtProperty(list, notify = discoveredPrintersChanged)
|
@pyqtProperty(list, notify = discoveredPrintersChanged)
|
||||||
def discoveredPrinters(self) -> List["DiscoveredPrinter"]:
|
def discoveredPrinters(self) -> List["DiscoveredPrinter"]:
|
||||||
item_list = list(x for x in self._discovered_printer_by_ip_dict.values())
|
item_list = list(x for x in self._discovered_printer_by_ip_dict.values())
|
||||||
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
|
return item_list
|
||||||
|
|
||||||
def addDiscoveredPrinter(self, ip_address: str, key: str, name: str, create_callback: Callable[[str], None],
|
def addDiscoveredPrinter(self, ip_address: str, key: str, name: str, create_callback: Callable[[str], None],
|
||||||
|
|
|
@ -53,7 +53,7 @@ Button
|
||||||
verticalCenter: parent.verticalCenter
|
verticalCenter: parent.verticalCenter
|
||||||
}
|
}
|
||||||
text: machineSelectorButton.text
|
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")
|
font: UM.Theme.getFont("medium")
|
||||||
visible: text != ""
|
visible: text != ""
|
||||||
renderType: Text.NativeRendering
|
renderType: Text.NativeRendering
|
||||||
|
|
|
@ -71,6 +71,10 @@ Item
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
model: CuraApplication.getDiscoveredPrintersModel().discoveredPrinters
|
model: CuraApplication.getDiscoveredPrintersModel().discoveredPrinters
|
||||||
|
|
||||||
|
section.property: "modelData.sectionName"
|
||||||
|
section.criteria: ViewSection.FullString
|
||||||
|
section.delegate: sectionHeading
|
||||||
|
|
||||||
Component.onCompleted:
|
Component.onCompleted:
|
||||||
{
|
{
|
||||||
// Select the first one that's not "unknown" by default.
|
// Select the first one that's not "unknown" by default.
|
||||||
|
@ -84,6 +88,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: MachineSelectorButton
|
delegate: MachineSelectorButton
|
||||||
{
|
{
|
||||||
text: modelData.device.name
|
text: modelData.device.name
|
||||||
|
@ -93,7 +114,7 @@ Item
|
||||||
anchors.rightMargin: UM.Theme.getSize("default_margin").width
|
anchors.rightMargin: UM.Theme.getSize("default_margin").width
|
||||||
outputDevice: modelData.device
|
outputDevice: modelData.device
|
||||||
|
|
||||||
enabled: !modelData.isUnknownMachineType
|
enabled: !modelData.isUnknownMachineType && modelData.isHostOfGroup
|
||||||
|
|
||||||
printerTypeLabelAutoFit: true
|
printerTypeLabelAutoFit: true
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue