diff options
author | Ghostkeeper <rubend@tutanota.com> | 2021-10-08 15:21:03 +0300 |
---|---|---|
committer | Ghostkeeper <rubend@tutanota.com> | 2021-10-08 15:21:03 +0300 |
commit | 07b2c1b7775d9147703b709f48c3ba274f9fc18e (patch) | |
tree | 9d66b90dfbd49bdcaaec7a029daefe8d20238397 /cura/Machines | |
parent | 82342762049fadc812dfb89331055af219cabc76 (diff) |
Add option to only show printers that are online
I have a feeling this will be abused later. But fine. We currently need it for the list of printers that we can sync materials to via the cloud.
Contributes to issue CURA-8609.
Diffstat (limited to 'cura/Machines')
-rw-r--r-- | cura/Machines/Models/GlobalStacksModel.py | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/cura/Machines/Models/GlobalStacksModel.py b/cura/Machines/Models/GlobalStacksModel.py index 82ed03e935..0f01df6b28 100644 --- a/cura/Machines/Models/GlobalStacksModel.py +++ b/cura/Machines/Models/GlobalStacksModel.py @@ -40,6 +40,7 @@ class GlobalStacksModel(ListModel): self._change_timer.timeout.connect(self._update) self._filter_connection_type = -1 + self._filter_online_only = False # Listen to changes CuraContainerRegistry.getInstance().containerAdded.connect(self._onContainerChanged) @@ -48,7 +49,6 @@ class GlobalStacksModel(ListModel): self._updateDelayed() filterConnectionTypeChanged = pyqtSignal() - def setFilterConnectionType(self, new_filter: int) -> None: self._filter_connection_type = new_filter @@ -62,6 +62,17 @@ class GlobalStacksModel(ListModel): """ return self._filter_connection_type + filterOnlineOnlyChanged = pyqtSignal() + def setFilterOnlineOnly(self, new_filter: bool) -> None: + self._filter_online_only = new_filter + + @pyqtProperty(bool, fset = setFilterOnlineOnly, notify = filterOnlineOnlyChanged) + def filterOnlineOnly(self) -> bool: + """ + Whether to filter the global stacks to show only printers that are online. + """ + return self._filter_online_only + def _onContainerChanged(self, container) -> None: """Handler for container added/removed events from registry""" @@ -90,10 +101,13 @@ class GlobalStacksModel(ListModel): if parseBool(container_stack.getMetaDataEntry("hidden", False)): continue + is_online = container_stack.getMetaDataEntry("is_online", False) + if self._filter_online_only and not is_online: + continue + device_name = container_stack.getMetaDataEntry("group_name", container_stack.getName()) section_name = "Connected printers" if has_remote_connection else "Preset printers" section_name = self._catalog.i18nc("@info:title", section_name) - is_online = container_stack.getMetaDataEntry("is_online", False) default_removal_warning = self._catalog.i18nc( "@label {0} is the name of a printer that's about to be deleted.", |