From 70f7f68a517dfaa2878cf5ae6e0f76b027eebf3f Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Thu, 17 Nov 2022 13:01:20 +0100 Subject: [PATCH 1/7] Color icons in workspace dialog so they are themed correctly in dark mode. Don't show name when defaulting to create new printer. CURA-9424 --- plugins/3MFReader/WorkspaceDialog.qml | 2 +- plugins/3MFReader/WorkspaceSection.qml | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/3MFReader/WorkspaceDialog.qml b/plugins/3MFReader/WorkspaceDialog.qml index 221696a571..c0128ab4de 100644 --- a/plugins/3MFReader/WorkspaceDialog.qml +++ b/plugins/3MFReader/WorkspaceDialog.qml @@ -96,7 +96,7 @@ UM.Dialog WorkspaceRow { leftLabelText: catalog.i18nc("@action:label", manager.isPrinterGroup ? "Printer Group" : "Printer Name") - rightLabelText: manager.machineName + rightLabelText: manager.machineName == "Create new" ? "" : manager.machineName } } diff --git a/plugins/3MFReader/WorkspaceSection.qml b/plugins/3MFReader/WorkspaceSection.qml index 6eb8f50bdf..0c94ab5d6a 100644 --- a/plugins/3MFReader/WorkspaceSection.qml +++ b/plugins/3MFReader/WorkspaceSection.qml @@ -36,6 +36,7 @@ Item anchors.verticalCenter: parent.verticalCenter source: "" height: UM.Theme.getSize("medium_button_icon").height + color: UM.Theme.getColor("text") width: height } UM.Label @@ -95,6 +96,7 @@ Item visible: comboboxTooltipText != "" source: UM.Theme.getIcon("Help") + color: UM.Theme.getColor("text") UM.ToolTip { From da71983891cc6756da85ef757d3fdd1a949d9b48 Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Thu, 17 Nov 2022 14:41:14 +0100 Subject: [PATCH 2/7] Make combobox font and padding customizable. Style WorkspaceDialog comboboxes similar to MachineSelector CURA-9424 --- plugins/3MFReader/WorkspaceDialog.qml | 22 ++++++++++++++++++++++ resources/qml/RoundedRectangle.qml | 1 + resources/qml/Widgets/ComboBox.qml | 8 ++++++-- 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/plugins/3MFReader/WorkspaceDialog.qml b/plugins/3MFReader/WorkspaceDialog.qml index c0128ab4de..cb93aec37e 100644 --- a/plugins/3MFReader/WorkspaceDialog.qml +++ b/plugins/3MFReader/WorkspaceDialog.qml @@ -195,6 +195,17 @@ UM.Dialog model: resolveStrategiesModel textRole: "label" visible: manager.qualityChangesConflict + contentLeftPadding: UM.Theme.getSize("default_margin").width + textFont: UM.Theme.getFont("medium") + + background: Cura.RoundedRectangle + { + border.width: UM.Theme.getSize("default_lining").width + border.color: UM.Theme.getColor("lining") + color: qualityChangesResolveComboBox.hovered ? UM.Theme.getColor("expandable_hover") : UM.Theme.getColor("action_button") + cornerSide: Cura.RoundedRectangle.Direction.All + radius: UM.Theme.getSize("default_radius").width + } // This is a hack. This will trigger onCurrentIndexChanged and set the index when this component in loaded currentIndex: @@ -238,6 +249,17 @@ UM.Dialog model: resolveStrategiesModel textRole: "label" visible: manager.materialConflict + contentLeftPadding: UM.Theme.getSize("default_margin").width + textFont: UM.Theme.getFont("medium") + + background: Cura.RoundedRectangle + { + border.width: UM.Theme.getSize("default_lining").width + border.color: UM.Theme.getColor("lining") + color: materialResolveComboBox.hovered ? UM.Theme.getColor("expandable_hover") : UM.Theme.getColor("action_button") + cornerSide: Cura.RoundedRectangle.Direction.All + radius: UM.Theme.getSize("default_radius").width + } // This is a hack. This will trigger onCurrentIndexChanged and set the index when this component in loaded currentIndex: diff --git a/resources/qml/RoundedRectangle.qml b/resources/qml/RoundedRectangle.qml index 3ca05e2125..86f7214654 100644 --- a/resources/qml/RoundedRectangle.qml +++ b/resources/qml/RoundedRectangle.qml @@ -1,3 +1,4 @@ + import QtQuick 2.7 import UM 1.2 as UM diff --git a/resources/qml/Widgets/ComboBox.qml b/resources/qml/Widgets/ComboBox.qml index 06ac2425bb..efe14497bc 100644 --- a/resources/qml/Widgets/ComboBox.qml +++ b/resources/qml/Widgets/ComboBox.qml @@ -20,6 +20,8 @@ ComboBox property alias textFormat: contentLabel.textFormat property alias backgroundColor: background.color property bool forceHighlight: false + property int contentLeftPadding: UM.Theme.getSize("setting_unit_margin").width + property var textFont: UM.Theme.getFont("default") enabled: delegateModel.count > 0 @@ -104,9 +106,10 @@ ComboBox contentItem: UM.Label { id: contentLabel - leftPadding: UM.Theme.getSize("setting_unit_margin").width + UM.Theme.getSize("default_margin").width + leftPadding: contentLeftPadding + UM.Theme.getSize("default_margin").width anchors.right: downArrow.left wrapMode: Text.NoWrap + font: textFont text: { if (control.delegateModel.count == 0) @@ -176,11 +179,12 @@ ComboBox id: delegateLabel // FIXME: Somehow the top/bottom anchoring is not correct on Linux and it results in invisible texts. anchors.fill: parent - anchors.leftMargin: UM.Theme.getSize("setting_unit_margin").width + anchors.leftMargin: contentLeftPadding anchors.rightMargin: UM.Theme.getSize("setting_unit_margin").width text: delegateItem.text textFormat: control.textFormat + font: textFont color: UM.Theme.getColor("setting_control_text") elide: Text.ElideRight wrapMode: Text.NoWrap From 4d2f6b9655dd4cecf9eef0f1f808b05e3b500d28 Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Thu, 17 Nov 2022 16:21:57 +0100 Subject: [PATCH 3/7] Previously there would always be one item in the updateableMachinesModel ("Create new"). This was moved to a button instead of being part of the model. This fixes new machines being incorrectly created when a machine already exists. CURA-9424 --- plugins/3MFReader/ThreeMFWorkspaceReader.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/3MFReader/ThreeMFWorkspaceReader.py b/plugins/3MFReader/ThreeMFWorkspaceReader.py index 20bb7c8e2e..de3274efff 100755 --- a/plugins/3MFReader/ThreeMFWorkspaceReader.py +++ b/plugins/3MFReader/ThreeMFWorkspaceReader.py @@ -616,6 +616,7 @@ class ThreeMFWorkspaceReader(WorkspaceReader): # The machine included in the project file exists locally already, no need to change selected printers. is_networked_machine = global_stack.hasNetworkedConnection() is_abstract_machine = parseBool(existing_global_stack.getMetaDataEntry("is_abstract_machine", False)) + self._dialog.setMachineToOverride(global_stack.getId()) elif self._dialog.updatableMachinesModel.count > 0: # The machine included in the project file does not exist. There is another machine of the same type. # This will always default to an abstract machine first. @@ -630,6 +631,7 @@ class ThreeMFWorkspaceReader(WorkspaceReader): machine_name = i18n_catalog.i18nc("@button", "Create new") self._dialog.setIsAbstractMachine(False) self._dialog.setIsNetworkedMachine(False) + self._dialog.setMachineToOverride(None) self._dialog.setResolveStrategy("machine", "new") self._dialog.setIsNetworkedMachine(is_networked_machine) @@ -730,7 +732,7 @@ class ThreeMFWorkspaceReader(WorkspaceReader): application.expandedCategoriesChanged.emit() # Notify the GUI of the change # If there are no machines of the same type, create a new machine. - if self._resolve_strategies["machine"] != "override" or self._dialog.updatableMachinesModel.count <= 1: + if self._resolve_strategies["machine"] != "override" or self._dialog.updatableMachinesModel.count == 0: # We need to create a new machine machine_name = self._container_registry.uniqueName(self._machine_info.name) From ff61097f13036044f407c6fd68405938697ebee0 Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Thu, 17 Nov 2022 16:37:14 +0100 Subject: [PATCH 4/7] Update resources/qml/RoundedRectangle.qml Co-authored-by: Casper Lamboo --- resources/qml/RoundedRectangle.qml | 1 - 1 file changed, 1 deletion(-) diff --git a/resources/qml/RoundedRectangle.qml b/resources/qml/RoundedRectangle.qml index 86f7214654..3ca05e2125 100644 --- a/resources/qml/RoundedRectangle.qml +++ b/resources/qml/RoundedRectangle.qml @@ -1,4 +1,3 @@ - import QtQuick 2.7 import UM 1.2 as UM From d286f50fe9428f247e4bae420a7747aa21b80029 Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Thu, 17 Nov 2022 16:39:59 +0100 Subject: [PATCH 5/7] Check for translated string CURA-9424 --- plugins/3MFReader/WorkspaceDialog.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/3MFReader/WorkspaceDialog.qml b/plugins/3MFReader/WorkspaceDialog.qml index cb93aec37e..0dfa7d4e8c 100644 --- a/plugins/3MFReader/WorkspaceDialog.qml +++ b/plugins/3MFReader/WorkspaceDialog.qml @@ -96,7 +96,7 @@ UM.Dialog WorkspaceRow { leftLabelText: catalog.i18nc("@action:label", manager.isPrinterGroup ? "Printer Group" : "Printer Name") - rightLabelText: manager.machineName == "Create new" ? "" : manager.machineName + rightLabelText: manager.machineName == catalog.i18nc("@button", "Create new") ? "" : manager.machineName } } From dd510a5dfcfbaa41e2311bdb22a860712d3bed5e Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Thu, 17 Nov 2022 16:58:16 +0100 Subject: [PATCH 6/7] Cleanup CURA-9424 --- plugins/3MFReader/ThreeMFWorkspaceReader.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/plugins/3MFReader/ThreeMFWorkspaceReader.py b/plugins/3MFReader/ThreeMFWorkspaceReader.py index de3274efff..554309d648 100755 --- a/plugins/3MFReader/ThreeMFWorkspaceReader.py +++ b/plugins/3MFReader/ThreeMFWorkspaceReader.py @@ -600,7 +600,6 @@ class ThreeMFWorkspaceReader(WorkspaceReader): self._dialog.setNumUserSettings(num_user_settings) self._dialog.setActiveMode(active_mode) self._dialog.setUpdatableMachines(updatable_machines) - self._dialog.setMachineToOverride(global_stack_id) self._dialog.setMaterialLabels(material_labels) self._dialog.setMachineType(machine_type) self._dialog.setExtruders(extruders) @@ -617,6 +616,7 @@ class ThreeMFWorkspaceReader(WorkspaceReader): is_networked_machine = global_stack.hasNetworkedConnection() is_abstract_machine = parseBool(existing_global_stack.getMetaDataEntry("is_abstract_machine", False)) self._dialog.setMachineToOverride(global_stack.getId()) + self._dialog.setResolveStrategy("machine", "override") elif self._dialog.updatableMachinesModel.count > 0: # The machine included in the project file does not exist. There is another machine of the same type. # This will always default to an abstract machine first. @@ -624,13 +624,13 @@ class ThreeMFWorkspaceReader(WorkspaceReader): machine_name = machine["name"] is_networked_machine = machine["isNetworked"] is_abstract_machine = machine["isAbstractMachine"] - self._dialog.setResolveStrategy("machine", "override") self._dialog.setMachineToOverride(machine["id"]) + self._dialog.setResolveStrategy("machine", "override") else: # The machine included in the project file does not exist. There are no other printers of the same type. Default to "Create New". machine_name = i18n_catalog.i18nc("@button", "Create new") - self._dialog.setIsAbstractMachine(False) - self._dialog.setIsNetworkedMachine(False) + is_networked_machine = False + is_abstract_machine = False self._dialog.setMachineToOverride(None) self._dialog.setResolveStrategy("machine", "new") @@ -732,6 +732,7 @@ class ThreeMFWorkspaceReader(WorkspaceReader): application.expandedCategoriesChanged.emit() # Notify the GUI of the change # If there are no machines of the same type, create a new machine. + print(self._resolve_strategies) if self._resolve_strategies["machine"] != "override" or self._dialog.updatableMachinesModel.count == 0: # We need to create a new machine machine_name = self._container_registry.uniqueName(self._machine_info.name) @@ -742,6 +743,7 @@ class ThreeMFWorkspaceReader(WorkspaceReader): # the other extruders. machine_extruder_count = self._getMachineExtruderCount() # type: Optional[int] global_stack = CuraStackBuilder.createMachine(machine_name, self._machine_info.definition_id, machine_extruder_count) + print(f"Created Global Stack: {global_stack}") if global_stack: # Only switch if creating the machine was successful. extruder_stack_dict = {str(position): extruder for position, extruder in enumerate(global_stack.extruderList)} From 1d1800e440bcc726d5fecf0cfc3fa646c281f54b Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Thu, 17 Nov 2022 17:03:05 +0100 Subject: [PATCH 7/7] Remove print statements CURA-9424 --- plugins/3MFReader/ThreeMFWorkspaceReader.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/plugins/3MFReader/ThreeMFWorkspaceReader.py b/plugins/3MFReader/ThreeMFWorkspaceReader.py index 554309d648..c839c46e7c 100755 --- a/plugins/3MFReader/ThreeMFWorkspaceReader.py +++ b/plugins/3MFReader/ThreeMFWorkspaceReader.py @@ -732,7 +732,6 @@ class ThreeMFWorkspaceReader(WorkspaceReader): application.expandedCategoriesChanged.emit() # Notify the GUI of the change # If there are no machines of the same type, create a new machine. - print(self._resolve_strategies) if self._resolve_strategies["machine"] != "override" or self._dialog.updatableMachinesModel.count == 0: # We need to create a new machine machine_name = self._container_registry.uniqueName(self._machine_info.name) @@ -743,7 +742,6 @@ class ThreeMFWorkspaceReader(WorkspaceReader): # the other extruders. machine_extruder_count = self._getMachineExtruderCount() # type: Optional[int] global_stack = CuraStackBuilder.createMachine(machine_name, self._machine_info.definition_id, machine_extruder_count) - print(f"Created Global Stack: {global_stack}") if global_stack: # Only switch if creating the machine was successful. extruder_stack_dict = {str(position): extruder for position, extruder in enumerate(global_stack.extruderList)}