From d4e5a39111896a21c93d22c8e667c39fba6f421b Mon Sep 17 00:00:00 2001 From: Paul Kuiper <46715907+pkuiper-ultimaker@users.noreply.github.com> Date: Wed, 24 Aug 2022 13:18:12 +0200 Subject: [PATCH 01/15] =?UTF-8?q?Moved=20top=20layer=20(roofing)=20setting?= =?UTF-8?q?s=20out=20of=20experimental:=20=E2=80=9CTop=20surface=20Skin=20?= =?UTF-8?q?Line=20Width=E2=80=9D,=20=E2=80=9CTop=20Surface=20Skin=20Patter?= =?UTF-8?q?n=E2=80=9D,=20=E2=80=9CMonotonic=20Top=20Surface=20Order?= =?UTF-8?q?=E2=80=9D=20and=20=E2=80=9CTop=20Surface=20Skin=20Line=20Direct?= =?UTF-8?q?ions=E2=80=9D=20as=20children=20under=20=E2=80=9CTop=20Surface?= =?UTF-8?q?=20Skin=20Layer=E2=80=9C=20in=20the=20Top/Bottom=20menu.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Relates to PP-216 --- resources/definitions/fdmprinter.def.json | 112 +++++++++++----------- 1 file changed, 57 insertions(+), 55 deletions(-) diff --git a/resources/definitions/fdmprinter.def.json b/resources/definitions/fdmprinter.def.json index ce641cf032..c80283ae2e 100644 --- a/resources/definitions/fdmprinter.def.json +++ b/resources/definitions/fdmprinter.def.json @@ -1443,7 +1443,63 @@ "value": "0", "limit_to_extruder": "roofing_extruder_nr", "settable_per_mesh": true, - "enabled": "top_layers > 0" + "enabled": "top_layers > 0", + "children": { + "roofing_line_width": + { + "label": "Top Surface Skin Line Width", + "description": "Width of a single line of the areas at the top of the print.", + "unit": "mm", + "minimum_value": "0.001", + "minimum_value_warning": "0.1 + 0.4 * machine_nozzle_size", + "maximum_value_warning": "2 * machine_nozzle_size", + "default_value": 0.4, + "type": "float", + "value": "skin_line_width", + "limit_to_extruder": "roofing_extruder_nr", + "settable_per_mesh": true, + "enabled": "roofing_layer_count > 0 and top_layers > 0" + }, + "roofing_pattern": + { + "label": "Top Surface Skin Pattern", + "description": "The pattern of the top most layers.", + "type": "enum", + "options": + { + "lines": "Lines", + "concentric": "Concentric", + "zigzag": "Zig Zag" + }, + "default_value": "lines", + "value": "top_bottom_pattern", + "limit_to_extruder": "roofing_extruder_nr", + "settable_per_mesh": true, + "enabled": "roofing_layer_count > 0 and top_layers > 0" + }, + "roofing_monotonic": + { + "label": "Monotonic Top Surface Order", + "description": "Print top surface lines in an ordering that causes them to always overlap with adjacent lines in a single direction. This takes slightly more time to print, but makes flat surfaces look more consistent.", + "type": "bool", + "default_value": false, + "value": "skin_monotonic", + "enabled": "roofing_layer_count > 0 and top_layers > 0 and roofing_pattern != 'concentric'", + "limit_to_extruder": "roofing_extruder_nr", + "settable_per_mesh": true + }, + "roofing_angles": + { + "label": "Top Surface Skin Line Directions", + "description": "A list of integer line directions to use when the top surface skin layers use the lines or zig zag pattern. Elements from the list are used sequentially as the layers progress and when the end of the list is reached, it starts at the beginning again. The list items are separated by commas and the whole list is contained in square brackets. Default is an empty list which means use the traditional default angles (45 and 135 degrees).", + "type": "[int]", + "default_value": "[ ]", + "value": "skin_angles", + "enabled": "roofing_pattern != 'concentric' and roofing_layer_count > 0 and top_layers > 0", + "limit_to_extruder": "roofing_extruder_nr", + "settable_per_mesh": true + } + } }, "top_bottom_extruder_nr": { @@ -6645,60 +6701,6 @@ "default_value": "middle", "settable_per_mesh": true }, - "roofing_line_width": - { - "label": "Top Surface Skin Line Width", - "description": "Width of a single line of the areas at the top of the print.", - "unit": "mm", - "minimum_value": "0.001", - "minimum_value_warning": "0.1 + 0.4 * machine_nozzle_size", - "maximum_value_warning": "2 * machine_nozzle_size", - "default_value": 0.4, - "type": "float", - "value": "skin_line_width", - "limit_to_extruder": "roofing_extruder_nr", - "settable_per_mesh": true, - "enabled": "roofing_layer_count > 0 and top_layers > 0" - }, - "roofing_pattern": - { - "label": "Top Surface Skin Pattern", - "description": "The pattern of the top most layers.", - "type": "enum", - "options": - { - "lines": "Lines", - "concentric": "Concentric", - "zigzag": "Zig Zag" - }, - "default_value": "lines", - "value": "top_bottom_pattern", - "limit_to_extruder": "roofing_extruder_nr", - "settable_per_mesh": true, - "enabled": "roofing_layer_count > 0 and top_layers > 0" - }, - "roofing_monotonic": - { - "label": "Monotonic Top Surface Order", - "description": "Print top surface lines in an ordering that causes them to always overlap with adjacent lines in a single direction. This takes slightly more time to print, but makes flat surfaces look more consistent.", - "type": "bool", - "default_value": false, - "value": "skin_monotonic", - "enabled": "roofing_layer_count > 0 and top_layers > 0 and roofing_pattern != 'concentric'", - "limit_to_extruder": "roofing_extruder_nr", - "settable_per_mesh": true - }, - "roofing_angles": - { - "label": "Top Surface Skin Line Directions", - "description": "A list of integer line directions to use when the top surface skin layers use the lines or zig zag pattern. Elements from the list are used sequentially as the layers progress and when the end of the list is reached, it starts at the beginning again. The list items are separated by commas and the whole list is contained in square brackets. Default is an empty list which means use the traditional default angles (45 and 135 degrees).", - "type": "[int]", - "default_value": "[ ]", - "value": "skin_angles", - "enabled": "roofing_pattern != 'concentric' and roofing_layer_count > 0 and top_layers > 0", - "limit_to_extruder": "roofing_extruder_nr", - "settable_per_mesh": true - }, "infill_enable_travel_optimization": { "label": "Infill Travel Optimization", From ac732e960483b74d7e62dc919f49ab3b6c708286 Mon Sep 17 00:00:00 2001 From: "c.lamboo" Date: Tue, 30 Aug 2022 23:15:54 +0200 Subject: [PATCH 02/15] 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 03/15] 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 04/15] 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 05/15] 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 06/15] 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 07/15] 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 08/15] 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 09/15] 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 c3dd70f7c7faf8aaaaa90c9744b358e91e09c5c7 Mon Sep 17 00:00:00 2001 From: Rijk van Manen Date: Wed, 31 Aug 2022 10:37:41 +0200 Subject: [PATCH 10/15] fix incorrect spacing --- resources/definitions/fdmprinter.def.json | 104 +++++++++++----------- 1 file changed, 52 insertions(+), 52 deletions(-) diff --git a/resources/definitions/fdmprinter.def.json b/resources/definitions/fdmprinter.def.json index c80283ae2e..a55c222b48 100644 --- a/resources/definitions/fdmprinter.def.json +++ b/resources/definitions/fdmprinter.def.json @@ -1445,60 +1445,60 @@ "settable_per_mesh": true, "enabled": "top_layers > 0", "children": { - "roofing_line_width": + "roofing_line_width": + { + "label": "Top Surface Skin Line Width", + "description": "Width of a single line of the areas at the top of the print.", + "unit": "mm", + "minimum_value": "0.001", + "minimum_value_warning": "0.1 + 0.4 * machine_nozzle_size", + "maximum_value_warning": "2 * machine_nozzle_size", + "default_value": 0.4, + "type": "float", + "value": "skin_line_width", + "limit_to_extruder": "roofing_extruder_nr", + "settable_per_mesh": true, + "enabled": "roofing_layer_count > 0 and top_layers > 0" + }, + "roofing_pattern": + { + "label": "Top Surface Skin Pattern", + "description": "The pattern of the top most layers.", + "type": "enum", + "options": { - "label": "Top Surface Skin Line Width", - "description": "Width of a single line of the areas at the top of the print.", - "unit": "mm", - "minimum_value": "0.001", - "minimum_value_warning": "0.1 + 0.4 * machine_nozzle_size", - "maximum_value_warning": "2 * machine_nozzle_size", - "default_value": 0.4, - "type": "float", - "value": "skin_line_width", - "limit_to_extruder": "roofing_extruder_nr", - "settable_per_mesh": true, - "enabled": "roofing_layer_count > 0 and top_layers > 0" + "lines": "Lines", + "concentric": "Concentric", + "zigzag": "Zig Zag" }, - "roofing_pattern": - { - "label": "Top Surface Skin Pattern", - "description": "The pattern of the top most layers.", - "type": "enum", - "options": - { - "lines": "Lines", - "concentric": "Concentric", - "zigzag": "Zig Zag" - }, - "default_value": "lines", - "value": "top_bottom_pattern", - "limit_to_extruder": "roofing_extruder_nr", - "settable_per_mesh": true, - "enabled": "roofing_layer_count > 0 and top_layers > 0" - }, - "roofing_monotonic": - { - "label": "Monotonic Top Surface Order", - "description": "Print top surface lines in an ordering that causes them to always overlap with adjacent lines in a single direction. This takes slightly more time to print, but makes flat surfaces look more consistent.", - "type": "bool", - "default_value": false, - "value": "skin_monotonic", - "enabled": "roofing_layer_count > 0 and top_layers > 0 and roofing_pattern != 'concentric'", - "limit_to_extruder": "roofing_extruder_nr", - "settable_per_mesh": true - }, - "roofing_angles": - { - "label": "Top Surface Skin Line Directions", - "description": "A list of integer line directions to use when the top surface skin layers use the lines or zig zag pattern. Elements from the list are used sequentially as the layers progress and when the end of the list is reached, it starts at the beginning again. The list items are separated by commas and the whole list is contained in square brackets. Default is an empty list which means use the traditional default angles (45 and 135 degrees).", - "type": "[int]", - "default_value": "[ ]", - "value": "skin_angles", - "enabled": "roofing_pattern != 'concentric' and roofing_layer_count > 0 and top_layers > 0", - "limit_to_extruder": "roofing_extruder_nr", - "settable_per_mesh": true - } + "default_value": "lines", + "value": "top_bottom_pattern", + "limit_to_extruder": "roofing_extruder_nr", + "settable_per_mesh": true, + "enabled": "roofing_layer_count > 0 and top_layers > 0" + }, + "roofing_monotonic": + { + "label": "Monotonic Top Surface Order", + "description": "Print top surface lines in an ordering that causes them to always overlap with adjacent lines in a single direction. This takes slightly more time to print, but makes flat surfaces look more consistent.", + "type": "bool", + "default_value": false, + "value": "skin_monotonic", + "enabled": "roofing_layer_count > 0 and top_layers > 0 and roofing_pattern != 'concentric'", + "limit_to_extruder": "roofing_extruder_nr", + "settable_per_mesh": true + }, + "roofing_angles": + { + "label": "Top Surface Skin Line Directions", + "description": "A list of integer line directions to use when the top surface skin layers use the lines or zig zag pattern. Elements from the list are used sequentially as the layers progress and when the end of the list is reached, it starts at the beginning again. The list items are separated by commas and the whole list is contained in square brackets. Default is an empty list which means use the traditional default angles (45 and 135 degrees).", + "type": "[int]", + "default_value": "[ ]", + "value": "skin_angles", + "enabled": "roofing_pattern != 'concentric' and roofing_layer_count > 0 and top_layers > 0", + "limit_to_extruder": "roofing_extruder_nr", + "settable_per_mesh": true + } } }, "top_bottom_extruder_nr": From 19835844bfb44278afa9683c06c1f9401a1513af Mon Sep 17 00:00:00 2001 From: joeydelarago Date: Wed, 31 Aug 2022 10:50:20 +0200 Subject: [PATCH 11/15] 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 12/15] 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() From 9084c31ce703b2e3fbd3e7219a4771d7c726f332 Mon Sep 17 00:00:00 2001 From: digitalfrost Date: Wed, 31 Aug 2022 12:11:20 +0200 Subject: [PATCH 13/15] MachineAction.py: Use error method with Logger Use f-string and error method with Logger instead of "Old Style" string formatting. --- cura/MachineAction.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cura/MachineAction.py b/cura/MachineAction.py index 15d9ab1ca1..c38be5261f 100644 --- a/cura/MachineAction.py +++ b/cura/MachineAction.py @@ -94,7 +94,7 @@ class MachineAction(QObject, PluginObject): plugin_path = PluginRegistry.getInstance().getPluginPath(self.getPluginId()) if plugin_path is None: - Logger.log("e", "Cannot create QML view: cannot find plugin path for plugin [%s]", self.getPluginId()) + Logger.error(f"Cannot create QML view: cannot find plugin path for plugin {self.getPluginId()}") return None path = os.path.join(plugin_path, self._qml_url) @@ -106,7 +106,7 @@ class MachineAction(QObject, PluginObject): def qmlPath(self) -> "QUrl": plugin_path = PluginRegistry.getInstance().getPluginPath(self.getPluginId()) if plugin_path is None: - Logger.log("e", "Cannot create QML view: cannot find plugin path for plugin [%s]", self.getPluginId()) + Logger.error(f"Cannot create QML view: cannot find plugin path for plugin {self.getPluginId()}") return QUrl("") path = os.path.join(plugin_path, self._qml_url) return QUrl.fromLocalFile(path) From ab722eb93cb3059b07a81766a6b62821bacbdfb8 Mon Sep 17 00:00:00 2001 From: joeydelarago Date: Wed, 31 Aug 2022 13:19:12 +0200 Subject: [PATCH 14/15] Default printers should be collapsed 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 40d8e47615..a72d6ebbc9 100644 --- a/cura/Machines/Models/MachineListModel.py +++ b/cura/Machines/Models/MachineListModel.py @@ -30,7 +30,7 @@ class MachineListModel(ListModel): def __init__(self, parent=None) -> None: super().__init__(parent) - self._show_cloud_printers = True + self._show_cloud_printers = False self._catalog = i18nCatalog("cura") From ded387324985b52632cab5eaa1343e6e239fcb1c Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Wed, 31 Aug 2022 15:12:25 +0200 Subject: [PATCH 15/15] Fix abstract machines being displayed twice --- cura/Machines/Models/MachineListModel.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cura/Machines/Models/MachineListModel.py b/cura/Machines/Models/MachineListModel.py index 2dbf088088..55db072180 100644 --- a/cura/Machines/Models/MachineListModel.py +++ b/cura/Machines/Models/MachineListModel.py @@ -83,7 +83,6 @@ class MachineListModel(ListModel): abstract_machine_stacks = CuraContainerRegistry.getInstance().findContainerStacks(is_abstract_machine = "True") abstract_machine_stacks.sort(key = lambda machine: machine.getName(), reverse = True) - for abstract_machine in abstract_machine_stacks: definition_id = abstract_machine.definition.getId() from cura.CuraApplication import CuraApplication @@ -93,6 +92,8 @@ class MachineListModel(ListModel): # Create a list item for abstract machine self.addItem(abstract_machine, len(online_machine_stacks)) other_machine_stacks.remove(abstract_machine) + if abstract_machine in online_machine_stacks: + online_machine_stacks.remove(abstract_machine) # Create list of machines that are children of the abstract machine for stack in online_machine_stacks: