From ac732e960483b74d7e62dc919f49ab3b6c708286 Mon Sep 17 00:00:00 2001 From: "c.lamboo" Date: Tue, 30 Aug 2022 23:15:54 +0200 Subject: [PATCH 01/10] Add button to hide/show connected printers CURA-9514 --- cura/Machines/Models/MachineListModel.py | 19 ++++++++- .../PrinterSelector/MachineSelectorList.qml | 40 ++++++++++++++++--- 2 files changed, 51 insertions(+), 8 deletions(-) diff --git a/cura/Machines/Models/MachineListModel.py b/cura/Machines/Models/MachineListModel.py index 6814600307..9b1ffd16c6 100644 --- a/cura/Machines/Models/MachineListModel.py +++ b/cura/Machines/Models/MachineListModel.py @@ -5,7 +5,7 @@ # online cloud connected printers are represented within this ListModel. Additional information such as the number of # 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.Settings.ContainerStack import ContainerStack @@ -29,6 +29,8 @@ class MachineListModel(ListModel): def __init__(self, parent=None) -> None: super().__init__(parent) + self._show_cloud_printers = True + self._catalog = i18nCatalog("cura") self.addRoleName(self.NameRole, "name") @@ -50,6 +52,18 @@ class MachineListModel(ListModel): CuraContainerRegistry.getInstance().containerRemoved.connect(self._onContainerChanged) 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: """Handler for container added/removed events from registry""" @@ -80,7 +94,8 @@ class MachineListModel(ListModel): # Create list of machines that are children of the abstract machine for stack in online_machine_stacks: - self.addItem(stack) + if self._show_cloud_printers: + self.addItem(stack) # Remove this machine from the other stack list other_machine_stacks.remove(stack) diff --git a/resources/qml/PrinterSelector/MachineSelectorList.qml b/resources/qml/PrinterSelector/MachineSelectorList.qml index 06c2fdb40c..6c5124969a 100644 --- a/resources/qml/PrinterSelector/MachineSelectorList.qml +++ b/resources/qml/PrinterSelector/MachineSelectorList.qml @@ -19,14 +19,42 @@ ListView 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 - 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") + height: childrenRect.height + + UM.Label + { + visible: section == "true" + text: catalog.i18nc("@label", "Connected 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") + } + + 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 From 60b12b9247676de84248d35a1db81a3d45b75a07 Mon Sep 17 00:00:00 2001 From: "c.lamboo" Date: Wed, 31 Aug 2022 07:58:05 +0200 Subject: [PATCH 02/10] Use list model to display show hide buttons CURA-9514 --- cura/Machines/Models/MachineListModel.py | 16 +- .../qml/PrinterSelector/MachineListButton.qml | 189 +++++++++++------- .../PrinterSelector/MachineSelectorList.qml | 58 ++---- 3 files changed, 156 insertions(+), 107 deletions(-) diff --git a/cura/Machines/Models/MachineListModel.py b/cura/Machines/Models/MachineListModel.py index 9b1ffd16c6..2225e014e8 100644 --- a/cura/Machines/Models/MachineListModel.py +++ b/cura/Machines/Models/MachineListModel.py @@ -25,6 +25,7 @@ class MachineListModel(ListModel): IsOnlineRole = Qt.ItemDataRole.UserRole + 5 MachineCountRole = Qt.ItemDataRole.UserRole + 6 IsAbstractMachine = Qt.ItemDataRole.UserRole + 7 + ListTypeRole = Qt.ItemDataRole.UserRole + 8 def __init__(self, parent=None) -> None: super().__init__(parent) @@ -40,6 +41,7 @@ class MachineListModel(ListModel): self.addRoleName(self.IsOnlineRole, "isOnline") self.addRoleName(self.MachineCountRole, "machineCount") self.addRoleName(self.IsAbstractMachine, "isAbstractMachine") + self.addRoleName(self.ListTypeRole, "listType") self._change_timer = QTimer() self._change_timer.setInterval(200) @@ -99,6 +101,16 @@ class MachineListModel(ListModel): # Remove this machine from the other stack list other_machine_stacks.remove(stack) + if len(abstract_machine_stacks) > 0: + if self._show_cloud_printers: + self.appendItem({ "listType": "HIDE_BUTTON", + "isOnline": True, + }) + else: + self.appendItem({ "listType": "SHOW_BUTTON", + "isOnline": True, + }) + for stack in other_machine_stacks: self.addItem(stack) @@ -113,7 +125,9 @@ class MachineListModel(ListModel): for connection_type in [ConnectionType.NetworkConnection.value, ConnectionType.CloudConnection.value]: has_connection |= connection_type in container_stack.configuredConnectionTypes - self.appendItem({"name": container_stack.getName(), + self.appendItem({ + "listType": "MACHINE", + "name": container_stack.getName(), "id": container_stack.getId(), "metadata": container_stack.getMetaData().copy(), "isOnline": parseBool(container_stack.getMetaDataEntry("is_online", False)) and has_connection, diff --git a/resources/qml/PrinterSelector/MachineListButton.qml b/resources/qml/PrinterSelector/MachineListButton.qml index 55ae5497d9..039c9c054b 100644 --- a/resources/qml/PrinterSelector/MachineListButton.qml +++ b/resources/qml/PrinterSelector/MachineListButton.qml @@ -7,81 +7,134 @@ import QtQuick.Controls 2.3 import UM 1.5 as UM import Cura 1.0 as Cura - -Button -{ - id: machineListButton - +Loader { + id: loader width: parent.width - height: UM.Theme.getSize("large_button").height - leftPadding: UM.Theme.getSize("default_margin").width - rightPadding: UM.Theme.getSize("default_margin").width - checkable: true - hoverEnabled: true + height: childrenRect.height + sourceComponent: { + switch (model.listType) { + case "HIDE_BUTTON": + hideButtonComponent + break; + case "SHOW_BUTTON": + showButtonComponent + break; + case "MACHINE": + machineListButtonComponent + break; + default: + } + } + property var onClicked - contentItem: Item + Component { - width: machineListButton.width - machineListButton.leftPadding - machineListButton.rightPadding - height: UM.Theme.getSize("action_button").height - - UM.ColorImage + id: hideButtonComponent + Cura.TertiaryButton { - id: printerIcon - height: UM.Theme.getSize("medium_button").height - width: UM.Theme.getSize("medium_button").width - color: UM.Theme.getColor("machine_selector_printer_icon") - visible: model.isAbstractMachine || !model.isOnline - source: model.isAbstractMachine ? UM.Theme.getIcon("PrinterTriple", "medium") : UM.Theme.getIcon("Printer", "medium") - - anchors - { - left: parent.left - verticalCenter: parent.verticalCenter - } - } - - UM.Label - { - id: buttonText - anchors - { - left: printerIcon.right - right: printerCount.left - verticalCenter: parent.verticalCenter - leftMargin: UM.Theme.getSize("default_margin").width - } - text: machineListButton.text - font: model.isAbstractMachine ? UM.Theme.getFont("medium_bold") : UM.Theme.getFont("medium") - visible: text != "" - elide: Text.ElideRight - } - - Rectangle - { - id: printerCount - color: UM.Theme.getColor("background_2") - radius: height - width: height - anchors - { - right: parent.right - top: buttonText.top - bottom: buttonText.bottom - } - visible: model.isAbstractMachine - - UM.Label - { - text: model.machineCount - anchors.centerIn: parent - font: UM.Theme.getFont("default_bold") - } + text: catalog.i18nc("@label", "Hide all connected printers") + height: UM.Theme.getSize("large_button").height + onClicked: if (loader.onClicked) loader.onClicked() + iconSource: UM.Theme.getIcon("ChevronSingleUp") + width: parent.width } } - background: Rectangle + Component { - id: backgroundRect - color: machineListButton.hovered ? UM.Theme.getColor("action_button_hovered") : "transparent" + id: showButtonComponent + Cura.TertiaryButton + { + text: catalog.i18nc("@label", "Show all connected printers") + height: UM.Theme.getSize("large_button").height + onClicked: if (loader.onClicked) loader.onClicked() + iconSource: UM.Theme.getIcon("ChevronSingleDown") + width: parent.width + } + } + + Component + { + id: machineListButtonComponent + + Button + { + id: machineListButton + + onClicked: if (loader.onClicked) loader.onClicked() + + width: parent.width + height: UM.Theme.getSize("large_button").height + leftPadding: UM.Theme.getSize("default_margin").width + rightPadding: UM.Theme.getSize("default_margin").width + checkable: true + hoverEnabled: true + + contentItem: Item + { + width: machineListButton.width - machineListButton.leftPadding - machineListButton.rightPadding + height: UM.Theme.getSize("action_button").height + + UM.ColorImage + { + id: printerIcon + height: UM.Theme.getSize("medium_button").height + width: UM.Theme.getSize("medium_button").width + color: UM.Theme.getColor("machine_selector_printer_icon") + visible: model.isAbstractMachine || !model.isOnline + source: model.isAbstractMachine ? UM.Theme.getIcon("PrinterTriple", "medium") : UM.Theme.getIcon("Printer", "medium") + + anchors + { + left: parent.left + verticalCenter: parent.verticalCenter + } + } + + UM.Label + { + id: buttonText + anchors + { + left: printerIcon.right + right: printerCount.left + verticalCenter: parent.verticalCenter + leftMargin: UM.Theme.getSize("default_margin").width + } + text: model.name ? model.name : "" + font: model.isAbstractMachine ? UM.Theme.getFont("medium_bold") : UM.Theme.getFont("medium") + visible: text != "" + elide: Text.ElideRight + } + + Rectangle + { + id: printerCount + color: UM.Theme.getColor("background_2") + radius: height + width: height + anchors + { + right: parent.right + top: buttonText.top + bottom: buttonText.bottom + } + visible: model.isAbstractMachine + + UM.Label + { + text: model.machineCount + anchors.centerIn: parent + font: UM.Theme.getFont("default_bold") + } + } + } + + background: Rectangle + { + id: backgroundRect + color: machineListButton.hovered ? UM.Theme.getColor("action_button_hovered") : "transparent" + } + } } } diff --git a/resources/qml/PrinterSelector/MachineSelectorList.qml b/resources/qml/PrinterSelector/MachineSelectorList.qml index 6c5124969a..d4a4c4a5ce 100644 --- a/resources/qml/PrinterSelector/MachineSelectorList.qml +++ b/resources/qml/PrinterSelector/MachineSelectorList.qml @@ -19,53 +19,35 @@ ListView id: scrollBar } - section.delegate: Item + section.delegate: UM.Label { + text: section == "true" ? catalog.i18nc("@label", "Connected printers") : catalog.i18nc("@label", "Other printers") + height: UM.Theme.getSize("action_button").height 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 - leftPadding: UM.Theme.getSize("default_margin").width - font: UM.Theme.getFont("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") - } - } + leftPadding: UM.Theme.getSize("default_margin").width + font: UM.Theme.getFont("medium") + color: UM.Theme.getColor("text_medium") } delegate: MachineListButton { - text: model.name ? model.name : "" width: listView.width - scrollBar.width - onClicked: + onClicked: function() { - toggleContent() - Cura.MachineManager.setActiveMachine(model.id) + switch (model.listType) { + case "HIDE_BUTTON": + listView.model.setShowCloudPrinters(false); + break; + case "SHOW_BUTTON": + listView.model.setShowCloudPrinters(true); + break; + case "MACHINE": + toggleContent() + Cura.MachineManager.setActiveMachine(model.id) + break; + default: + } } } } From aa1c09591f3e7d7c696f9dc3f809f66a6a90262d Mon Sep 17 00:00:00 2001 From: "c.lamboo" Date: Wed, 31 Aug 2022 08:15:13 +0200 Subject: [PATCH 03/10] Typo CURA-9514 --- cura/Machines/Models/MachineListModel.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cura/Machines/Models/MachineListModel.py b/cura/Machines/Models/MachineListModel.py index 2225e014e8..8637801657 100644 --- a/cura/Machines/Models/MachineListModel.py +++ b/cura/Machines/Models/MachineListModel.py @@ -54,9 +54,9 @@ class MachineListModel(ListModel): CuraContainerRegistry.getInstance().containerRemoved.connect(self._onContainerChanged) self._updateDelayed() - showCloutPrintersChanged = pyqtSignal(bool) + showCloudPrintersChanged = pyqtSignal(bool) - @pyqtProperty(bool, notify=showCloutPrintersChanged) + @pyqtProperty(bool, notify=showCloudPrintersChanged) def showCloudPrinters(self) -> bool: return self._show_cloud_printers @@ -64,7 +64,7 @@ class MachineListModel(ListModel): 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) + self.showCloudPrintersChanged.emit(show_cloud_printers) def _onContainerChanged(self, container) -> None: """Handler for container added/removed events from registry""" From daab1aae713fb4d060512fa72f37d3714b2c7e36 Mon Sep 17 00:00:00 2001 From: joeydelarago Date: Wed, 31 Aug 2022 10:05:41 +0200 Subject: [PATCH 04/10] QML was attempting to fetch variables that were emtpy. Using self.clear() properly removed unused items when the list is resized to be smaller. Also add some dummy variables inside cloud printer expand and contract buttons. CURA-9514 --- cura/Machines/Models/MachineListModel.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/cura/Machines/Models/MachineListModel.py b/cura/Machines/Models/MachineListModel.py index 8637801657..66def23a32 100644 --- a/cura/Machines/Models/MachineListModel.py +++ b/cura/Machines/Models/MachineListModel.py @@ -77,7 +77,7 @@ class MachineListModel(ListModel): self._change_timer.start() def _update(self) -> None: - self.setItems([]) # Clear items + self.clear() other_machine_stacks = CuraContainerRegistry.getInstance().findContainerStacks(type="machine") @@ -105,14 +105,19 @@ class MachineListModel(ListModel): if self._show_cloud_printers: self.appendItem({ "listType": "HIDE_BUTTON", "isOnline": True, + "isAbstractMachine": False, + "machineCount": 0 }) else: - self.appendItem({ "listType": "SHOW_BUTTON", + self.appendItem({"listType": "SHOW_BUTTON", "isOnline": True, + "isAbstractMachine": False, + "machineCount": 0 }) for stack in other_machine_stacks: self.addItem(stack) + print(self.items) def addItem(self, container_stack: ContainerStack, machine_count: int = 0) -> None: if parseBool(container_stack.getMetaDataEntry("hidden", False)): From 760e53c401e7fc9af2536a5ccd1c41a7af4566a2 Mon Sep 17 00:00:00 2001 From: joeydelarago Date: Wed, 31 Aug 2022 10:19:02 +0200 Subject: [PATCH 05/10] Fix indentation Remove debug statement CURA-9514 --- cura/Machines/Models/MachineListModel.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/cura/Machines/Models/MachineListModel.py b/cura/Machines/Models/MachineListModel.py index 66def23a32..82272ca39b 100644 --- a/cura/Machines/Models/MachineListModel.py +++ b/cura/Machines/Models/MachineListModel.py @@ -103,21 +103,20 @@ class MachineListModel(ListModel): if len(abstract_machine_stacks) > 0: if self._show_cloud_printers: - self.appendItem({ "listType": "HIDE_BUTTON", - "isOnline": True, - "isAbstractMachine": False, - "machineCount": 0 + self.appendItem({"listType": "HIDE_BUTTON", + "isOnline": True, + "isAbstractMachine": False, + "machineCount": 0 }) else: self.appendItem({"listType": "SHOW_BUTTON", - "isOnline": True, - "isAbstractMachine": False, - "machineCount": 0 + "isOnline": True, + "isAbstractMachine": False, + "machineCount": 0 }) for stack in other_machine_stacks: self.addItem(stack) - print(self.items) def addItem(self, container_stack: ContainerStack, machine_count: int = 0) -> None: if parseBool(container_stack.getMetaDataEntry("hidden", False)): From 9f204f2e43f8a546d417f173b12536cb5ac10f2f Mon Sep 17 00:00:00 2001 From: joeydelarago Date: Wed, 31 Aug 2022 10:20:50 +0200 Subject: [PATCH 06/10] Update isAbstractMachine to match Role name format. CURA-9514 --- cura/Machines/Models/MachineListModel.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cura/Machines/Models/MachineListModel.py b/cura/Machines/Models/MachineListModel.py index 82272ca39b..5f222c82e8 100644 --- a/cura/Machines/Models/MachineListModel.py +++ b/cura/Machines/Models/MachineListModel.py @@ -24,7 +24,7 @@ class MachineListModel(ListModel): MetaDataRole = Qt.ItemDataRole.UserRole + 4 IsOnlineRole = Qt.ItemDataRole.UserRole + 5 MachineCountRole = Qt.ItemDataRole.UserRole + 6 - IsAbstractMachine = Qt.ItemDataRole.UserRole + 7 + IsAbstractMachineRole = Qt.ItemDataRole.UserRole + 7 ListTypeRole = Qt.ItemDataRole.UserRole + 8 def __init__(self, parent=None) -> None: @@ -40,7 +40,7 @@ class MachineListModel(ListModel): self.addRoleName(self.MetaDataRole, "metadata") self.addRoleName(self.IsOnlineRole, "isOnline") self.addRoleName(self.MachineCountRole, "machineCount") - self.addRoleName(self.IsAbstractMachine, "isAbstractMachine") + self.addRoleName(self.IsAbstractMachineRole, "isAbstractMachine") self.addRoleName(self.ListTypeRole, "listType") self._change_timer = QTimer() From 2ff0aed171ba02b603416dcde7d9bb11c96955b5 Mon Sep 17 00:00:00 2001 From: joeydelarago Date: Wed, 31 Aug 2022 10:26:23 +0200 Subject: [PATCH 07/10] Remove height binding loop. CURA-9514 --- resources/qml/PrinterSelector/MachineListButton.qml | 1 - 1 file changed, 1 deletion(-) diff --git a/resources/qml/PrinterSelector/MachineListButton.qml b/resources/qml/PrinterSelector/MachineListButton.qml index 039c9c054b..f492e87574 100644 --- a/resources/qml/PrinterSelector/MachineListButton.qml +++ b/resources/qml/PrinterSelector/MachineListButton.qml @@ -10,7 +10,6 @@ import Cura 1.0 as Cura Loader { id: loader width: parent.width - height: childrenRect.height sourceComponent: { switch (model.listType) { case "HIDE_BUTTON": From b999a88b26f27683c685236ec565a5c8cdb1f8d1 Mon Sep 17 00:00:00 2001 From: joeydelarago Date: Wed, 31 Aug 2022 10:26:57 +0200 Subject: [PATCH 08/10] Update function name to match code style CURA-9514 --- cura/Machines/Models/MachineListModel.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cura/Machines/Models/MachineListModel.py b/cura/Machines/Models/MachineListModel.py index 5f222c82e8..10bc2d13c9 100644 --- a/cura/Machines/Models/MachineListModel.py +++ b/cura/Machines/Models/MachineListModel.py @@ -61,7 +61,7 @@ class MachineListModel(ListModel): return self._show_cloud_printers @pyqtSlot(bool, name="setShowCloudPrinters") - def set_show_cloud_printers(self, show_cloud_printers: bool) -> None: + def setShowCloudPrinters(self, show_cloud_printers: bool) -> None: self._show_cloud_printers = show_cloud_printers self._updateDelayed() self.showCloudPrintersChanged.emit(show_cloud_printers) From 19835844bfb44278afa9683c06c1f9401a1513af Mon Sep 17 00:00:00 2001 From: joeydelarago Date: Wed, 31 Aug 2022 10:50:20 +0200 Subject: [PATCH 09/10] Change listType -> componentType. Makes it a bit more clear that this variable decides which component should be used for the model. CURA-9514 --- cura/Machines/Models/MachineListModel.py | 10 +++++----- resources/qml/PrinterSelector/MachineListButton.qml | 2 +- resources/qml/PrinterSelector/MachineSelectorList.qml | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/cura/Machines/Models/MachineListModel.py b/cura/Machines/Models/MachineListModel.py index 10bc2d13c9..a429418e09 100644 --- a/cura/Machines/Models/MachineListModel.py +++ b/cura/Machines/Models/MachineListModel.py @@ -25,7 +25,7 @@ class MachineListModel(ListModel): IsOnlineRole = Qt.ItemDataRole.UserRole + 5 MachineCountRole = Qt.ItemDataRole.UserRole + 6 IsAbstractMachineRole = Qt.ItemDataRole.UserRole + 7 - ListTypeRole = Qt.ItemDataRole.UserRole + 8 + ComponentTypeRole = Qt.ItemDataRole.UserRole + 8 def __init__(self, parent=None) -> None: super().__init__(parent) @@ -41,7 +41,7 @@ class MachineListModel(ListModel): self.addRoleName(self.IsOnlineRole, "isOnline") self.addRoleName(self.MachineCountRole, "machineCount") self.addRoleName(self.IsAbstractMachineRole, "isAbstractMachine") - self.addRoleName(self.ListTypeRole, "listType") + self.addRoleName(self.ComponentTypeRole, "componentType") self._change_timer = QTimer() self._change_timer.setInterval(200) @@ -103,13 +103,13 @@ class MachineListModel(ListModel): if len(abstract_machine_stacks) > 0: if self._show_cloud_printers: - self.appendItem({"listType": "HIDE_BUTTON", + self.appendItem({"componentType": "HIDE_BUTTON", "isOnline": True, "isAbstractMachine": False, "machineCount": 0 }) else: - self.appendItem({"listType": "SHOW_BUTTON", + self.appendItem({"componentType": "SHOW_BUTTON", "isOnline": True, "isAbstractMachine": False, "machineCount": 0 @@ -130,7 +130,7 @@ class MachineListModel(ListModel): has_connection |= connection_type in container_stack.configuredConnectionTypes self.appendItem({ - "listType": "MACHINE", + "componentType": "MACHINE", "name": container_stack.getName(), "id": container_stack.getId(), "metadata": container_stack.getMetaData().copy(), diff --git a/resources/qml/PrinterSelector/MachineListButton.qml b/resources/qml/PrinterSelector/MachineListButton.qml index f492e87574..b158cb20c0 100644 --- a/resources/qml/PrinterSelector/MachineListButton.qml +++ b/resources/qml/PrinterSelector/MachineListButton.qml @@ -11,7 +11,7 @@ Loader { id: loader width: parent.width sourceComponent: { - switch (model.listType) { + switch (model.componentType) { case "HIDE_BUTTON": hideButtonComponent break; diff --git a/resources/qml/PrinterSelector/MachineSelectorList.qml b/resources/qml/PrinterSelector/MachineSelectorList.qml index d4a4c4a5ce..a328ae69d9 100644 --- a/resources/qml/PrinterSelector/MachineSelectorList.qml +++ b/resources/qml/PrinterSelector/MachineSelectorList.qml @@ -35,7 +35,7 @@ ListView onClicked: function() { - switch (model.listType) { + switch (model.componentType) { case "HIDE_BUTTON": listView.model.setShowCloudPrinters(false); break; From dccffdeca3cf6c1913224d0a8977e1ed232d3f65 Mon Sep 17 00:00:00 2001 From: Casper Lamboo Date: Wed, 31 Aug 2022 11:08:37 +0200 Subject: [PATCH 10/10] Update cura/Machines/Models/MachineListModel.py --- cura/Machines/Models/MachineListModel.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cura/Machines/Models/MachineListModel.py b/cura/Machines/Models/MachineListModel.py index a429418e09..40d8e47615 100644 --- a/cura/Machines/Models/MachineListModel.py +++ b/cura/Machines/Models/MachineListModel.py @@ -60,7 +60,7 @@ class MachineListModel(ListModel): def showCloudPrinters(self) -> bool: return self._show_cloud_printers - @pyqtSlot(bool, name="setShowCloudPrinters") + @pyqtSlot(bool) def setShowCloudPrinters(self, show_cloud_printers: bool) -> None: self._show_cloud_printers = show_cloud_printers self._updateDelayed()