mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-14 10:17:52 -06:00
Add button to hide/show connected printers
CURA-9514
This commit is contained in:
parent
401170d8dd
commit
ac732e9604
2 changed files with 51 additions and 8 deletions
|
@ -5,7 +5,7 @@
|
||||||
# online cloud connected printers are represented within this ListModel. Additional information such as the number of
|
# online cloud connected printers are represented within this ListModel. Additional information such as the number of
|
||||||
# connected printers for each printer type is gathered.
|
# connected printers for each printer type is gathered.
|
||||||
|
|
||||||
from PyQt6.QtCore import Qt, QTimer
|
from PyQt6.QtCore import Qt, QTimer, pyqtSlot, pyqtProperty, pyqtSignal
|
||||||
|
|
||||||
from UM.Qt.ListModel import ListModel
|
from UM.Qt.ListModel import ListModel
|
||||||
from UM.Settings.ContainerStack import ContainerStack
|
from UM.Settings.ContainerStack import ContainerStack
|
||||||
|
@ -29,6 +29,8 @@ class MachineListModel(ListModel):
|
||||||
def __init__(self, parent=None) -> None:
|
def __init__(self, parent=None) -> None:
|
||||||
super().__init__(parent)
|
super().__init__(parent)
|
||||||
|
|
||||||
|
self._show_cloud_printers = True
|
||||||
|
|
||||||
self._catalog = i18nCatalog("cura")
|
self._catalog = i18nCatalog("cura")
|
||||||
|
|
||||||
self.addRoleName(self.NameRole, "name")
|
self.addRoleName(self.NameRole, "name")
|
||||||
|
@ -50,6 +52,18 @@ class MachineListModel(ListModel):
|
||||||
CuraContainerRegistry.getInstance().containerRemoved.connect(self._onContainerChanged)
|
CuraContainerRegistry.getInstance().containerRemoved.connect(self._onContainerChanged)
|
||||||
self._updateDelayed()
|
self._updateDelayed()
|
||||||
|
|
||||||
|
showCloutPrintersChanged = pyqtSignal(bool)
|
||||||
|
|
||||||
|
@pyqtProperty(bool, notify=showCloutPrintersChanged)
|
||||||
|
def showCloudPrinters(self) -> bool:
|
||||||
|
return self._show_cloud_printers
|
||||||
|
|
||||||
|
@pyqtSlot(bool, name="setShowCloudPrinters")
|
||||||
|
def set_show_cloud_printers(self, show_cloud_printers: bool) -> None:
|
||||||
|
self._show_cloud_printers = show_cloud_printers
|
||||||
|
self._updateDelayed()
|
||||||
|
self.showCloutPrintersChanged.emit(show_cloud_printers)
|
||||||
|
|
||||||
def _onContainerChanged(self, container) -> None:
|
def _onContainerChanged(self, container) -> None:
|
||||||
"""Handler for container added/removed events from registry"""
|
"""Handler for container added/removed events from registry"""
|
||||||
|
|
||||||
|
@ -80,6 +94,7 @@ class MachineListModel(ListModel):
|
||||||
|
|
||||||
# Create list of machines that are children of the abstract machine
|
# Create list of machines that are children of the abstract machine
|
||||||
for stack in online_machine_stacks:
|
for stack in online_machine_stacks:
|
||||||
|
if self._show_cloud_printers:
|
||||||
self.addItem(stack)
|
self.addItem(stack)
|
||||||
# Remove this machine from the other stack list
|
# Remove this machine from the other stack list
|
||||||
other_machine_stacks.remove(stack)
|
other_machine_stacks.remove(stack)
|
||||||
|
|
|
@ -19,16 +19,44 @@ ListView
|
||||||
id: scrollBar
|
id: scrollBar
|
||||||
}
|
}
|
||||||
|
|
||||||
section.delegate: UM.Label
|
section.delegate: Item
|
||||||
{
|
{
|
||||||
text: section == "true" ? catalog.i18nc("@label", "Connected printers") : catalog.i18nc("@label", "Other printers")
|
|
||||||
width: parent.width - scrollBar.width
|
width: parent.width - scrollBar.width
|
||||||
|
height: childrenRect.height
|
||||||
|
|
||||||
|
UM.Label
|
||||||
|
{
|
||||||
|
visible: section == "true"
|
||||||
|
text: catalog.i18nc("@label", "Connected printers")
|
||||||
height: UM.Theme.getSize("action_button").height
|
height: UM.Theme.getSize("action_button").height
|
||||||
leftPadding: UM.Theme.getSize("default_margin").width
|
leftPadding: UM.Theme.getSize("default_margin").width
|
||||||
font: UM.Theme.getFont("medium")
|
font: UM.Theme.getFont("medium")
|
||||||
color: UM.Theme.getColor("text_medium")
|
color: UM.Theme.getColor("text_medium")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Column
|
||||||
|
{
|
||||||
|
visible: section != "true"
|
||||||
|
height: childrenRect.height
|
||||||
|
|
||||||
|
Cura.TertiaryButton
|
||||||
|
{
|
||||||
|
text: listView.model.showCloudPrinters ? catalog.i18nc("@label", "Hide all connected printers") : catalog.i18nc("@label", "Show all connected printers")
|
||||||
|
onClicked: listView.model.setShowCloudPrinters(!listView.model.showCloudPrinters)
|
||||||
|
iconSource: listView.model.showCloudPrinters ? UM.Theme.getIcon("ChevronSingleUp") : UM.Theme.getIcon("ChevronSingleDown")
|
||||||
|
}
|
||||||
|
|
||||||
|
UM.Label
|
||||||
|
{
|
||||||
|
text: catalog.i18nc("@label", "Other printers")
|
||||||
|
height: UM.Theme.getSize("action_button").height
|
||||||
|
leftPadding: UM.Theme.getSize("default_margin").width
|
||||||
|
font: UM.Theme.getFont("medium")
|
||||||
|
color: UM.Theme.getColor("text_medium")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
delegate: MachineListButton
|
delegate: MachineListButton
|
||||||
{
|
{
|
||||||
text: model.name ? model.name : ""
|
text: model.name ? model.name : ""
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue