mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-14 18:27:51 -06:00
Add isOnline role to GlobalStacksModel
This way we can filter for only online printers or display whether printers are online or not in the future. Contributes to issue CURA-8609.
This commit is contained in:
parent
93953630ec
commit
32c63c2757
2 changed files with 6 additions and 2 deletions
|
@ -20,6 +20,7 @@ class GlobalStacksModel(ListModel):
|
||||||
MetaDataRole = Qt.UserRole + 5
|
MetaDataRole = Qt.UserRole + 5
|
||||||
DiscoverySourceRole = Qt.UserRole + 6 # For separating local and remote printers in the machine management page
|
DiscoverySourceRole = Qt.UserRole + 6 # For separating local and remote printers in the machine management page
|
||||||
RemovalWarningRole = Qt.UserRole + 7
|
RemovalWarningRole = Qt.UserRole + 7
|
||||||
|
IsOnlineRole = Qt.UserRole + 8
|
||||||
|
|
||||||
def __init__(self, parent = None) -> None:
|
def __init__(self, parent = None) -> None:
|
||||||
super().__init__(parent)
|
super().__init__(parent)
|
||||||
|
@ -31,6 +32,7 @@ class GlobalStacksModel(ListModel):
|
||||||
self.addRoleName(self.HasRemoteConnectionRole, "hasRemoteConnection")
|
self.addRoleName(self.HasRemoteConnectionRole, "hasRemoteConnection")
|
||||||
self.addRoleName(self.MetaDataRole, "metadata")
|
self.addRoleName(self.MetaDataRole, "metadata")
|
||||||
self.addRoleName(self.DiscoverySourceRole, "discoverySource")
|
self.addRoleName(self.DiscoverySourceRole, "discoverySource")
|
||||||
|
self.addRoleName(self.IsOnlineRole, "isOnline")
|
||||||
|
|
||||||
self._change_timer = QTimer()
|
self._change_timer = QTimer()
|
||||||
self._change_timer.setInterval(200)
|
self._change_timer.setInterval(200)
|
||||||
|
@ -91,6 +93,7 @@ class GlobalStacksModel(ListModel):
|
||||||
device_name = container_stack.getMetaDataEntry("group_name", container_stack.getName())
|
device_name = container_stack.getMetaDataEntry("group_name", container_stack.getName())
|
||||||
section_name = "Connected printers" if has_remote_connection else "Preset printers"
|
section_name = "Connected printers" if has_remote_connection else "Preset printers"
|
||||||
section_name = self._catalog.i18nc("@info:title", section_name)
|
section_name = self._catalog.i18nc("@info:title", section_name)
|
||||||
|
is_online = container_stack.getMetaDataEntry("is_online", False)
|
||||||
|
|
||||||
default_removal_warning = self._catalog.i18nc(
|
default_removal_warning = self._catalog.i18nc(
|
||||||
"@label {0} is the name of a printer that's about to be deleted.",
|
"@label {0} is the name of a printer that's about to be deleted.",
|
||||||
|
@ -103,6 +106,7 @@ class GlobalStacksModel(ListModel):
|
||||||
"hasRemoteConnection": has_remote_connection,
|
"hasRemoteConnection": has_remote_connection,
|
||||||
"metadata": container_stack.getMetaData().copy(),
|
"metadata": container_stack.getMetaData().copy(),
|
||||||
"discoverySource": section_name,
|
"discoverySource": section_name,
|
||||||
"removalWarning": removal_warning})
|
"removalWarning": removal_warning,
|
||||||
|
"isOnline": is_online})
|
||||||
items.sort(key=lambda i: (not i["hasRemoteConnection"], i["name"]))
|
items.sort(key=lambda i: (not i["hasRemoteConnection"], i["name"]))
|
||||||
self.setItems(items)
|
self.setItems(items)
|
||||||
|
|
|
@ -247,7 +247,7 @@ Window
|
||||||
}
|
}
|
||||||
|
|
||||||
source: UM.Theme.getIcon("CloudBadge", "low")
|
source: UM.Theme.getIcon("CloudBadge", "low")
|
||||||
color: "red" //TODO: connectionStatus == "printer_cloud_not_available" ? UM.Theme.getColor("cloud_unavailable") : UM.Theme.getColor("primary")
|
color: model.isOnline ? UM.Theme.getColor("primary") : UM.Theme.getColor("cloud_unavailable")
|
||||||
|
|
||||||
//Make a themeable circle in the background so we can change it in other themes.
|
//Make a themeable circle in the background so we can change it in other themes.
|
||||||
Rectangle
|
Rectangle
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue