From a7dc1b24bc0f1b4659e4f66c182c98086a7b636d Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Thu, 24 Nov 2022 15:16:07 +0100 Subject: [PATCH 01/82] Rename RecommendedInfillDensitySelector.qml since it will now be a more generic Strength selector CURA-9793 --- .../PrintSetupSelector/Recommended/RecommendedPrintSetup.qml | 2 +- ...nfillDensitySelector.qml => RecommendedStrengthSelector.qml} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename resources/qml/PrintSetupSelector/Recommended/{RecommendedInfillDensitySelector.qml => RecommendedStrengthSelector.qml} (100%) diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedPrintSetup.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedPrintSetup.qml index 94de16141f..977d90f5e0 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedPrintSetup.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedPrintSetup.qml @@ -83,7 +83,7 @@ Item font: UM.Theme.getFont("medium") } - RecommendedInfillDensitySelector + RecommendedStrengthSelector { width: parent.width labelColumnWidth: parent.firstColumnWidth diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedInfillDensitySelector.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedStrengthSelector.qml similarity index 100% rename from resources/qml/PrintSetupSelector/Recommended/RecommendedInfillDensitySelector.qml rename to resources/qml/PrintSetupSelector/Recommended/RecommendedStrengthSelector.qml From ac2e733ea6d0b445ff669cd182a4f9e9a5dd4635 Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Thu, 24 Nov 2022 17:24:28 +0100 Subject: [PATCH 02/82] Add Section Header and Section Setting item components. Upgrade Adhesion to use new components CURA-9793 --- .../RecommendedAdhesionSelector.qml | 73 +++-------------- .../Recommended/RecommendedPrintSetup.qml | 7 +- .../Recommended/RecommendedSettingItem.qml | 36 +++++++++ .../Recommended/RecommendedSettingSection.qml | 80 +++++++++++++++++++ 4 files changed, 127 insertions(+), 69 deletions(-) create mode 100644 resources/qml/PrintSetupSelector/Recommended/RecommendedSettingItem.qml create mode 100644 resources/qml/PrintSetupSelector/Recommended/RecommendedSettingSection.qml diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedAdhesionSelector.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedAdhesionSelector.qml index 8d31d6292d..c87aa96c07 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedAdhesionSelector.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedAdhesionSelector.qml @@ -1,4 +1,4 @@ -// Copyright (c) 2018 Ultimaker B.V. +// Copyright (c) 2022 Ultimaker B.V. // Cura is released under the terms of the LGPLv3 or higher. import QtQuick 2.7 @@ -7,74 +7,21 @@ import UM 1.5 as UM import Cura 1.0 as Cura -// -// Adhesion -// -Item +RecommendedSettingSection { id: enableAdhesionRow height: enableAdhesionContainer.height - property real labelColumnWidth: Math.round(width / 3) + title: catalog.i18nc("@label", "Adhesion") + icon: UM.Theme.getIcon("Adhesion") + enableSectionVisible: platformAdhesionType.properties.enabled == "True" + enableSectionChecked: platformAdhesionType.properties.value != "skirt" && platformAdhesionType.properties.value != "none" + enableSectionEnabled: recommendedPrintSetup.settingsEnabled + property var curaRecommendedMode: Cura.RecommendedMode {} - Cura.IconWithText - { - id: enableAdhesionRowTitle - anchors.top: parent.top - anchors.left: parent.left - source: UM.Theme.getIcon("Adhesion") - text: catalog.i18nc("@label", "Adhesion") - font: UM.Theme.getFont("medium") - width: labelColumnWidth - iconSize: UM.Theme.getSize("medium_button_icon").width - } - - Item - { - id: enableAdhesionContainer - height: enableAdhesionCheckBox.height - - anchors - { - left: enableAdhesionRowTitle.right - right: parent.right - verticalCenter: enableAdhesionRowTitle.verticalCenter - } - - UM.CheckBox - { - id: enableAdhesionCheckBox - anchors.verticalCenter: parent.verticalCenter - - //: Setting enable printing build-plate adhesion helper checkbox - enabled: recommendedPrintSetup.settingsEnabled - - visible: platformAdhesionType.properties.enabled == "True" - checked: platformAdhesionType.properties.value != "skirt" && platformAdhesionType.properties.value != "none" - - MouseArea - { - id: adhesionMouseArea - anchors.fill: parent - hoverEnabled: true - // propagateComposedEvents used on adhesionTooltipMouseArea does not work with Controls Components. - // It only works with other MouseAreas, so this is required - onClicked: curaRecommendedMode.setAdhesion(!parent.checked) - } - } - } - - MouseArea - { - id: adhesionTooltipMouseArea - anchors.fill: parent - propagateComposedEvents: true - hoverEnabled: true - - onEntered:base.showTooltip(enableAdhesionCheckBox, Qt.point(-enableAdhesionContainer.x - UM.Theme.getSize("thick_margin").width, 0), - catalog.i18nc("@label", "Enable printing a brim or raft. This will add a flat area around or under your object which is easy to cut off afterwards.")); - onExited: base.hideTooltip() + function onEnableSectionChanged(state) { + curaRecommendedMode.setAdhesion(state) } UM.SettingPropertyProvider diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedPrintSetup.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedPrintSetup.qml index 977d90f5e0..472d786618 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedPrintSetup.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedPrintSetup.qml @@ -98,12 +98,7 @@ Item Layout.fillWidth: true } - RecommendedAdhesionSelector - { - width: parent.width - labelColumnWidth: parent.firstColumnWidth - Layout.fillWidth: true - } + RecommendedAdhesionSelector {} } UM.SettingPropertyProvider diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedSettingItem.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedSettingItem.qml new file mode 100644 index 0000000000..684a2afd38 --- /dev/null +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedSettingItem.qml @@ -0,0 +1,36 @@ +// Copyright (c) 2022 Ultimaker B.V. +// Cura is released under the terms of the LGPLv3 or higher. + +import QtQuick 2.10 +import QtQuick.Controls 2.3 +import QtQuick.Layouts 2.10 + +import UM 1.5 as UM +import Cura 1.7 as Cura + + +Item +{ + property Component content: Item { visible: false } + property alias settingName: settingLabel.text + + UM.Label + { + id: settingLabel + anchors.left: parent.left + anchors.verticalCenter: parent.verticalCenter + text: "TEST" + } + + + Loader + { + id: settingLoader + width: parent.width + height: content.height + anchors.left: settingLabel.right + anchors.right: parent.right + anchers.verticalCenter: parent.verticalCenter + sourceComponent: content + } +} \ No newline at end of file diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedSettingSection.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedSettingSection.qml new file mode 100644 index 0000000000..b51d273430 --- /dev/null +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedSettingSection.qml @@ -0,0 +1,80 @@ +// Copyright (c) 2022 Ultimaker B.V. +// Cura is released under the terms of the LGPLv3 or higher. + +import QtQuick 2.10 +import QtQuick.Controls 2.3 +import QtQuick.Layouts 2.10 + +import UM 1.6 as UM +import Cura 1.7 as Cura + +Item +{ + property alias title: sectionTitle.text + property alias icon: sectionTitle.source + property Component content: Item { visible: false } + + property alias enableSectionVisible: enableSectionSwitch.visible + property alias enableSectionChecked: enableSectionSwitch.checked + property alias enableSectionEnabled: enableSectionSwitch.enabled + property var enableSectionClicked: { return } + property int leftColumnWidth: width / 2 + + function onEnableSectionChanged(state) {} + + height: childrenRect.height + width: parent.width + + + Item + { + id: sectionHeader + + Cura.IconWithText + { + id: sectionTitle + width: leftColumnWidth + anchors.left: parent.left + anchors.verticalCenter: parent.verticalCenter + anchors.leftMargin: - UM.Theme.getSize("thick_lining").width + source: UM.Theme.getIcon("PrintQuality") + spacing: UM.Theme.getSize("thick_margin").width + iconSize: UM.Theme.getSize("medium_button_icon").width + iconColor: UM.Theme.getColor("text") + font: UM.Theme.getFont("medium_bold") + } + + UM.Switch + { + id: enableSectionSwitch + anchors.left: sectionTitle.right + anchors.verticalCenter: parent.verticalCenter + visible: false + + onClicked: onEnableSectionChanged(enableSectionSwitch.checked) + } + + MouseArea + { + id: tooltipMouseArea + anchors.fill: parent + propagateComposedEvents: true + hoverEnabled: true + + onEntered: { print("showTooltip") } + onExited: { print("hideTooltip" ) } + } + + } + + Loader + { + id: contentLoader + width: parent.width + height: content.height + anchors.left: settingLabel.right + anchors.right: parent.right + anchors.verticalCenter: parent.verticalCenter + sourceComponent: content + } +} \ No newline at end of file From eb13ac7f6b575ea818e13bb229dfc5ab6ff68adb Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Fri, 25 Nov 2022 17:42:50 +0100 Subject: [PATCH 03/82] Getting setting section sized properly CURA-9793 --- .../RecommendedAdhesionSelector.qml | 25 +++++++++++++------ .../Recommended/RecommendedPrintSetup.qml | 5 +++- .../Recommended/RecommendedSettingItem.qml | 18 +++++++------ .../Recommended/RecommendedSettingSection.qml | 12 ++++++--- 4 files changed, 41 insertions(+), 19 deletions(-) diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedAdhesionSelector.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedAdhesionSelector.qml index c87aa96c07..4eaf4f17ce 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedAdhesionSelector.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedAdhesionSelector.qml @@ -10,7 +10,6 @@ import Cura 1.0 as Cura RecommendedSettingSection { id: enableAdhesionRow - height: enableAdhesionContainer.height title: catalog.i18nc("@label", "Adhesion") icon: UM.Theme.getIcon("Adhesion") @@ -20,17 +19,29 @@ RecommendedSettingSection property var curaRecommendedMode: Cura.RecommendedMode {} - function onEnableSectionChanged(state) { - curaRecommendedMode.setAdhesion(state) - } - - UM.SettingPropertyProvider + property UM.SettingPropertyProvider platformAdhesionType: UM.SettingPropertyProvider { - id: platformAdhesionType containerStack: Cura.MachineManager.activeMachine removeUnusedValue: false //Doesn't work with settings that are resolved. key: "adhesion_type" watchedProperties: [ "value", "resolve", "enabled" ] storeIndex: 0 } + + function onEnableSectionChanged(state) { + curaRecommendedMode.setAdhesion(state) + } + + contents: RecommendedSettingItem + { + settingName: catalog.i18nc("@action:label", "Print with") + + settingControl: Rectangle + { + width: 20 + height: 20 + color: Qt.rgba(1, 0, 0, .5) + } + } + } diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedPrintSetup.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedPrintSetup.qml index 472d786618..5bbfcc5550 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedPrintSetup.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedPrintSetup.qml @@ -98,7 +98,10 @@ Item Layout.fillWidth: true } - RecommendedAdhesionSelector {} + RecommendedAdhesionSelector { + width: parent.width + Layout.fillWidth: true + } } UM.SettingPropertyProvider diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedSettingItem.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedSettingItem.qml index 684a2afd38..2e1dd826a0 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedSettingItem.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedSettingItem.qml @@ -11,26 +11,30 @@ import Cura 1.7 as Cura Item { - property Component content: Item { visible: false } + width: parent.width + height: UM.Theme.getSize("section_header").height + + property alias settingControl: settingContainer.children property alias settingName: settingLabel.text + property int leftColumnWidth: width / 2 UM.Label { id: settingLabel + width: leftColumnWidth anchors.left: parent.left anchors.verticalCenter: parent.verticalCenter - text: "TEST" + // These numbers come from the IconWithText in RecommendedSettingSection + anchors.leftMargin: UM.Theme.getSize("medium_button_icon").width + UM.Theme.getSize("thick_margin").width - UM.Theme.getSize("thick_lining").width } Loader { - id: settingLoader - width: parent.width - height: content.height + id: settingContainer + height: childrenRect.height anchors.left: settingLabel.right anchors.right: parent.right - anchers.verticalCenter: parent.verticalCenter - sourceComponent: content + anchors.verticalCenter: parent.verticalCenter } } \ No newline at end of file diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedSettingSection.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedSettingSection.qml index b51d273430..8eb8c57edb 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedSettingSection.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedSettingSection.qml @@ -20,15 +20,19 @@ Item property var enableSectionClicked: { return } property int leftColumnWidth: width / 2 + property alias contents: settingColumn.children + function onEnableSectionChanged(state) {} height: childrenRect.height - width: parent.width - Item { id: sectionHeader + anchors.top: parent.top + anchors.right: parent.right + anchors.left: parent.left + height: UM.Theme.getSize("section_header").height Cura.IconWithText { @@ -71,8 +75,8 @@ Item { id: contentLoader width: parent.width - height: content.height - anchors.left: settingLabel.right + height: childrenRect.height + anchors.left: parent.left anchors.right: parent.right anchors.verticalCenter: parent.verticalCenter sourceComponent: content From ba958e1186ef507353fb7e25768762901716cb39 Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Fri, 25 Nov 2022 17:42:55 +0100 Subject: [PATCH 04/82] Changes by c.lamboo --- .../Recommended/RecommendedSettingSection.qml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedSettingSection.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedSettingSection.qml index 8eb8c57edb..03e7d0c8a7 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedSettingSection.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedSettingSection.qml @@ -12,7 +12,6 @@ Item { property alias title: sectionTitle.text property alias icon: sectionTitle.source - property Component content: Item { visible: false } property alias enableSectionVisible: enableSectionSwitch.visible property alias enableSectionChecked: enableSectionSwitch.checked @@ -71,14 +70,13 @@ Item } - Loader + Column { - id: contentLoader + id: settingColumn width: parent.width height: childrenRect.height anchors.left: parent.left anchors.right: parent.right - anchors.verticalCenter: parent.verticalCenter - sourceComponent: content + anchors.top: sectionHeader.bottom } } \ No newline at end of file From 4a59607d0519ce6ca5779e8112fa8453b21c4e61 Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Mon, 28 Nov 2022 10:49:53 +0100 Subject: [PATCH 05/82] Switch to ColumnLayout Update part of Support selector to new layout. CURA-9793 --- .../Recommended/RecommendedPrintSetup.qml | 1 - .../Recommended/RecommendedSettingItem.qml | 1 + .../Recommended/RecommendedSettingSection.qml | 5 +- .../RecommendedSupportSelector.qml | 498 ++++++++---------- 4 files changed, 213 insertions(+), 292 deletions(-) diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedPrintSetup.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedPrintSetup.qml index 5bbfcc5550..cf8e9e4e2a 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedPrintSetup.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedPrintSetup.qml @@ -94,7 +94,6 @@ Item RecommendedSupportSelector { width: parent.width - labelColumnWidth: parent.firstColumnWidth Layout.fillWidth: true } diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedSettingItem.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedSettingItem.qml index 2e1dd826a0..9434e856af 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedSettingItem.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedSettingItem.qml @@ -13,6 +13,7 @@ Item { width: parent.width height: UM.Theme.getSize("section_header").height + Layout.fillWidth: true property alias settingControl: settingContainer.children property alias settingName: settingLabel.text diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedSettingSection.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedSettingSection.qml index 03e7d0c8a7..445e1663a6 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedSettingSection.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedSettingSection.qml @@ -18,6 +18,7 @@ Item property alias enableSectionEnabled: enableSectionSwitch.enabled property var enableSectionClicked: { return } property int leftColumnWidth: width / 2 + property var toolTipText: "" property alias contents: settingColumn.children @@ -60,7 +61,7 @@ Item MouseArea { id: tooltipMouseArea - anchors.fill: parent + anchors.fill: sectionTitle propagateComposedEvents: true hoverEnabled: true @@ -70,7 +71,7 @@ Item } - Column + ColumnLayout { id: settingColumn width: parent.width diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedSupportSelector.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedSupportSelector.qml index 3e40c16d74..b59feeff64 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedSupportSelector.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedSupportSelector.qml @@ -3,305 +3,31 @@ import QtQuick 2.10 import QtQuick.Controls 2.3 +import QtQuick.Layouts 1.3 import UM 1.5 as UM import Cura 1.0 as Cura -// -// Enable support -// -Item +RecommendedSettingSection { id: enableSupportRow - height: UM.Theme.getSize("print_setup_big_item").height - property real labelColumnWidth: Math.round(width / 3) + title: catalog.i18nc("@label", "Support") + icon: UM.Theme.getIcon("Support") + enableSectionVisible: supportEnabled.properties.enabled == "True" + enableSectionChecked: supportEnabled.properties.value == "True" + enableSectionEnabled: recommendedPrintSetup.settingsEnabled + toolTipText: catalog.i18nc("@label", "Generate structures to support parts of the model which have overhangs. Without these structures, such parts would collapse during printing.") - Item - { - id: enableSupportContainer - width: labelColumnWidth + enableSupportCheckBox.width - - anchors - { - left: parent.left - top: parent.top - bottom: parent.bottom - rightMargin: UM.Theme.getSize("thick_margin").width - } - - Cura.IconWithText - { - id: enableSupportRowTitle - anchors.left: parent.left - visible: enableSupportCheckBox.visible - source: UM.Theme.getIcon("Support") - text: catalog.i18nc("@label", "Support") - font: UM.Theme.getFont("medium") - width: labelColumnWidth - iconSize: UM.Theme.getSize("medium_button_icon").width - tooltipText: catalog.i18nc("@label", "Generate structures to support parts of the model which have overhangs. Without these structures, such parts would collapse during printing.") - } - - UM.CheckBox - { - id: enableSupportCheckBox - anchors.verticalCenter: parent.verticalCenter - anchors.left: enableSupportRowTitle.right - - property alias _hovered: enableSupportMouseArea.containsMouse - - enabled: recommendedPrintSetup.settingsEnabled - - visible: supportEnabled.properties.enabled == "True" - checked: supportEnabled.properties.value == "True" - - MouseArea - { - id: enableSupportMouseArea - anchors.fill: parent - hoverEnabled: true - // propagateComposedEvents used on supportToolTipMouseArea does not work with Controls Components. - // It only works with other MouseAreas, so this is required - onClicked: supportEnabled.setPropertyValue("value", supportEnabled.properties.value != "True") - } - } - - MouseArea - { - id: supportToolTipMouseArea - anchors.fill: parent - propagateComposedEvents: true - hoverEnabled: true - onEntered: base.showTooltip(enableSupportContainer, Qt.point(-enableSupportContainer.x - UM.Theme.getSize("thick_margin").width, 0), - catalog.i18nc("@label", "Generate structures to support parts of the model which have overhangs. Without these structures, such parts would collapse during printing.")) - onExited: base.hideTooltip() - } - } - - ComboBox - { - id: supportExtruderCombobox - - height: UM.Theme.getSize("print_setup_big_item").height - anchors - { - left: enableSupportContainer.right - right: parent.right - leftMargin: UM.Theme.getSize("default_margin").width - rightMargin: UM.Theme.getSize("thick_margin").width - verticalCenter: parent.verticalCenter - } - - enabled: recommendedPrintSetup.settingsEnabled - visible: enableSupportCheckBox.visible && (supportEnabled.properties.value == "True") && (extrudersEnabledCount.properties.value > 1) - textRole: "name" // this solves that the combobox isn't populated in the first time Cura is started - - model: extruderModel - - // knowing the extruder position, try to find the item index in the model - function getIndexByPosition(position) - { - var itemIndex = -1 // if position is not found, return -1 - for (var item_index in model.items) - { - var item = model.getItem(item_index) - if (item.index == position) - { - itemIndex = item_index - break - } - } - return itemIndex - } - - onActivated: - { - if (model.getItem(index).enabled) - { - forceActiveFocus(); - supportExtruderNr.setPropertyValue("value", model.getItem(index).index); - } else - { - currentIndex = supportExtruderNr.properties.value; // keep the old value - } - } - - currentIndex: (supportExtruderNr.properties.value !== undefined) ? supportExtruderNr.properties.value : 0 - - property string color: "#fff" - Connections - { - target: extruderModel - function onModelChanged() - { - var maybeColor = supportExtruderCombobox.model.getItem(supportExtruderCombobox.currentIndex).color - if (maybeColor) - { - supportExtruderCombobox.color = maybeColor - } - } - } - onCurrentIndexChanged: - { - var maybeColor = supportExtruderCombobox.model.getItem(supportExtruderCombobox.currentIndex).color - if(maybeColor) - { - supportExtruderCombobox.color = maybeColor - } - } - - Binding - { - target: supportExtruderCombobox - property: "currentIndex" - value: supportExtruderCombobox.getIndexByPosition(supportExtruderNr.properties.value) - // Sometimes when the value is already changed, the model is still being built. - // The when clause ensures that the current index is not updated when this happens. - when: supportExtruderCombobox.model.count > 0 - } - - indicator: UM.ColorImage - { - id: downArrow - x: supportExtruderCombobox.width - width - supportExtruderCombobox.rightPadding - y: supportExtruderCombobox.topPadding + Math.round((supportExtruderCombobox.availableHeight - height) / 2) - - source: UM.Theme.getIcon("ChevronSingleDown") - width: UM.Theme.getSize("standard_arrow").width - height: UM.Theme.getSize("standard_arrow").height - - color: UM.Theme.getColor("setting_control_button") - } - - background: Rectangle - { - color: - { - if (!enabled) - { - return UM.Theme.getColor("setting_control_disabled") - } - if (supportExtruderCombobox.hovered || base.activeFocus) - { - return UM.Theme.getColor("setting_control_highlight") - } - return UM.Theme.getColor("setting_control") - } - radius: UM.Theme.getSize("setting_control_radius").width - border.width: UM.Theme.getSize("default_lining").width - border.color: - { - if (!enabled) - { - return UM.Theme.getColor("setting_control_disabled_border") - } - if (supportExtruderCombobox.hovered || supportExtruderCombobox.activeFocus) - { - return UM.Theme.getColor("setting_control_border_highlight") - } - return UM.Theme.getColor("setting_control_border") - } - } - - contentItem: UM.Label - { - anchors.verticalCenter: parent.verticalCenter - anchors.left: parent.left - anchors.leftMargin: UM.Theme.getSize("setting_unit_margin").width - anchors.right: downArrow.left - rightPadding: swatch.width + UM.Theme.getSize("setting_unit_margin").width - - text: supportExtruderCombobox.currentText - textFormat: Text.PlainText - color: enabled ? UM.Theme.getColor("setting_control_text") : UM.Theme.getColor("setting_control_disabled_text") - - elide: Text.ElideLeft - - - background: Rectangle - { - id: swatch - height: Math.round(parent.height / 2) - width: height - radius: Math.round(width / 2) - anchors.right: parent.right - anchors.verticalCenter: parent.verticalCenter - anchors.rightMargin: UM.Theme.getSize("thin_margin").width - - color: supportExtruderCombobox.color - } - } - - popup: Popup - { - y: supportExtruderCombobox.height - UM.Theme.getSize("default_lining").height - width: supportExtruderCombobox.width - implicitHeight: contentItem.implicitHeight + 2 * UM.Theme.getSize("default_lining").width - padding: UM.Theme.getSize("default_lining").width - - contentItem: ListView - { - implicitHeight: contentHeight - - ScrollBar.vertical: UM.ScrollBar {} - clip: true - model: supportExtruderCombobox.popup.visible ? supportExtruderCombobox.delegateModel : null - currentIndex: supportExtruderCombobox.highlightedIndex - } - - background: Rectangle - { - color: UM.Theme.getColor("setting_control") - border.color: UM.Theme.getColor("setting_control_border") - } - } - - delegate: ItemDelegate - { - width: supportExtruderCombobox.width - 2 * UM.Theme.getSize("default_lining").width - height: supportExtruderCombobox.height - highlighted: supportExtruderCombobox.highlightedIndex == index - - contentItem: UM.Label - { - anchors.fill: parent - anchors.leftMargin: UM.Theme.getSize("setting_unit_margin").width - anchors.rightMargin: UM.Theme.getSize("setting_unit_margin").width - - text: model.name - color: model.enabled ? UM.Theme.getColor("setting_control_text"): UM.Theme.getColor("action_button_disabled_text") - - elide: Text.ElideRight - rightPadding: swatch.width + UM.Theme.getSize("setting_unit_margin").width - - background: Rectangle - { - id: swatch - height: Math.round(parent.height / 2) - width: height - radius: Math.round(width / 2) - anchors.right: parent.right - anchors.verticalCenter: parent.verticalCenter - anchors.rightMargin: UM.Theme.getSize("thin_margin").width - - color: supportExtruderCombobox.model.getItem(index).color - } - } - - background: Rectangle - { - color: parent.highlighted ? UM.Theme.getColor("setting_control_highlight") : "transparent" - border.color: parent.highlighted ? UM.Theme.getColor("setting_control_border_highlight") : "transparent" - } - } + function onEnableSectionChanged(state) { + supportEnabled.setPropertyValue("value", state) } property var extruderModel: CuraApplication.getExtrudersModel() - UM.SettingPropertyProvider + property UM.SettingPropertyProvider supportEnabled: UM.SettingPropertyProvider { id: supportEnabled containerStack: Cura.MachineManager.activeMachine @@ -310,21 +36,215 @@ Item storeIndex: 0 } - UM.SettingPropertyProvider + property UM.SettingPropertyProvider supportExtruderNr: UM.SettingPropertyProvider { - id: supportExtruderNr containerStack: Cura.MachineManager.activeMachine key: "support_extruder_nr" watchedProperties: [ "value" ] storeIndex: 0 } - UM.SettingPropertyProvider + property UM.SettingPropertyProvider machineExtruderCount: UM.SettingPropertyProvider { - id: machineExtruderCount containerStack: Cura.MachineManager.activeMachine key: "machine_extruder_count" watchedProperties: ["value"] storeIndex: 0 } + + //Replace this with the Extruder selector + contents: [ + RecommendedSettingItem + { + settingName: catalog.i18nc("@action:label", "Print with") + settingControl: Rectangle { color: "red"; width: 10; height:10 } +// ComboBox +// { +// id: supportExtruderCombobox +// +// // height: UM.Theme.getSize("print_setup_big_item").height +// +// enabled: recommendedPrintSetup.settingsEnabled +// visible: (supportEnabled.properties.value == "True") && (extrudersEnabledCount.properties.value > 1) +// textRole: "name" // this solves that the combobox isn't populated in the first time Cura is started +// +// model: extruderModel +// +// // knowing the extruder position, try to find the item index in the model +// function getIndexByPosition(position) +// { +// var itemIndex = -1 // if position is not found, return -1 +// for (var item_index in model.items) +// { +// var item = model.getItem(item_index) +// if (item.index == position) +// { +// itemIndex = item_index +// break +// } +// } +// return itemIndex +// } +// +// onActivated: +// { +// if (model.getItem(index).enabled) +// { +// forceActiveFocus(); +// supportExtruderNr.setPropertyValue("value", model.getItem(index).index); +// } else +// { +// currentIndex = supportExtruderNr.properties.value; // keep the old value +// } +// } +// +// // currentIndex: (supportExtruderNr.properties.value !== undefined) ? supportExtruderNr.properties.value : 0 +// +// property string color: "#fff" +// Connections +// { +// target: extruderModel +// function onModelChanged() +// { +// var maybeColor = supportExtruderCombobox.model.getItem(supportExtruderCombobox.currentIndex).color +// if (maybeColor) +// { +// supportExtruderCombobox.color = maybeColor +// } +// } +// } +// onCurrentIndexChanged: +// { +// var maybeColor = supportExtruderCombobox.model.getItem(supportExtruderCombobox.currentIndex).color +// if(maybeColor) +// { +// supportExtruderCombobox.color = maybeColor +// } +// } +// +// Binding +// { +// target: supportExtruderCombobox +// property: "currentIndex" +// value: supportExtruderCombobox.getIndexByPosition(supportExtruderNr.properties.value) +// // Sometimes when the value is already changed, the model is still being built. +// // The when clause ensures that the current index is not updated when this happens. +// when: supportExtruderCombobox.model.count > 0 +// } +// +// indicator: UM.ColorImage +// { +// id: downArrow +// x: supportExtruderCombobox.width - width - supportExtruderCombobox.rightPadding +// y: supportExtruderCombobox.topPadding + Math.round((supportExtruderCombobox.availableHeight - height) / 2) +// +// source: UM.Theme.getIcon("ChevronSingleDown") +// width: UM.Theme.getSize("standard_arrow").width +// height: UM.Theme.getSize("standard_arrow").height +// +// color: UM.Theme.getColor("setting_control_button") +// } +// +// contentItem: UM.Label +// { +// anchors.verticalCenter: parent.verticalCenter +// anchors.left: parent.left +// anchors.leftMargin: UM.Theme.getSize("setting_unit_margin").width +// anchors.right: downArrow.left +// rightPadding: swatch.width + UM.Theme.getSize("setting_unit_margin").width +// +// text: supportExtruderCombobox.currentText +// textFormat: Text.PlainText +// color: enabled ? UM.Theme.getColor("setting_control_text") : UM.Theme.getColor("setting_control_disabled_text") +// +// elide: Text.ElideLeft +// +// +// background: Rectangle +// { +// id: swatch +// height: Math.round(parent.height / 2) +// width: height +// radius: Math.round(width / 2) +// anchors.right: parent.right +// anchors.verticalCenter: parent.verticalCenter +// anchors.rightMargin: UM.Theme.getSize("thin_margin").width +// +// color: supportExtruderCombobox.color +// } +// } +// +// popup: Popup +// { +// y: supportExtruderCombobox.height - UM.Theme.getSize("default_lining").height +// width: supportExtruderCombobox.width +// implicitHeight: contentItem.implicitHeight + 2 * UM.Theme.getSize("default_lining").width +// padding: UM.Theme.getSize("default_lining").width +// +// contentItem: ListView +// { +// implicitHeight: contentHeight +// +// ScrollBar.vertical: UM.ScrollBar {} +// clip: true +// model: supportExtruderCombobox.popup.visible ? supportExtruderCombobox.delegateModel : null +// currentIndex: supportExtruderCombobox.highlightedIndex +// } +// +// background: Rectangle +// { +// color: UM.Theme.getColor("setting_control") +// border.color: UM.Theme.getColor("setting_control_border") +// } +// } +// +// delegate: ItemDelegate +// { +// width: supportExtruderCombobox.width - 2 * UM.Theme.getSize("default_lining").width +// height: supportExtruderCombobox.height +// highlighted: supportExtruderCombobox.highlightedIndex == index +// +// contentItem: UM.Label +// { +// anchors.fill: parent +// anchors.leftMargin: UM.Theme.getSize("setting_unit_margin").width +// anchors.rightMargin: UM.Theme.getSize("setting_unit_margin").width +// +// text: model.name +// color: model.enabled ? UM.Theme.getColor("setting_control_text"): UM.Theme.getColor("action_button_disabled_text") +// +// elide: Text.ElideRight +// rightPadding: swatch.width + UM.Theme.getSize("setting_unit_margin").width +// +// background: Rectangle +// { +// id: swatch +// height: Math.round(parent.height / 2) +// width: height +// radius: Math.round(width / 2) +// anchors.right: parent.right +// anchors.verticalCenter: parent.verticalCenter +// anchors.rightMargin: UM.Theme.getSize("thin_margin").width +// +// color: supportExtruderCombobox.model.getItem(index).color +// } +// } +// +// background: Rectangle +// { +// color: parent.highlighted ? UM.Theme.getColor("setting_control_highlight") : "transparent" +// border.color: parent.highlighted ? UM.Theme.getColor("setting_control_border_highlight") : "transparent" +// } +// } +// } + }, + + RecommendedSettingItem + { + settingName: catalog.i18nc("@action:label", "Placement") + settingControl: Rectangle { color: "red"; width: 10; height:10 } + } + ] + + } From 30d886cfcda886ae03160984ceaa0aa94240f665 Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Mon, 28 Nov 2022 13:06:03 +0100 Subject: [PATCH 06/82] Adjust setting first column width to match designs. CURA-9793 --- .../PrintSetupSelector/Recommended/RecommendedSettingItem.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedSettingItem.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedSettingItem.qml index 9434e856af..ddd99af1ab 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedSettingItem.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedSettingItem.qml @@ -17,7 +17,7 @@ Item property alias settingControl: settingContainer.children property alias settingName: settingLabel.text - property int leftColumnWidth: width / 2 + property int leftColumnWidth: Math.floor(width * 0.35) UM.Label { From 631d6a15b09f82aef08245898ca8297d05c1f294 Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Mon, 28 Nov 2022 15:55:55 +0100 Subject: [PATCH 07/82] =?UTF-8?q?Add=20extruder=20button=20bar=20that=20sh?= =?UTF-8?q?ows=20icons=20for=20each=20extruder=20in=20a=20horizontal=20row?= =?UTF-8?q?=20=F0=9F=92=AA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Make ExtruderButton more generic by moving functionality out. Remove background color from ToolbarButton and add that background color to the Toolbar.qml. Fix Toolbar border being created by overlapping rectangles instead of using border Add scaling options for ToolBarButtons icon CURA-9793 --- .../Recommended/RecommendedSettingItem.qml | 4 +- .../Recommended/RecommendedSettingSection.qml | 2 +- .../RecommendedSupportSelector.qml | 8 ++-- resources/qml/Toolbar.qml | 32 +++++++++------ resources/qml/Widgets/ExtruderSelectorBar.qml | 40 +++++++++++++++++++ resources/qml/qmldir | 2 + 6 files changed, 70 insertions(+), 18 deletions(-) create mode 100644 resources/qml/Widgets/ExtruderSelectorBar.qml diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedSettingItem.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedSettingItem.qml index ddd99af1ab..ec777b13d6 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedSettingItem.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedSettingItem.qml @@ -12,12 +12,12 @@ import Cura 1.7 as Cura Item { width: parent.width - height: UM.Theme.getSize("section_header").height + Layout.preferredHeight: childrenRect.height + Layout.minimumHeight: UM.Theme.getSize("section_header").height Layout.fillWidth: true property alias settingControl: settingContainer.children property alias settingName: settingLabel.text - property int leftColumnWidth: Math.floor(width * 0.35) UM.Label { diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedSettingSection.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedSettingSection.qml index 445e1663a6..ac0c7fbccf 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedSettingSection.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedSettingSection.qml @@ -17,7 +17,7 @@ Item property alias enableSectionChecked: enableSectionSwitch.checked property alias enableSectionEnabled: enableSectionSwitch.enabled property var enableSectionClicked: { return } - property int leftColumnWidth: width / 2 + property int leftColumnWidth: Math.floor(width * 0.35) property var toolTipText: "" property alias contents: settingColumn.children diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedSupportSelector.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedSupportSelector.qml index b59feeff64..8da6f8cd01 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedSupportSelector.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedSupportSelector.qml @@ -6,7 +6,7 @@ import QtQuick.Controls 2.3 import QtQuick.Layouts 1.3 import UM 1.5 as UM -import Cura 1.0 as Cura +import Cura 1.6 as Cura RecommendedSettingSection @@ -57,7 +57,9 @@ RecommendedSettingSection RecommendedSettingItem { settingName: catalog.i18nc("@action:label", "Print with") - settingControl: Rectangle { color: "red"; width: 10; height:10 } + settingControl: Cura.ExtruderSelectorBar { model: extruderModel } + + Layout.preferredHeight: childrenRect.height // ComboBox // { // id: supportExtruderCombobox @@ -242,7 +244,7 @@ RecommendedSettingSection RecommendedSettingItem { settingName: catalog.i18nc("@action:label", "Placement") - settingControl: Rectangle { color: "red"; width: 10; height:10 } + settingControl: Rectangle { color: "green"; width: 50; height:50 } } ] diff --git a/resources/qml/Toolbar.qml b/resources/qml/Toolbar.qml index 6ecdc9dce0..e003c6cd6f 100644 --- a/resources/qml/Toolbar.qml +++ b/resources/qml/Toolbar.qml @@ -5,7 +5,7 @@ import QtQuick 2.2 import QtQuick.Controls 2.3 import UM 1.5 as UM -import Cura 1.0 as Cura +import Cura 1.7 as Cura Item { @@ -29,13 +29,13 @@ Item anchors { fill: toolButtons - leftMargin: -radius - border.width - rightMargin: -border.width - topMargin: -border.width - bottomMargin: -border.width + leftMargin: -radius - border.width // Removes border on left side } radius: UM.Theme.getSize("default_radius").width - color: UM.Theme.getColor("lining") + color: UM.Theme.getColor("toolbar_background") + border.color: UM.Theme.getColor("lining") + border.width: UM.Theme.getSize("default_lining").width + } Column @@ -111,13 +111,12 @@ Item anchors { fill: extruderButtons - leftMargin: -radius - border.width - rightMargin: -border.width - topMargin: -border.width - bottomMargin: -border.width + leftMargin: -radius - border.width // Removes border on left side } radius: UM.Theme.getSize("default_radius").width - color: UM.Theme.getColor("lining") + color: UM.Theme.getColor("toolbar_background") + border.color: UM.Theme.getColor("lining") + border.width: UM.Theme.getSize("default_lining").width visible: extrudersModel.items.length > 1 } @@ -135,11 +134,20 @@ Item height: childrenRect.height model: extrudersModel.items.length > 1 ? extrudersModel : 0 - delegate: ExtruderButton + delegate: Cura.ExtruderButton { extruder: model isTopElement: extrudersModel.getItem(0).id == model.id isBottomElement: extrudersModel.getItem(extrudersModel.rowCount() - 1).id == model.id + text: catalog.i18ncp("@label %1 is filled in with the name of an extruder", "Print Selected Model with %1", "Print Selected Models with %1", UM.Selection.selectionCount).arg(extruder.name) + checked: Cura.ExtruderManager.selectedObjectExtruders.indexOf(extruder.id) != -1 + enabled: UM.Selection.hasSelection && extruder.stack.isEnabled + + onClicked: + { + forceActiveFocus() //First grab focus, so all the text fields are updated + CuraActions.setExtruderForSelection(extruder.id) + } } } } diff --git a/resources/qml/Widgets/ExtruderSelectorBar.qml b/resources/qml/Widgets/ExtruderSelectorBar.qml new file mode 100644 index 0000000000..7ac4101ed8 --- /dev/null +++ b/resources/qml/Widgets/ExtruderSelectorBar.qml @@ -0,0 +1,40 @@ +import QtQuick 2.12 +import QtQuick.Controls 2.12 +import QtQuick.Layouts 1.3 + +import UM 1.5 as UM +import Cura 1.5 as Cura + +Row +{ + id: extruderSelectionBar + property alias model: extruderButtonRepeater.model + + spacing: 0 + width: parent.width + height: childrenRect.height + + Repeater + { + id: extruderButtonRepeater + + delegate: Item + { + width: { + const maximum_width = Math.floor(extruderSelectionBar.width / extruderButtonRepeater.count); + return Math.min(UM.Theme.getSize("large_button").width, maximum_width); + } + + height: childrenRect.height + + Cura.ExtruderButton + { + extruder: model + isTopElement: extrudersModel.getItem(0).id == model.id + isBottomElement: extrudersModel.getItem(extrudersModel.rowCount() - 1).id == model.id + iconScale: 0.6 + buttonSize: UM.Theme.getSize("large_button").width + } + } + } +} diff --git a/resources/qml/qmldir b/resources/qml/qmldir index d5184f1d8c..1a6739f5fb 100644 --- a/resources/qml/qmldir +++ b/resources/qml/qmldir @@ -38,6 +38,8 @@ ScrollView 1.0 ScrollView.qml Menu 1.0 Menu.qml MenuItem 1.0 MenuItem.qml MenuSeparator 1.0 MenuSeparator.qml +ExtruderSelectorBar 1.6 ExtruderSelectorBar.qml +ExtruderButton 1.6 ExtruderButton.qml # Cura/MachineSettings From 84988a57e503fed0f6c04238036530abb4698d97 Mon Sep 17 00:00:00 2001 From: "c.lamboo" Date: Mon, 28 Nov 2022 22:01:28 +0100 Subject: [PATCH 08/82] Update styling of infill slider CURA-9793 --- .../RecommendedStrengthSelector.qml | 79 +++++++++---------- resources/themes/cura-light/theme.json | 4 +- 2 files changed, 41 insertions(+), 42 deletions(-) diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedStrengthSelector.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedStrengthSelector.qml index 0317cb7814..d0914e8813 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedStrengthSelector.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedStrengthSelector.qml @@ -6,6 +6,7 @@ import QtQuick.Controls 2.15 import UM 1.5 as UM import Cura 1.0 as Cura +import QtQuick.Layouts 1.3 // @@ -25,24 +26,29 @@ Item property: "source" value: { - var density = parseInt(infillDensity.properties.value) - if (parseInt(infillSteps.properties.value) != 0) + const infill_steps = parseInt(infillSteps.properties.value); + if (infill_steps != 0) { return UM.Theme.getIcon("InfillGradual") } - if (density <= 0) + + const density = parseInt(infillDensity.properties.value) + if (density == 0) { - return UM.Theme.getIcon("Infill0") + return UM.Theme.getIcon("Infill0"); } - if (density < 40) + else if (density < 40) { - return UM.Theme.getIcon("Infill3") + return UM.Theme.getIcon("Infill3"); } - if (density < 90) + else if (density < 90) { - return UM.Theme.getIcon("Infill2") + return UM.Theme.getIcon("Infill2"); + } + else + { + return UM.Theme.getIcon("Infill100"); } - return UM.Theme.getIcon("Infill100") } } @@ -55,7 +61,7 @@ Item // The infill slider has a max value of 100. When it is given a value > 100 onValueChanged updates the setting to be 100. // When changing to an intent with infillDensity > 100, it would always be clamped to 100. // This will force the slider to ignore the first onValueChanged for values > 100 so higher values can be set. - var density = parseInt(infillDensity.properties.value) + const density = parseInt(infillDensity.properties.value) if (density > 100) { infillSlider.ignoreValueChange = true } @@ -71,18 +77,20 @@ Item anchors.top: parent.top anchors.left: parent.left source: UM.Theme.getIcon("Infill1") - text: catalog.i18nc("@label", "Infill") + " (%)" + text: `${catalog.i18nc("@label", "Infill")} (%)` font: UM.Theme.getFont("medium") width: labelColumnWidth iconSize: UM.Theme.getSize("medium_button_icon").width tooltipText: catalog.i18nc("@label", "Gradual infill will gradually increase the amount of infill towards the top.") } - Item + RowLayout { id: infillSliderContainer height: childrenRect.height + spacing: UM.Theme.getSize("default_margin").width + anchors { left: infillRowTitle.right @@ -90,18 +98,19 @@ Item verticalCenter: infillRowTitle.verticalCenter } + UM.Label { Layout.fillWidth: false; text: "0" } + Slider { id: infillSlider + Layout.fillWidth: true property var ignoreValueChange: false width: parent.width - height: UM.Theme.getSize("print_setup_slider_handle").height // The handle is the widest element of the slider + height: childrenRect.height - from: 0 - to: 100 - stepSize: 1 + from: 0; to: 100; stepSize: 1 // disable slider when gradual support is enabled enabled: parseInt(infillSteps.properties.value) == 0 @@ -117,36 +126,24 @@ Item width: parent.width - UM.Theme.getSize("print_setup_slider_handle").width anchors.horizontalCenter: parent.horizontalCenter anchors.verticalCenter: parent.verticalCenter - color: infillSlider.enabled ? UM.Theme.getColor("quality_slider_available") : UM.Theme.getColor("quality_slider_unavailable") + color: UM.Theme.getColor("lining") Repeater { id: repeater anchors.fill: parent - model: infillSlider.to / infillSlider.stepSize + 1 + model: 11 Rectangle { - color: infillSlider.enabled ? UM.Theme.getColor("quality_slider_available") : UM.Theme.getColor("quality_slider_unavailable") + color: UM.Theme.getColor("lining") implicitWidth: UM.Theme.getSize("print_setup_slider_tickmarks").width implicitHeight: UM.Theme.getSize("print_setup_slider_tickmarks").height anchors.verticalCenter: parent.verticalCenter - // Do not use Math.round otherwise the tickmarks won't be aligned - // (space between steps) * index of step - x: (backgroundLine.width / (repeater.count - 1)) * index + x: Math.round(backgroundLine.width / (repeater.count - 1) * index - width / 2) - radius: Math.round(implicitWidth / 2) - visible: (index % 10) == 0 // Only show steps of 10% - - UM.Label - { - text: index - visible: (index % 20) == 0 // Only show steps of 20% - anchors.horizontalCenter: parent.horizontalCenter - y: UM.Theme.getSize("thin_margin").height - color: UM.Theme.getColor("quality_slider_available") - } + radius: Math.round(width / 2) } } } @@ -155,13 +152,13 @@ Item { id: handleButton x: infillSlider.leftPadding + infillSlider.visualPosition * (infillSlider.availableWidth - width) - y: infillSlider.topPadding + infillSlider.availableHeight / 2 - height / 2 - color: infillSlider.enabled ? UM.Theme.getColor("primary") : UM.Theme.getColor("quality_slider_unavailable") + anchors.verticalCenter: parent.verticalCenter implicitWidth: UM.Theme.getSize("print_setup_slider_handle").width - implicitHeight: implicitWidth - radius: Math.round(implicitWidth / 2) - border.color: UM.Theme.getColor("slider_groove_fill") - border.width: UM.Theme.getSize("default_lining").height + implicitHeight: UM.Theme.getSize("print_setup_slider_handle").height + radius: Math.round(width / 2) + color: UM.Theme.getColor("main_background") + border.color: UM.Theme.getColor("primary") + border.width: UM.Theme.getSize("wide_lining").height } Connections @@ -201,6 +198,8 @@ Item } } } + + UM.Label { Layout.fillWidth: false; text: "100" } } // Gradual Support Infill Checkbox @@ -210,7 +209,7 @@ Item property alias _hovered: enableGradualInfillMouseArea.containsMouse anchors.top: infillSliderContainer.bottom - anchors.topMargin: UM.Theme.getSize("wide_margin").height + anchors.topMargin: UM.Theme.getSize("default_margin").height anchors.left: infillSliderContainer.left text: catalog.i18nc("@label", "Gradual infill") diff --git a/resources/themes/cura-light/theme.json b/resources/themes/cura-light/theme.json index 809bcfdee8..4fd31db731 100644 --- a/resources/themes/cura-light/theme.json +++ b/resources/themes/cura-light/theme.json @@ -487,8 +487,8 @@ "print_setup_widget": [38.0, 30.0], "print_setup_extruder_box": [0.0, 6.0], "print_setup_slider_groove": [0.16, 0.16], - "print_setup_slider_handle": [1.0, 1.0], - "print_setup_slider_tickmarks": [0.32, 0.32], + "print_setup_slider_handle": [1.3, 1.3], + "print_setup_slider_tickmarks": [0.5, 0.5], "print_setup_big_item": [28, 2.5], "print_setup_icon": [1.2, 1.2], "drag_icon": [1.416, 0.25], From 3682918efa98e3c2f36cd930f8f7b21be6f9c696 Mon Sep 17 00:00:00 2001 From: jspijker Date: Tue, 29 Nov 2022 08:41:45 +0100 Subject: [PATCH 09/82] Add basic styling to Switch Contributes to CURA-9793 --- resources/themes/cura-light/theme.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/resources/themes/cura-light/theme.json b/resources/themes/cura-light/theme.json index 4fd31db731..d1ba93bef1 100644 --- a/resources/themes/cura-light/theme.json +++ b/resources/themes/cura-light/theme.json @@ -354,6 +354,10 @@ "checkbox_text": "text_default", "checkbox_text_disabled": "text_disabled", + "switch": "background_1", + "switch_state_checked": "accent_1", + "switch_state_unchecked": "text_disabled", + "radio": "background_1", "radio_disabled": "background_2", "radio_selected": "accent_1", From 87ff29499030e4ba83c2d7ec3f8d3c8a4c3b8bc9 Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Mon, 28 Nov 2022 16:36:14 +0100 Subject: [PATCH 10/82] Remove redundant parameters. These will now be overriden by the parent. CURA-9793 --- resources/qml/ExtruderButton.qml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/resources/qml/ExtruderButton.qml b/resources/qml/ExtruderButton.qml index 204e9a5469..df1a72e765 100644 --- a/resources/qml/ExtruderButton.qml +++ b/resources/qml/ExtruderButton.qml @@ -13,11 +13,6 @@ UM.ToolbarButton property var extruder - text: catalog.i18ncp("@label %1 is filled in with the name of an extruder", "Print Selected Model with %1", "Print Selected Models with %1", UM.Selection.selectionCount).arg(extruder.name) - - checked: Cura.ExtruderManager.selectedObjectExtruders.indexOf(extruder.id) != -1 - enabled: UM.Selection.hasSelection && extruder.stack.isEnabled - toolItem: ExtruderIcon { materialColor: extruder.color From 5d5915e49edce8577deb5055fb55e1fad28c2b13 Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Mon, 28 Nov 2022 16:38:44 +0100 Subject: [PATCH 11/82] Make support selector functional CURA-9793 --- .../RecommendedSupportSelector.qml | 190 +----------------- resources/qml/Widgets/ExtruderSelectorBar.qml | 13 +- 2 files changed, 18 insertions(+), 185 deletions(-) diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedSupportSelector.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedSupportSelector.qml index 8da6f8cd01..4e8ac406dc 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedSupportSelector.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedSupportSelector.qml @@ -57,188 +57,18 @@ RecommendedSettingSection RecommendedSettingItem { settingName: catalog.i18nc("@action:label", "Print with") - settingControl: Cura.ExtruderSelectorBar { model: extruderModel } + settingControl: Cura.ExtruderSelectorBar + { + model: extruderModel + selectedIndex: (supportExtruderNr.properties.value !== undefined) ? supportExtruderNr.properties.value : 0 + function onClickExtruder(index) + { + forceActiveFocus(); + supportExtruderNr.setPropertyValue("value", index); + } + } Layout.preferredHeight: childrenRect.height -// ComboBox -// { -// id: supportExtruderCombobox -// -// // height: UM.Theme.getSize("print_setup_big_item").height -// -// enabled: recommendedPrintSetup.settingsEnabled -// visible: (supportEnabled.properties.value == "True") && (extrudersEnabledCount.properties.value > 1) -// textRole: "name" // this solves that the combobox isn't populated in the first time Cura is started -// -// model: extruderModel -// -// // knowing the extruder position, try to find the item index in the model -// function getIndexByPosition(position) -// { -// var itemIndex = -1 // if position is not found, return -1 -// for (var item_index in model.items) -// { -// var item = model.getItem(item_index) -// if (item.index == position) -// { -// itemIndex = item_index -// break -// } -// } -// return itemIndex -// } -// -// onActivated: -// { -// if (model.getItem(index).enabled) -// { -// forceActiveFocus(); -// supportExtruderNr.setPropertyValue("value", model.getItem(index).index); -// } else -// { -// currentIndex = supportExtruderNr.properties.value; // keep the old value -// } -// } -// -// // currentIndex: (supportExtruderNr.properties.value !== undefined) ? supportExtruderNr.properties.value : 0 -// -// property string color: "#fff" -// Connections -// { -// target: extruderModel -// function onModelChanged() -// { -// var maybeColor = supportExtruderCombobox.model.getItem(supportExtruderCombobox.currentIndex).color -// if (maybeColor) -// { -// supportExtruderCombobox.color = maybeColor -// } -// } -// } -// onCurrentIndexChanged: -// { -// var maybeColor = supportExtruderCombobox.model.getItem(supportExtruderCombobox.currentIndex).color -// if(maybeColor) -// { -// supportExtruderCombobox.color = maybeColor -// } -// } -// -// Binding -// { -// target: supportExtruderCombobox -// property: "currentIndex" -// value: supportExtruderCombobox.getIndexByPosition(supportExtruderNr.properties.value) -// // Sometimes when the value is already changed, the model is still being built. -// // The when clause ensures that the current index is not updated when this happens. -// when: supportExtruderCombobox.model.count > 0 -// } -// -// indicator: UM.ColorImage -// { -// id: downArrow -// x: supportExtruderCombobox.width - width - supportExtruderCombobox.rightPadding -// y: supportExtruderCombobox.topPadding + Math.round((supportExtruderCombobox.availableHeight - height) / 2) -// -// source: UM.Theme.getIcon("ChevronSingleDown") -// width: UM.Theme.getSize("standard_arrow").width -// height: UM.Theme.getSize("standard_arrow").height -// -// color: UM.Theme.getColor("setting_control_button") -// } -// -// contentItem: UM.Label -// { -// anchors.verticalCenter: parent.verticalCenter -// anchors.left: parent.left -// anchors.leftMargin: UM.Theme.getSize("setting_unit_margin").width -// anchors.right: downArrow.left -// rightPadding: swatch.width + UM.Theme.getSize("setting_unit_margin").width -// -// text: supportExtruderCombobox.currentText -// textFormat: Text.PlainText -// color: enabled ? UM.Theme.getColor("setting_control_text") : UM.Theme.getColor("setting_control_disabled_text") -// -// elide: Text.ElideLeft -// -// -// background: Rectangle -// { -// id: swatch -// height: Math.round(parent.height / 2) -// width: height -// radius: Math.round(width / 2) -// anchors.right: parent.right -// anchors.verticalCenter: parent.verticalCenter -// anchors.rightMargin: UM.Theme.getSize("thin_margin").width -// -// color: supportExtruderCombobox.color -// } -// } -// -// popup: Popup -// { -// y: supportExtruderCombobox.height - UM.Theme.getSize("default_lining").height -// width: supportExtruderCombobox.width -// implicitHeight: contentItem.implicitHeight + 2 * UM.Theme.getSize("default_lining").width -// padding: UM.Theme.getSize("default_lining").width -// -// contentItem: ListView -// { -// implicitHeight: contentHeight -// -// ScrollBar.vertical: UM.ScrollBar {} -// clip: true -// model: supportExtruderCombobox.popup.visible ? supportExtruderCombobox.delegateModel : null -// currentIndex: supportExtruderCombobox.highlightedIndex -// } -// -// background: Rectangle -// { -// color: UM.Theme.getColor("setting_control") -// border.color: UM.Theme.getColor("setting_control_border") -// } -// } -// -// delegate: ItemDelegate -// { -// width: supportExtruderCombobox.width - 2 * UM.Theme.getSize("default_lining").width -// height: supportExtruderCombobox.height -// highlighted: supportExtruderCombobox.highlightedIndex == index -// -// contentItem: UM.Label -// { -// anchors.fill: parent -// anchors.leftMargin: UM.Theme.getSize("setting_unit_margin").width -// anchors.rightMargin: UM.Theme.getSize("setting_unit_margin").width -// -// text: model.name -// color: model.enabled ? UM.Theme.getColor("setting_control_text"): UM.Theme.getColor("action_button_disabled_text") -// -// elide: Text.ElideRight -// rightPadding: swatch.width + UM.Theme.getSize("setting_unit_margin").width -// -// background: Rectangle -// { -// id: swatch -// height: Math.round(parent.height / 2) -// width: height -// radius: Math.round(width / 2) -// anchors.right: parent.right -// anchors.verticalCenter: parent.verticalCenter -// anchors.rightMargin: UM.Theme.getSize("thin_margin").width -// -// color: supportExtruderCombobox.model.getItem(index).color -// } -// } -// -// background: Rectangle -// { -// color: parent.highlighted ? UM.Theme.getColor("setting_control_highlight") : "transparent" -// border.color: parent.highlighted ? UM.Theme.getColor("setting_control_border_highlight") : "transparent" -// } -// } -// } }, RecommendedSettingItem diff --git a/resources/qml/Widgets/ExtruderSelectorBar.qml b/resources/qml/Widgets/ExtruderSelectorBar.qml index 7ac4101ed8..63d9ca9da4 100644 --- a/resources/qml/Widgets/ExtruderSelectorBar.qml +++ b/resources/qml/Widgets/ExtruderSelectorBar.qml @@ -8,11 +8,15 @@ import Cura 1.5 as Cura Row { id: extruderSelectionBar - property alias model: extruderButtonRepeater.model - spacing: 0 width: parent.width height: childrenRect.height + spacing: 0 + + property alias model: extruderButtonRepeater.model + property int selectedIndex: 0 + function onClickExtruder(index) {} + Repeater { @@ -24,16 +28,15 @@ Row const maximum_width = Math.floor(extruderSelectionBar.width / extruderButtonRepeater.count); return Math.min(UM.Theme.getSize("large_button").width, maximum_width); } - height: childrenRect.height Cura.ExtruderButton { extruder: model - isTopElement: extrudersModel.getItem(0).id == model.id - isBottomElement: extrudersModel.getItem(extrudersModel.rowCount() - 1).id == model.id + checked: extruder.index == selectedIndex iconScale: 0.6 buttonSize: UM.Theme.getSize("large_button").width + onClicked: extruder.enabled && onClickExtruder(extruder.index) } } } From d9a2a3f5b754a70e4d55ebadcf87a18ffc267904 Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Mon, 28 Nov 2022 16:39:23 +0100 Subject: [PATCH 12/82] cleanup CURA-9793 --- .../Recommended/RecommendedSupportSelector.qml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedSupportSelector.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedSupportSelector.qml index 4e8ac406dc..8f236ddf4c 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedSupportSelector.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedSupportSelector.qml @@ -52,10 +52,10 @@ RecommendedSettingSection storeIndex: 0 } - //Replace this with the Extruder selector contents: [ RecommendedSettingItem { + Layout.preferredHeight: childrenRect.height settingName: catalog.i18nc("@action:label", "Print with") settingControl: Cura.ExtruderSelectorBar { @@ -68,7 +68,6 @@ RecommendedSettingSection } } - Layout.preferredHeight: childrenRect.height }, RecommendedSettingItem From 261adf06e72a2dbebd6f621c36b7cf95e55399c5 Mon Sep 17 00:00:00 2001 From: "c.lamboo" Date: Tue, 29 Nov 2022 10:32:47 +0100 Subject: [PATCH 13/82] Place `InfillSlider` in sperate file CURA-9793 --- .../Recommended/InfillSlider.qml | 116 +++++++++++++++ .../RecommendedStrengthSelector.qml | 133 +----------------- 2 files changed, 117 insertions(+), 132 deletions(-) create mode 100644 resources/qml/PrintSetupSelector/Recommended/InfillSlider.qml diff --git a/resources/qml/PrintSetupSelector/Recommended/InfillSlider.qml b/resources/qml/PrintSetupSelector/Recommended/InfillSlider.qml new file mode 100644 index 0000000000..cadbd61122 --- /dev/null +++ b/resources/qml/PrintSetupSelector/Recommended/InfillSlider.qml @@ -0,0 +1,116 @@ +// Copyright (c) 2022 UltiMaker +// Cura is released under the terms of the LGPLv3 or higher. + +import QtQuick 2.7 +import QtQuick.Controls 2.15 + +import UM 1.5 as UM +import Cura 1.0 as Cura +import QtQuick.Layouts 1.3 + +RowLayout +{ + height: childrenRect.height + spacing: UM.Theme.getSize("default_margin").width + + anchors + { + left: infillRowTitle.right + right: parent.right + verticalCenter: infillRowTitle.verticalCenter + } + + UM.Label { Layout.fillWidth: false; text: "0" } + + Slider + { + id: infillSlider + Layout.fillWidth: true + + width: parent.width + + from: 0; to: 100; stepSize: 1 + + // disable slider when gradual support is enabled + enabled: parseInt(infillSteps.properties.value) == 0 + + // set initial value from stack + value: parseInt(infillDensity.properties.value) + + //Draw line + background: Rectangle + { + id: backgroundLine + height: UM.Theme.getSize("print_setup_slider_groove").height + width: parent.width - UM.Theme.getSize("print_setup_slider_handle").width + anchors.horizontalCenter: parent.horizontalCenter + anchors.verticalCenter: parent.verticalCenter + color: UM.Theme.getColor("lining") + + Repeater + { + id: repeater + anchors.fill: parent + model: 11 + + Rectangle + { + color: UM.Theme.getColor("lining") + implicitWidth: UM.Theme.getSize("print_setup_slider_tickmarks").width + implicitHeight: UM.Theme.getSize("print_setup_slider_tickmarks").height + anchors.verticalCenter: parent.verticalCenter + + x: Math.round(backgroundLine.width / (repeater.count - 1) * index - width / 2) + + radius: Math.round(width / 2) + } + } + } + + handle: Rectangle + { + id: handleButton + x: infillSlider.leftPadding + infillSlider.visualPosition * (infillSlider.availableWidth - width) + anchors.verticalCenter: parent.verticalCenter + implicitWidth: UM.Theme.getSize("print_setup_slider_handle").width + implicitHeight: UM.Theme.getSize("print_setup_slider_handle").height + radius: Math.round(width / 2) + color: UM.Theme.getColor("main_background") + border.color: UM.Theme.getColor("primary") + border.width: UM.Theme.getSize("wide_lining").height + } + + Connections + { + target: infillSlider + function onValueChanged() + { + // Work around, the `infillDensity.properties.value` is initially `undefined`. As + // `parseInt(infillDensity.properties.value)` is parsed as 0 and is initially set as + // the slider value. By setting this 0 value an update is triggered setting the actual + // infill value to 0. + if (isNaN(parseInt(infillDensity.properties.value))) + { + return; + } + + // Don't update if the setting value, if the slider has the same value + if (parseInt(infillDensity.properties.value) == infillSlider.value) + { + return; + } + + // Round the slider value to the nearest multiple of 10 (simulate step size of 10) + const roundedSliderValue = Math.round(infillSlider.value / 10) * 10; + + // Update the slider value to represent the rounded value + infillSlider.value = roundedSliderValue; + + Cura.MachineManager.setSettingForAllExtruders("infill_sparse_density", "value", roundedSliderValue) + Cura.MachineManager.resetSettingForAllExtruders("infill_line_distance") + } + } + } + + UM.Label { Layout.fillWidth: false; text: "100" } +} diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedStrengthSelector.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedStrengthSelector.qml index d0914e8813..75beb023ee 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedStrengthSelector.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedStrengthSelector.qml @@ -6,7 +6,6 @@ import QtQuick.Controls 2.15 import UM 1.5 as UM import Cura 1.0 as Cura -import QtQuick.Layouts 1.3 // @@ -52,24 +51,6 @@ Item } } - // We use a binding to make sure that after manually setting infillSlider.value it is still bound to the property provider - Binding - { - target: infillSlider - property: "value" - value: { - // The infill slider has a max value of 100. When it is given a value > 100 onValueChanged updates the setting to be 100. - // When changing to an intent with infillDensity > 100, it would always be clamped to 100. - // This will force the slider to ignore the first onValueChanged for values > 100 so higher values can be set. - const density = parseInt(infillDensity.properties.value) - if (density > 100) { - infillSlider.ignoreValueChange = true - } - - return density - } - } - // Here are the elements that are shown in the left column Cura.IconWithText { @@ -84,122 +65,10 @@ Item tooltipText: catalog.i18nc("@label", "Gradual infill will gradually increase the amount of infill towards the top.") } - RowLayout + InfillSlider { id: infillSliderContainer height: childrenRect.height - - spacing: UM.Theme.getSize("default_margin").width - - anchors - { - left: infillRowTitle.right - right: parent.right - verticalCenter: infillRowTitle.verticalCenter - } - - UM.Label { Layout.fillWidth: false; text: "0" } - - Slider - { - id: infillSlider - Layout.fillWidth: true - - property var ignoreValueChange: false - - width: parent.width - height: childrenRect.height - - from: 0; to: 100; stepSize: 1 - - // disable slider when gradual support is enabled - enabled: parseInt(infillSteps.properties.value) == 0 - - // set initial value from stack - value: parseInt(infillDensity.properties.value) - - //Draw line - background: Rectangle - { - id: backgroundLine - height: UM.Theme.getSize("print_setup_slider_groove").height - width: parent.width - UM.Theme.getSize("print_setup_slider_handle").width - anchors.horizontalCenter: parent.horizontalCenter - anchors.verticalCenter: parent.verticalCenter - color: UM.Theme.getColor("lining") - - Repeater - { - id: repeater - anchors.fill: parent - model: 11 - - Rectangle - { - color: UM.Theme.getColor("lining") - implicitWidth: UM.Theme.getSize("print_setup_slider_tickmarks").width - implicitHeight: UM.Theme.getSize("print_setup_slider_tickmarks").height - anchors.verticalCenter: parent.verticalCenter - - x: Math.round(backgroundLine.width / (repeater.count - 1) * index - width / 2) - - radius: Math.round(width / 2) - } - } - } - - handle: Rectangle - { - id: handleButton - x: infillSlider.leftPadding + infillSlider.visualPosition * (infillSlider.availableWidth - width) - anchors.verticalCenter: parent.verticalCenter - implicitWidth: UM.Theme.getSize("print_setup_slider_handle").width - implicitHeight: UM.Theme.getSize("print_setup_slider_handle").height - radius: Math.round(width / 2) - color: UM.Theme.getColor("main_background") - border.color: UM.Theme.getColor("primary") - border.width: UM.Theme.getSize("wide_lining").height - } - - Connections - { - target: infillSlider - function onValueChanged() - { - if (infillSlider.ignoreValueChange) - { - infillSlider.ignoreValueChange = false - return - } - - // Don't update if the setting value, if the slider has the same value - if (parseInt(infillDensity.properties.value) == infillSlider.value) - { - return - } - - // Round the slider value to the nearest multiple of 10 (simulate step size of 10) - var roundedSliderValue = Math.round(infillSlider.value / 10) * 10 - - // Update the slider value to represent the rounded value - infillSlider.value = roundedSliderValue - - // Update value only if the Recommended mode is Active, - // Otherwise if I change the value in the Custom mode the Recommended view will try to repeat - // same operation - const active_mode = UM.Preferences.getValue("cura/active_mode") - - if (visible // Workaround: 'visible' is checked because on startup in Windows it spuriously gets an 'onValueChanged' with value '0' if this isn't checked. - && (active_mode == 0 || active_mode == "simple")) - { - Cura.MachineManager.setSettingForAllExtruders("infill_sparse_density", "value", roundedSliderValue) - Cura.MachineManager.resetSettingForAllExtruders("infill_line_distance") - } - } - } - } - - UM.Label { Layout.fillWidth: false; text: "100" } } // Gradual Support Infill Checkbox From f4e7829e0b011fe5a40aec96e7895fe4c45661dc Mon Sep 17 00:00:00 2001 From: "c.lamboo" Date: Tue, 29 Nov 2022 13:12:11 +0100 Subject: [PATCH 14/82] Remove infill icon changing density on change slider Suggestion from @lorenzoromagnoli CURA-9793 --- .../RecommendedStrengthSelector.qml | 33 ------------------- 1 file changed, 33 deletions(-) diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedStrengthSelector.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedStrengthSelector.qml index 75beb023ee..be4b0dbf0b 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedStrengthSelector.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedStrengthSelector.qml @@ -18,39 +18,6 @@ Item property real labelColumnWidth: Math.round(width / 3) - // Create a binding to update the icon when the infill density changes - Binding - { - target: infillRowTitle - property: "source" - value: - { - const infill_steps = parseInt(infillSteps.properties.value); - if (infill_steps != 0) - { - return UM.Theme.getIcon("InfillGradual") - } - - const density = parseInt(infillDensity.properties.value) - if (density == 0) - { - return UM.Theme.getIcon("Infill0"); - } - else if (density < 40) - { - return UM.Theme.getIcon("Infill3"); - } - else if (density < 90) - { - return UM.Theme.getIcon("Infill2"); - } - else - { - return UM.Theme.getIcon("Infill100"); - } - } - } - // Here are the elements that are shown in the left column Cura.IconWithText { From a470a6c3336b7207ffc7ff41f91931179ad16a51 Mon Sep 17 00:00:00 2001 From: "c.lamboo" Date: Tue, 29 Nov 2022 14:37:45 +0100 Subject: [PATCH 15/82] Add indicator arrow to slider CURA-9793 --- .../Recommended/InfillSlider.qml | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/resources/qml/PrintSetupSelector/Recommended/InfillSlider.qml b/resources/qml/PrintSetupSelector/Recommended/InfillSlider.qml index cadbd61122..1796ae7ea1 100644 --- a/resources/qml/PrintSetupSelector/Recommended/InfillSlider.qml +++ b/resources/qml/PrintSetupSelector/Recommended/InfillSlider.qml @@ -80,6 +80,26 @@ RowLayout border.width: UM.Theme.getSize("wide_lining").height } + UM.PointingRectangle + { + arrowSize: UM.Theme.getSize("button_tooltip_arrow").width + width: childrenRect.width + height: childrenRect.height + target: Qt.point(handleButton.x + handleButton.width / 2, handleButton.y + handleButton.height / 2) + x: handleButton.x - width / 2 + handleButton.width / 2 + y: handleButton.y - height - UM.Theme.getSize("button_tooltip_arrow").height - UM.Theme.getSize("narrow_margin").height + color: UM.Theme.getColor("tooltip"); + + UM.Label + { + text: `${infillSlider.value}%` + horizontalAlignment: TextInput.AlignHCenter + leftPadding: UM.Theme.getSize("narrow_margin").width + rightPadding: UM.Theme.getSize("narrow_margin").width + color: UM.Theme.getColor("tooltip_text"); + } + } + Connections { target: infillSlider From 0fc4773db38a744c8148f79a950380e31d71dcde Mon Sep 17 00:00:00 2001 From: "c.lamboo" Date: Tue, 29 Nov 2022 14:56:15 +0100 Subject: [PATCH 16/82] Round possible fractional positional values CURA-9793 --- resources/qml/PrintSetupSelector/Recommended/InfillSlider.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/qml/PrintSetupSelector/Recommended/InfillSlider.qml b/resources/qml/PrintSetupSelector/Recommended/InfillSlider.qml index 1796ae7ea1..6cde19c2a9 100644 --- a/resources/qml/PrintSetupSelector/Recommended/InfillSlider.qml +++ b/resources/qml/PrintSetupSelector/Recommended/InfillSlider.qml @@ -86,7 +86,7 @@ RowLayout width: childrenRect.width height: childrenRect.height target: Qt.point(handleButton.x + handleButton.width / 2, handleButton.y + handleButton.height / 2) - x: handleButton.x - width / 2 + handleButton.width / 2 + x: handleButton.x + Math.round((handleButton.width - width) / 2) y: handleButton.y - height - UM.Theme.getSize("button_tooltip_arrow").height - UM.Theme.getSize("narrow_margin").height color: UM.Theme.getColor("tooltip"); From b53c8aac5499026392297d67a397b5d4cf60c6a2 Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Tue, 29 Nov 2022 16:06:55 +0100 Subject: [PATCH 17/82] Add single setting update ComboBox CURA-9793 --- .../RecommendedSupportSelector.qml | 14 +++-- .../qml/Widgets/SingleSettingComboBox.qml | 62 +++++++++++++++++++ resources/qml/qmldir | 1 + 3 files changed, 72 insertions(+), 5 deletions(-) create mode 100644 resources/qml/Widgets/SingleSettingComboBox.qml diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedSupportSelector.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedSupportSelector.qml index 8f236ddf4c..3ff2cc0501 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedSupportSelector.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedSupportSelector.qml @@ -6,7 +6,7 @@ import QtQuick.Controls 2.3 import QtQuick.Layouts 1.3 import UM 1.5 as UM -import Cura 1.6 as Cura +import Cura 1.7 as Cura RecommendedSettingSection @@ -60,7 +60,7 @@ RecommendedSettingSection settingControl: Cura.ExtruderSelectorBar { model: extruderModel - selectedIndex: (supportExtruderNr.properties.value !== undefined) ? supportExtruderNr.properties.value : 0 + selectedIndex: supportExtruderNr.properties.value !== undefined ? supportExtruderNr.properties.value : 0 function onClickExtruder(index) { forceActiveFocus(); @@ -73,9 +73,13 @@ RecommendedSettingSection RecommendedSettingItem { settingName: catalog.i18nc("@action:label", "Placement") - settingControl: Rectangle { color: "green"; width: 50; height:50 } + + settingControl: Cura.SingleSettingComboBox + { + width: parent.width + height: UM.Theme.getSize("combobox").height + settingName: "support_type" + } } ] - - } diff --git a/resources/qml/Widgets/SingleSettingComboBox.qml b/resources/qml/Widgets/SingleSettingComboBox.qml new file mode 100644 index 0000000000..c79ff591e8 --- /dev/null +++ b/resources/qml/Widgets/SingleSettingComboBox.qml @@ -0,0 +1,62 @@ +// Copyright (c) 2022 UltiMaker B.V. +// Cura is released under the terms of the LGPLv3 or higher. + +import QtQuick 2.10 +import QtQuick.Controls 2.3 +import QtQuick.Layouts 1.3 + +import UM 1.5 as UM +import Cura 1.7 as Cura + +// This ComboBox allows changing of a single setting. Only the setting name has to be passed in to "settingName". +// All of the setting updating logic is handled by this component. +// This uses the "options" value of a setting to populate the drop down. This will only work for settings with "options" +Cura.ComboBox { + textRole: "text" + property alias settingName: propertyProvider.key + + model: ListModel { + id: comboboxModel + + // The propertyProvider has not loaded the setting when this components onComplete triggers. Populating the model + // is defered until propertyProvider signals "onIsValueUsedChanged". + function updateModel() + { + clear() + + if(!propertyProvider.properties.options) // No options have been loaded yet to populate combobox + { + return + } + + for (var i = 0; i < propertyProvider.properties["options"].keys().length; i++) + { + var key = propertyProvider.properties["options"].keys()[i] + var value = propertyProvider.properties["options"][key] + comboboxModel.append({ text: value, code: key}) + + if (propertyProvider.properties.value == key) + { + // The combobox is cleared after each value change so the currentIndex must be set each time. + currentIndex = i + } + } + } + } + + property UM.SettingPropertyProvider propertyProvider: UM.SettingPropertyProvider + { + id: propertyProvider + containerStack: Cura.MachineManager.activeMachine + watchedProperties: [ "value" , "options"] + } + + Connections + { + target: propertyProvider + function onContainerStackChanged() { comboboxModel.updateModel() } + function onIsValueUsedChanged() { comboboxModel.updateModel() } + } + + onCurrentIndexChanged: propertyProvider.setPropertyValue("value", comboboxModel.get(currentIndex).code) +} diff --git a/resources/qml/qmldir b/resources/qml/qmldir index 1a6739f5fb..da90f32145 100644 --- a/resources/qml/qmldir +++ b/resources/qml/qmldir @@ -40,6 +40,7 @@ MenuItem 1.0 MenuItem.qml MenuSeparator 1.0 MenuSeparator.qml ExtruderSelectorBar 1.6 ExtruderSelectorBar.qml ExtruderButton 1.6 ExtruderButton.qml +SingleSettingComboBox 1.7 SingleSettingComboBox.qml # Cura/MachineSettings From 788ab7da1b61d5d002ba35914f57b5cc971d2fc9 Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Tue, 29 Nov 2022 16:16:32 +0100 Subject: [PATCH 18/82] Fix broken combobox CURA-9793 --- .../MachineSettings/ComboBoxWithOptions.qml | 37 ++++++++++++++----- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/resources/qml/MachineSettings/ComboBoxWithOptions.qml b/resources/qml/MachineSettings/ComboBoxWithOptions.qml index 4ff7cf7092..9f5f89dde1 100644 --- a/resources/qml/MachineSettings/ComboBoxWithOptions.qml +++ b/resources/qml/MachineSettings/ComboBoxWithOptions.qml @@ -68,20 +68,37 @@ UM.TooltipArea function updateModel() { clear() - // Options come in as a string-representation of an OrderedDict - if(propertyProvider.properties.options) + + if(!propertyProvider.properties.options) { - var options = propertyProvider.properties.options.match(/^OrderedDict\(\[\((.*)\)\]\)$/); - if(options) + return + } + + for (var i = 0; i < propertyProvider.properties["options"].keys().length; i++) + { + var key = propertyProvider.properties["options"].keys()[i] + var value = propertyProvider.properties["options"][key] + append({ text: value, code: key}) + + if (propertyProvider.properties.value == key) { - options = options[1].split("), ("); - for(var i = 0; i < options.length; i++) - { - var option = options[i].substring(1, options[i].length - 1).split("', '"); - append({ text: option[1], value: option[0] }); - } + currentIndex = i } } +// // Options come in as a string-representation of an OrderedDict +// if(propertyProvider.properties.options) +// { +// var options = propertyProvider.properties.options.match(/^OrderedDict\(\[\((.*)\)\]\)$/); +// if(options) +// { +// options = options[1].split("), ("); +// for(var i = 0; i < options.length; i++) +// { +// var option = options[i].substring(1, options[i].length - 1).split("', '"); +// append({ text: option[1], value: option[0] }); +// } +// } +// } } Component.onCompleted: updateModel() From c240833868078fc83866d26115a2f04a888ee8be Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Tue, 29 Nov 2022 16:23:49 +0100 Subject: [PATCH 19/82] Add Support type settings CURA-9793 --- .../Recommended/RecommendedSupportSelector.qml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedSupportSelector.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedSupportSelector.qml index 3ff2cc0501..359de13697 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedSupportSelector.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedSupportSelector.qml @@ -53,6 +53,17 @@ RecommendedSettingSection } contents: [ + RecommendedSettingItem + { + settingName: catalog.i18nc("@action:label", "Support Type") + + settingControl: Cura.SingleSettingComboBox + { + width: parent.width + height: UM.Theme.getSize("combobox").height + settingName: "support_structure" + } + }, RecommendedSettingItem { Layout.preferredHeight: childrenRect.height From c356b9d46f7e20dc92492b6dd3fd81dd650be133 Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Tue, 29 Nov 2022 16:59:27 +0100 Subject: [PATCH 20/82] Rename ExtruderSelectorBar -> SingleSettingExtruderSelectorBar to be inline with new single setting widgets. Move common functionality into SingleSettingExtruderSelectorBar Add adhesion settings CURA-9793 --- .../RecommendedAdhesionSelector.qml | 21 +++--- .../RecommendedSupportSelector.qml | 18 +----- resources/qml/Widgets/ExtruderSelectorBar.qml | 43 ------------- .../qml/Widgets/SingleSettingComboBox.qml | 2 +- .../SingleSettingExtruderSelectorBar.qml | 64 +++++++++++++++++++ resources/qml/qmldir | 6 +- 6 files changed, 79 insertions(+), 75 deletions(-) delete mode 100644 resources/qml/Widgets/ExtruderSelectorBar.qml create mode 100644 resources/qml/Widgets/SingleSettingExtruderSelectorBar.qml diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedAdhesionSelector.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedAdhesionSelector.qml index 4eaf4f17ce..3ffb71e707 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedAdhesionSelector.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedAdhesionSelector.qml @@ -1,10 +1,11 @@ -// Copyright (c) 2022 Ultimaker B.V. +// Copyright (c) 2022 UltiMaker B.V. // Cura is released under the terms of the LGPLv3 or higher. import QtQuick 2.7 +import QtQuick.Layouts 1.3 import UM 1.5 as UM -import Cura 1.0 as Cura +import Cura 1.7 as Cura RecommendedSettingSection @@ -32,16 +33,12 @@ RecommendedSettingSection curaRecommendedMode.setAdhesion(state) } - contents: RecommendedSettingItem - { - settingName: catalog.i18nc("@action:label", "Print with") - - settingControl: Rectangle + contents: [ + RecommendedSettingItem { - width: 20 - height: 20 - color: Qt.rgba(1, 0, 0, .5) + Layout.preferredHeight: childrenRect.height + settingName: catalog.i18nc("@action:label", "Print with") + settingControl: Cura.SingleSettingExtruderSelectorBar { extruderSettingName: "adhesion_extruder_nr" } } - } - + ] } diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedSupportSelector.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedSupportSelector.qml index 359de13697..2a2ec08c70 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedSupportSelector.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedSupportSelector.qml @@ -1,4 +1,4 @@ -// Copyright (c) 2022 Ultimaker B.V. +// Copyright (c) 2022 UltiMaker B.V. // Cura is released under the terms of the LGPLv3 or higher. import QtQuick 2.10 @@ -24,9 +24,6 @@ RecommendedSettingSection supportEnabled.setPropertyValue("value", state) } - property var extruderModel: CuraApplication.getExtrudersModel() - - property UM.SettingPropertyProvider supportEnabled: UM.SettingPropertyProvider { id: supportEnabled @@ -68,19 +65,8 @@ RecommendedSettingSection { Layout.preferredHeight: childrenRect.height settingName: catalog.i18nc("@action:label", "Print with") - settingControl: Cura.ExtruderSelectorBar - { - model: extruderModel - selectedIndex: supportExtruderNr.properties.value !== undefined ? supportExtruderNr.properties.value : 0 - function onClickExtruder(index) - { - forceActiveFocus(); - supportExtruderNr.setPropertyValue("value", index); - } - } - + settingControl: Cura.SingleSettingExtruderSelectorBar { extruderSettingName: "support_extruder_nr" } }, - RecommendedSettingItem { settingName: catalog.i18nc("@action:label", "Placement") diff --git a/resources/qml/Widgets/ExtruderSelectorBar.qml b/resources/qml/Widgets/ExtruderSelectorBar.qml deleted file mode 100644 index 63d9ca9da4..0000000000 --- a/resources/qml/Widgets/ExtruderSelectorBar.qml +++ /dev/null @@ -1,43 +0,0 @@ -import QtQuick 2.12 -import QtQuick.Controls 2.12 -import QtQuick.Layouts 1.3 - -import UM 1.5 as UM -import Cura 1.5 as Cura - -Row -{ - id: extruderSelectionBar - - width: parent.width - height: childrenRect.height - spacing: 0 - - property alias model: extruderButtonRepeater.model - property int selectedIndex: 0 - function onClickExtruder(index) {} - - - Repeater - { - id: extruderButtonRepeater - - delegate: Item - { - width: { - const maximum_width = Math.floor(extruderSelectionBar.width / extruderButtonRepeater.count); - return Math.min(UM.Theme.getSize("large_button").width, maximum_width); - } - height: childrenRect.height - - Cura.ExtruderButton - { - extruder: model - checked: extruder.index == selectedIndex - iconScale: 0.6 - buttonSize: UM.Theme.getSize("large_button").width - onClicked: extruder.enabled && onClickExtruder(extruder.index) - } - } - } -} diff --git a/resources/qml/Widgets/SingleSettingComboBox.qml b/resources/qml/Widgets/SingleSettingComboBox.qml index c79ff591e8..be0b7782f0 100644 --- a/resources/qml/Widgets/SingleSettingComboBox.qml +++ b/resources/qml/Widgets/SingleSettingComboBox.qml @@ -19,7 +19,7 @@ Cura.ComboBox { id: comboboxModel // The propertyProvider has not loaded the setting when this components onComplete triggers. Populating the model - // is defered until propertyProvider signals "onIsValueUsedChanged". + // is defered until propertyProvider signals "onIsValueUsedChanged". The defered upate is triggered with this function. function updateModel() { clear() diff --git a/resources/qml/Widgets/SingleSettingExtruderSelectorBar.qml b/resources/qml/Widgets/SingleSettingExtruderSelectorBar.qml new file mode 100644 index 0000000000..c42b525f6b --- /dev/null +++ b/resources/qml/Widgets/SingleSettingExtruderSelectorBar.qml @@ -0,0 +1,64 @@ +import QtQuick 2.12 +import QtQuick.Controls 2.12 +import QtQuick.Layouts 1.3 + +import UM 1.5 as UM +import Cura 1.5 as Cura + +// This component displays a row of extruder icons, clicking on the extruder will update the setting passed to "settingName" +// with the index of that extruder. +// This will only work for settings that take an extruder index. +Row +{ + id: extruderSelectionBar + + width: parent.width + height: childrenRect.height + spacing: 0 + + property int selectedIndex: extruderSettingProvider.properties.value !== undefined ? extruderSettingProvider.properties.value : 0 + property alias model: extruderButtonRepeater.model + property alias extruderSettingName: extruderSettingProvider.key + property alias containerStack: extruderSettingProvider.containerStack + + property UM.SettingPropertyProvider extruderSettingProvider: UM.SettingPropertyProvider + { + id: extruderSettingProvider + containerStack: Cura.MachineManager.activeMachine + watchedProperties: [ "value" ] + storeIndex: 0 + } + + function onClickExtruder(index) + { + forceActiveFocus(); + extruderSettingProvider.setPropertyValue("value", index); + } + + + Repeater + { + id: extruderButtonRepeater + + model: CuraApplication.getExtrudersModel() + + delegate: Item + { + width: { + // This will "squish" the extruder buttons together when the fill up the horizontal space + const maximum_width = Math.floor(extruderSelectionBar.width / extruderButtonRepeater.count); + return Math.min(UM.Theme.getSize("large_button").width, maximum_width); + } + height: childrenRect.height + + Cura.ExtruderButton + { + extruder: model + checked: extruder.index == selectedIndex + iconScale: 0.6 + buttonSize: UM.Theme.getSize("large_button").width + onClicked: extruder.enabled && onClickExtruder(extruder.index) + } + } + } +} diff --git a/resources/qml/qmldir b/resources/qml/qmldir index da90f32145..4616b8c268 100644 --- a/resources/qml/qmldir +++ b/resources/qml/qmldir @@ -38,9 +38,9 @@ ScrollView 1.0 ScrollView.qml Menu 1.0 Menu.qml MenuItem 1.0 MenuItem.qml MenuSeparator 1.0 MenuSeparator.qml -ExtruderSelectorBar 1.6 ExtruderSelectorBar.qml -ExtruderButton 1.6 ExtruderButton.qml -SingleSettingComboBox 1.7 SingleSettingComboBox.qml +SingleSettingExtruderSelectorBar 1.7 SingleSettingExtruderSelectorBar.qml +ExtruderButton 1.7 ExtruderButton.qml +SingleSettingComboBox 1.7 SingleSettingComboBox.qml # Cura/MachineSettings From 1224f076c3971ca83b57037f21e501cee656cec1 Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Tue, 29 Nov 2022 17:20:34 +0100 Subject: [PATCH 21/82] Fix switch alignment CURA-9793 --- .../Recommended/RecommendedSettingSection.qml | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedSettingSection.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedSettingSection.qml index ac0c7fbccf..71c34737f5 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedSettingSection.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedSettingSection.qml @@ -48,16 +48,6 @@ Item font: UM.Theme.getFont("medium_bold") } - UM.Switch - { - id: enableSectionSwitch - anchors.left: sectionTitle.right - anchors.verticalCenter: parent.verticalCenter - visible: false - - onClicked: onEnableSectionChanged(enableSectionSwitch.checked) - } - MouseArea { id: tooltipMouseArea @@ -71,6 +61,18 @@ Item } + UM.Switch + { + id: enableSectionSwitch + anchors.left: parent.left + // These numbers come from the IconWithText in RecommendedSettingSection. + anchors.leftMargin: leftColumnWidth + UM.Theme.getSize("medium_button_icon").width + UM.Theme.getSize("thick_margin").width - (2 * UM.Theme.getSize("thick_lining").width) + anchors.verticalCenter: sectionHeader.verticalCenter + visible: false + + onClicked: onEnableSectionChanged(enableSectionSwitch.checked) + } + ColumnLayout { id: settingColumn From f99f1a4528aedddbb081e5c40a04595f7dc77106 Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Tue, 29 Nov 2022 17:49:26 +0100 Subject: [PATCH 22/82] Stop logging spam by checking before setting property. CURA-9793 --- resources/qml/Widgets/SingleSettingComboBox.qml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/resources/qml/Widgets/SingleSettingComboBox.qml b/resources/qml/Widgets/SingleSettingComboBox.qml index be0b7782f0..f0c43c31f7 100644 --- a/resources/qml/Widgets/SingleSettingComboBox.qml +++ b/resources/qml/Widgets/SingleSettingComboBox.qml @@ -58,5 +58,11 @@ Cura.ComboBox { function onIsValueUsedChanged() { comboboxModel.updateModel() } } - onCurrentIndexChanged: propertyProvider.setPropertyValue("value", comboboxModel.get(currentIndex).code) + onCurrentIndexChanged: + { + if (comboboxModel.get(currentIndex) && comboboxModel.get(currentIndex).code) + { + propertyProvider.setPropertyValue("value", comboboxModel.get(currentIndex).code) + } + } } From 7ba02811360abd5e03eb49356b5a182c687f034c Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Tue, 29 Nov 2022 17:50:40 +0100 Subject: [PATCH 23/82] Move required settingPropertyProvider into InfillSlider. Use new RecommendedSetting components for Strength section of recommended. CURA-9793 --- .../Recommended/InfillSlider.qml | 13 +- .../Recommended/RecommendedPrintSetup.qml | 2 - .../Recommended/RecommendedSettingItem.qml | 1 + .../RecommendedStrengthSelector.qml | 119 ++++-------------- .../cura-light/icons/default/Hammer.svg | 8 ++ 5 files changed, 45 insertions(+), 98 deletions(-) create mode 100644 resources/themes/cura-light/icons/default/Hammer.svg diff --git a/resources/qml/PrintSetupSelector/Recommended/InfillSlider.qml b/resources/qml/PrintSetupSelector/Recommended/InfillSlider.qml index 6cde19c2a9..4cc80a835f 100644 --- a/resources/qml/PrintSetupSelector/Recommended/InfillSlider.qml +++ b/resources/qml/PrintSetupSelector/Recommended/InfillSlider.qml @@ -15,9 +15,18 @@ RowLayout anchors { - left: infillRowTitle.right + left: strengthSection.right right: parent.right - verticalCenter: infillRowTitle.verticalCenter + verticalCenter: strengthSection.verticalCenter + } + + UM.SettingPropertyProvider + { + id: infillDensity + containerStackId: Cura.MachineManager.activeStackId + key: "infill_sparse_density" + watchedProperties: [ "value" ] + storeIndex: 0 } UM.Label { Layout.fillWidth: false; text: "0" } diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedPrintSetup.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedPrintSetup.qml index cf8e9e4e2a..7e25785c74 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedPrintSetup.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedPrintSetup.qml @@ -86,9 +86,7 @@ Item RecommendedStrengthSelector { width: parent.width - labelColumnWidth: parent.firstColumnWidth Layout.fillWidth: true - Layout.rightMargin: UM.Theme.getSize("default_margin").width } RecommendedSupportSelector diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedSettingItem.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedSettingItem.qml index ec777b13d6..87a95a12e8 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedSettingItem.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedSettingItem.qml @@ -18,6 +18,7 @@ Item property alias settingControl: settingContainer.children property alias settingName: settingLabel.text + property string tooltipText: "" UM.Label { diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedStrengthSelector.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedStrengthSelector.qml index be4b0dbf0b..82fcd64bb9 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedStrengthSelector.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedStrengthSelector.qml @@ -5,108 +5,39 @@ import QtQuick 2.7 import QtQuick.Controls 2.15 import UM 1.5 as UM -import Cura 1.0 as Cura +import Cura 1.7 as Cura -// -// Infill -// -Item +RecommendedSettingSection { - id: infillRow - height: childrenRect.height + id: strengthSection - property real labelColumnWidth: Math.round(width / 3) + title: catalog.i18nc("@label", "Strength") + icon: UM.Theme.getIcon("Hammer") + enableSectionVisible: false + enableSectionEnabled: false - // Here are the elements that are shown in the left column - Cura.IconWithText - { - id: infillRowTitle - anchors.top: parent.top - anchors.left: parent.left - source: UM.Theme.getIcon("Infill1") - text: `${catalog.i18nc("@label", "Infill")} (%)` - font: UM.Theme.getFont("medium") - width: labelColumnWidth - iconSize: UM.Theme.getSize("medium_button_icon").width - tooltipText: catalog.i18nc("@label", "Gradual infill will gradually increase the amount of infill towards the top.") - } - - InfillSlider - { - id: infillSliderContainer - height: childrenRect.height - } - - // Gradual Support Infill Checkbox - UM.CheckBox - { - id: enableGradualInfillCheckBox - property alias _hovered: enableGradualInfillMouseArea.containsMouse - - anchors.top: infillSliderContainer.bottom - anchors.topMargin: UM.Theme.getSize("default_margin").height - anchors.left: infillSliderContainer.left - - text: catalog.i18nc("@label", "Gradual infill") - enabled: recommendedPrintSetup.settingsEnabled - visible: infillSteps.properties.enabled == "True" - checked: parseInt(infillSteps.properties.value) > 0 - - MouseArea + contents: [ + RecommendedSettingItem { - id: enableGradualInfillMouseArea - - anchors.fill: parent - hoverEnabled: true - enabled: true - - property var previousInfillDensity: parseInt(infillDensity.properties.value) - - onClicked: + settingName: catalog.i18nc("@action:label", "Infill Density") + tooltipText: catalog.i18nc("@label", "Gradual infill will gradually increase the amount of infill towards the top.") + settingControl: InfillSlider { - // Set to 90% only when enabling gradual infill - var newInfillDensity; - if (parseInt(infillSteps.properties.value) == 0) - { - previousInfillDensity = parseInt(infillDensity.properties.value) - newInfillDensity = 90 - } else { - newInfillDensity = previousInfillDensity - } - Cura.MachineManager.setSettingForAllExtruders("infill_sparse_density", "value", String(newInfillDensity)) - - var infill_steps_value = 0 - if (parseInt(infillSteps.properties.value) == 0) - { - infill_steps_value = 5 - } - - Cura.MachineManager.setSettingForAllExtruders("gradual_infill_steps", "value", infill_steps_value) + height: UM.Theme.getSize("combobox").height + width: parent.width } + }, + RecommendedSettingItem + { + settingName: catalog.i18nc("@action:label", "Infill Pattern") - onEntered: base.showTooltip(enableGradualInfillCheckBox, Qt.point(-infillSliderContainer.x - UM.Theme.getSize("thick_margin").width, 0), - catalog.i18nc("@label", "Gradual infill will gradually increase the amount of infill towards the top.")) - - onExited: base.hideTooltip() + settingControl: Cura.SingleSettingComboBox + { + width: parent.width + height: UM.Theme.getSize("combobox").height + settingName: "infill_pattern" + } } - } - - UM.SettingPropertyProvider - { - id: infillDensity - containerStackId: Cura.MachineManager.activeStackId - key: "infill_sparse_density" - watchedProperties: [ "value" ] - storeIndex: 0 - } - - UM.SettingPropertyProvider - { - id: infillSteps - containerStackId: Cura.MachineManager.activeStackId - key: "gradual_infill_steps" - watchedProperties: ["value", "enabled"] - storeIndex: 0 - } + ] } diff --git a/resources/themes/cura-light/icons/default/Hammer.svg b/resources/themes/cura-light/icons/default/Hammer.svg new file mode 100644 index 0000000000..62823682be --- /dev/null +++ b/resources/themes/cura-light/icons/default/Hammer.svg @@ -0,0 +1,8 @@ + + + + + From 69af593d8c26e8e6f2407149f2234a17f4e71a17 Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Wed, 30 Nov 2022 11:45:27 +0100 Subject: [PATCH 24/82] Make Slider generic component in UM. Make Infill slider into generic SingleSettinSlider which will work for any setting now. Change slider theme slighly. CURA-9793 --- .../Recommended/InfillSlider.qml | 145 ------------------ .../Recommended/RecommendedSettingSection.qml | 2 +- .../RecommendedStrengthSelector.qml | 21 ++- resources/qml/Widgets/SingleSettingSlider.qml | 109 +++++++++++++ resources/qml/qmldir | 1 + resources/themes/cura-light/theme.json | 2 +- 6 files changed, 132 insertions(+), 148 deletions(-) delete mode 100644 resources/qml/PrintSetupSelector/Recommended/InfillSlider.qml create mode 100644 resources/qml/Widgets/SingleSettingSlider.qml diff --git a/resources/qml/PrintSetupSelector/Recommended/InfillSlider.qml b/resources/qml/PrintSetupSelector/Recommended/InfillSlider.qml deleted file mode 100644 index 4cc80a835f..0000000000 --- a/resources/qml/PrintSetupSelector/Recommended/InfillSlider.qml +++ /dev/null @@ -1,145 +0,0 @@ -// Copyright (c) 2022 UltiMaker -// Cura is released under the terms of the LGPLv3 or higher. - -import QtQuick 2.7 -import QtQuick.Controls 2.15 - -import UM 1.5 as UM -import Cura 1.0 as Cura -import QtQuick.Layouts 1.3 - -RowLayout -{ - height: childrenRect.height - spacing: UM.Theme.getSize("default_margin").width - - anchors - { - left: strengthSection.right - right: parent.right - verticalCenter: strengthSection.verticalCenter - } - - UM.SettingPropertyProvider - { - id: infillDensity - containerStackId: Cura.MachineManager.activeStackId - key: "infill_sparse_density" - watchedProperties: [ "value" ] - storeIndex: 0 - } - - UM.Label { Layout.fillWidth: false; text: "0" } - - Slider - { - id: infillSlider - Layout.fillWidth: true - - width: parent.width - - from: 0; to: 100; stepSize: 1 - - // disable slider when gradual support is enabled - enabled: parseInt(infillSteps.properties.value) == 0 - - // set initial value from stack - value: parseInt(infillDensity.properties.value) - - //Draw line - background: Rectangle - { - id: backgroundLine - height: UM.Theme.getSize("print_setup_slider_groove").height - width: parent.width - UM.Theme.getSize("print_setup_slider_handle").width - anchors.horizontalCenter: parent.horizontalCenter - anchors.verticalCenter: parent.verticalCenter - color: UM.Theme.getColor("lining") - - Repeater - { - id: repeater - anchors.fill: parent - model: 11 - - Rectangle - { - color: UM.Theme.getColor("lining") - implicitWidth: UM.Theme.getSize("print_setup_slider_tickmarks").width - implicitHeight: UM.Theme.getSize("print_setup_slider_tickmarks").height - anchors.verticalCenter: parent.verticalCenter - - x: Math.round(backgroundLine.width / (repeater.count - 1) * index - width / 2) - - radius: Math.round(width / 2) - } - } - } - - handle: Rectangle - { - id: handleButton - x: infillSlider.leftPadding + infillSlider.visualPosition * (infillSlider.availableWidth - width) - anchors.verticalCenter: parent.verticalCenter - implicitWidth: UM.Theme.getSize("print_setup_slider_handle").width - implicitHeight: UM.Theme.getSize("print_setup_slider_handle").height - radius: Math.round(width / 2) - color: UM.Theme.getColor("main_background") - border.color: UM.Theme.getColor("primary") - border.width: UM.Theme.getSize("wide_lining").height - } - - UM.PointingRectangle - { - arrowSize: UM.Theme.getSize("button_tooltip_arrow").width - width: childrenRect.width - height: childrenRect.height - target: Qt.point(handleButton.x + handleButton.width / 2, handleButton.y + handleButton.height / 2) - x: handleButton.x + Math.round((handleButton.width - width) / 2) - y: handleButton.y - height - UM.Theme.getSize("button_tooltip_arrow").height - UM.Theme.getSize("narrow_margin").height - color: UM.Theme.getColor("tooltip"); - - UM.Label - { - text: `${infillSlider.value}%` - horizontalAlignment: TextInput.AlignHCenter - leftPadding: UM.Theme.getSize("narrow_margin").width - rightPadding: UM.Theme.getSize("narrow_margin").width - color: UM.Theme.getColor("tooltip_text"); - } - } - - Connections - { - target: infillSlider - function onValueChanged() - { - // Work around, the `infillDensity.properties.value` is initially `undefined`. As - // `parseInt(infillDensity.properties.value)` is parsed as 0 and is initially set as - // the slider value. By setting this 0 value an update is triggered setting the actual - // infill value to 0. - if (isNaN(parseInt(infillDensity.properties.value))) - { - return; - } - - // Don't update if the setting value, if the slider has the same value - if (parseInt(infillDensity.properties.value) == infillSlider.value) - { - return; - } - - // Round the slider value to the nearest multiple of 10 (simulate step size of 10) - const roundedSliderValue = Math.round(infillSlider.value / 10) * 10; - - // Update the slider value to represent the rounded value - infillSlider.value = roundedSliderValue; - - Cura.MachineManager.setSettingForAllExtruders("infill_sparse_density", "value", roundedSliderValue) - Cura.MachineManager.resetSettingForAllExtruders("infill_line_distance") - } - } - } - - UM.Label { Layout.fillWidth: false; text: "100" } -} diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedSettingSection.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedSettingSection.qml index 71c34737f5..ac4abf4a3e 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedSettingSection.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedSettingSection.qml @@ -5,7 +5,7 @@ import QtQuick 2.10 import QtQuick.Controls 2.3 import QtQuick.Layouts 2.10 -import UM 1.6 as UM +import UM 1.7 as UM import Cura 1.7 as Cura Item diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedStrengthSelector.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedStrengthSelector.qml index 82fcd64bb9..e0136401ad 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedStrengthSelector.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedStrengthSelector.qml @@ -17,15 +17,34 @@ RecommendedSettingSection enableSectionVisible: false enableSectionEnabled: false + UM.SettingPropertyProvider + { + id: infillSteps + containerStackId: Cura.MachineManager.activeStackId + key: "gradual_infill_steps" + watchedProperties: ["value", "enabled"] + storeIndex: 0 + } + contents: [ RecommendedSettingItem { settingName: catalog.i18nc("@action:label", "Infill Density") tooltipText: catalog.i18nc("@label", "Gradual infill will gradually increase the amount of infill towards the top.") - settingControl: InfillSlider + settingControl: Cura.SingleSettingSlider { height: UM.Theme.getSize("combobox").height width: parent.width + settingName: "infill_sparse_density" + roundToNearestTen: true + // disable slider when gradual support is enabled + enabled: parseInt(infillSteps.properties.value) == 0 + + function updateSetting(value) + { + Cura.MachineManager.setSettingForAllExtruders("infill_sparse_density", "value", value) + Cura.MachineManager.resetSettingForAllExtruders("infill_line_distance") + } } }, RecommendedSettingItem diff --git a/resources/qml/Widgets/SingleSettingSlider.qml b/resources/qml/Widgets/SingleSettingSlider.qml new file mode 100644 index 0000000000..d1df835e58 --- /dev/null +++ b/resources/qml/Widgets/SingleSettingSlider.qml @@ -0,0 +1,109 @@ +// Copyright (c) 2022 UltiMaker +// Cura is released under the terms of the LGPLv3 or higher. + +import QtQuick 2.7 +import QtQuick.Controls 2.15 + +import UM 1.7 as UM +import Cura 1.7 as Cura +import QtQuick.Layouts 1.3 + +RowLayout +{ + height: childrenRect.height + spacing: UM.Theme.getSize("default_margin").width + + property alias settingName: settingPropertyProvider.key + property alias enabled: settingSlider.enabled + + property bool roundToNearestTen: false + property int maxValue: 100 + property int minValue: 0 + + anchors + { + left: strengthSection.right + right: parent.right + verticalCenter: strengthSection.verticalCenter + } + + UM.SettingPropertyProvider + { + id: settingPropertyProvider + containerStackId: Cura.MachineManager.activeStackId + watchedProperties: [ "value" ] + storeIndex: 0 + + } + + UM.Label { Layout.fillWidth: false; text: minValue } + + UM.Slider + { + id: settingSlider + Layout.fillWidth: true + + width: parent.width + + from: minValue; to: maxValue; stepSize: 1 + + // set initial value from stack + value: parseInt(settingPropertyProvider.properties.value) + + // When the slider is released trigger an update immediately. This forces the slider to snap to the rounded value. + onPressedChanged: if(!pressed) { parseValueUpdateSetting() } + } + + UM.Label { Layout.fillWidth: false; text: maxValue } + + Connections + { + target: settingPropertyProvider + function onContainerStackChanged() { updateTimer.restart() } + function onIsValueUsedChanged() { updateTimer.restart() } + } + + // Updates to the setting are delayed by interval. This stops lag caused by calling the + // parseValueUpdateSetting() function being call repeatedly while dragging the slider. + Timer + { + id: updateTimer + interval: 100 + repeat: false + onTriggered: + { + parseValueUpdateSetting() + } + } + + function parseValueUpdateSetting() + { + // Work around, the `settingPropertyProvider.properties.value` is initially `undefined`. As + // `parseInt(settingPropertyProvider.properties.value)` is parsed as 0 and is initially set as + // the slider value. By setting this 0 value an update is triggered setting the actual + // sitting value to 0. + if (isNaN(parseInt(settingPropertyProvider.properties.value))) + { + return; + } + + // Don't update if the setting value, if the slider has the same value + if (parseInt(settingPropertyProvider.properties.value) == settingSlider.value) + { + return; + } + + // Round the slider value to the nearest multiple of 10 (simulate step size of 10) + const roundedSliderValue = roundToNearestTen ? Math.round(settingSlider.value / 10) * 10 : Math.round(settingSlider.value) + + // Update the slider value to represent the rounded value + settingSlider.value = roundedSliderValue; + + updateSetting(roundedSliderValue); + } + + // Override this function to update a setting differently + function updateSetting(value) { + propertyProvider.setPropertyValue("value", value) + } +} diff --git a/resources/qml/qmldir b/resources/qml/qmldir index 4616b8c268..dd594d8583 100644 --- a/resources/qml/qmldir +++ b/resources/qml/qmldir @@ -41,6 +41,7 @@ MenuSeparator 1.0 MenuSeparator.qml SingleSettingExtruderSelectorBar 1.7 SingleSettingExtruderSelectorBar.qml ExtruderButton 1.7 ExtruderButton.qml SingleSettingComboBox 1.7 SingleSettingComboBox.qml +SingleSettingSlider 1.7 SingleSettingSlider.qml # Cura/MachineSettings diff --git a/resources/themes/cura-light/theme.json b/resources/themes/cura-light/theme.json index d1ba93bef1..45db2670d1 100644 --- a/resources/themes/cura-light/theme.json +++ b/resources/themes/cura-light/theme.json @@ -492,7 +492,7 @@ "print_setup_extruder_box": [0.0, 6.0], "print_setup_slider_groove": [0.16, 0.16], "print_setup_slider_handle": [1.3, 1.3], - "print_setup_slider_tickmarks": [0.5, 0.5], + "print_setup_slider_tickmarks": [0.3, 0.3], "print_setup_big_item": [28, 2.5], "print_setup_icon": [1.2, 1.2], "drag_icon": [1.416, 0.25], From 4f8943412f1e4ea6b5d217272a54b9c8b0aebca2 Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Wed, 30 Nov 2022 12:10:50 +0100 Subject: [PATCH 25/82] Remove unused anchors CURA-9793 --- resources/qml/Widgets/SingleSettingSlider.qml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/resources/qml/Widgets/SingleSettingSlider.qml b/resources/qml/Widgets/SingleSettingSlider.qml index d1df835e58..8baccfefe7 100644 --- a/resources/qml/Widgets/SingleSettingSlider.qml +++ b/resources/qml/Widgets/SingleSettingSlider.qml @@ -20,13 +20,6 @@ RowLayout property int maxValue: 100 property int minValue: 0 - anchors - { - left: strengthSection.right - right: parent.right - verticalCenter: strengthSection.verticalCenter - } - UM.SettingPropertyProvider { id: settingPropertyProvider From dbf27a432f6aa8d77a567aabd31e7ff9f1a74c11 Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Wed, 30 Nov 2022 12:12:41 +0100 Subject: [PATCH 26/82] Change confusing naming of section enable switch. CURA-9793 --- .../Recommended/RecommendedAdhesionSelector.qml | 6 +++--- .../Recommended/RecommendedSettingSection.qml | 6 +++--- .../Recommended/RecommendedStrengthSelector.qml | 4 ++-- .../Recommended/RecommendedSupportSelector.qml | 6 +++--- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedAdhesionSelector.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedAdhesionSelector.qml index 3ffb71e707..b73faa543f 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedAdhesionSelector.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedAdhesionSelector.qml @@ -14,9 +14,9 @@ RecommendedSettingSection title: catalog.i18nc("@label", "Adhesion") icon: UM.Theme.getIcon("Adhesion") - enableSectionVisible: platformAdhesionType.properties.enabled == "True" - enableSectionChecked: platformAdhesionType.properties.value != "skirt" && platformAdhesionType.properties.value != "none" - enableSectionEnabled: recommendedPrintSetup.settingsEnabled + enableSectionSwitchVisible: platformAdhesionType.properties.enabled == "True" + enableSectionSwitchChecked: platformAdhesionType.properties.value != "skirt" && platformAdhesionType.properties.value != "none" + enableSectionSwitchEnabled: recommendedPrintSetup.settingsEnabled property var curaRecommendedMode: Cura.RecommendedMode {} diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedSettingSection.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedSettingSection.qml index ac4abf4a3e..81cba57d0e 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedSettingSection.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedSettingSection.qml @@ -13,9 +13,9 @@ Item property alias title: sectionTitle.text property alias icon: sectionTitle.source - property alias enableSectionVisible: enableSectionSwitch.visible - property alias enableSectionChecked: enableSectionSwitch.checked - property alias enableSectionEnabled: enableSectionSwitch.enabled + property alias enableSectionSwitchVisible: enableSectionSwitch.visible + property alias enableSectionSwitchChecked: enableSectionSwitch.checked + property alias enableSectionSwitchEnabled: enableSectionSwitch.enabled property var enableSectionClicked: { return } property int leftColumnWidth: Math.floor(width * 0.35) property var toolTipText: "" diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedStrengthSelector.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedStrengthSelector.qml index e0136401ad..a80d735f59 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedStrengthSelector.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedStrengthSelector.qml @@ -14,8 +14,8 @@ RecommendedSettingSection title: catalog.i18nc("@label", "Strength") icon: UM.Theme.getIcon("Hammer") - enableSectionVisible: false - enableSectionEnabled: false + enableSectionSwitchVisible: false + enableSectionSwitchEnabled: false UM.SettingPropertyProvider { diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedSupportSelector.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedSupportSelector.qml index 2a2ec08c70..119be2c37e 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedSupportSelector.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedSupportSelector.qml @@ -15,9 +15,9 @@ RecommendedSettingSection title: catalog.i18nc("@label", "Support") icon: UM.Theme.getIcon("Support") - enableSectionVisible: supportEnabled.properties.enabled == "True" - enableSectionChecked: supportEnabled.properties.value == "True" - enableSectionEnabled: recommendedPrintSetup.settingsEnabled + enableSectionSwitchVisible: supportEnabled.properties.enabled == "True" + enableSectionSwitchChecked: supportEnabled.properties.value == "True" + enableSectionSwitchEnabled: recommendedPrintSetup.settingsEnabled toolTipText: catalog.i18nc("@label", "Generate structures to support parts of the model which have overhangs. Without these structures, such parts would collapse during printing.") function onEnableSectionChanged(state) { From 75721f467b2e46081906ba5090b949b2026b2367 Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Wed, 30 Nov 2022 14:41:19 +0100 Subject: [PATCH 27/82] Remove margins and padding and scale icon better. CURA-9793 --- resources/qml/Widgets/SingleSettingExtruderSelectorBar.qml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/resources/qml/Widgets/SingleSettingExtruderSelectorBar.qml b/resources/qml/Widgets/SingleSettingExtruderSelectorBar.qml index c42b525f6b..c4045b57f0 100644 --- a/resources/qml/Widgets/SingleSettingExtruderSelectorBar.qml +++ b/resources/qml/Widgets/SingleSettingExtruderSelectorBar.qml @@ -53,10 +53,12 @@ Row Cura.ExtruderButton { + anchors.margins : 0 + padding: 0 extruder: model checked: extruder.index == selectedIndex - iconScale: 0.6 - buttonSize: UM.Theme.getSize("large_button").width + iconScale: 0.8 + buttonSize: UM.Theme.getSize("small_button").width onClicked: extruder.enabled && onClickExtruder(extruder.index) } } From e8ba3695b3629f8599cf472988f63c01b1c18284 Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Wed, 30 Nov 2022 14:41:35 +0100 Subject: [PATCH 28/82] Swap out svg for clean export CURA-9793 --- resources/themes/cura-light/icons/default/Hammer.svg | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/resources/themes/cura-light/icons/default/Hammer.svg b/resources/themes/cura-light/icons/default/Hammer.svg index 62823682be..4fd6cd9ce9 100644 --- a/resources/themes/cura-light/icons/default/Hammer.svg +++ b/resources/themes/cura-light/icons/default/Hammer.svg @@ -1,8 +1,3 @@ - - - - + + From 0514c62b3ebaeab0244126b267dfe1b727970601 Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Wed, 30 Nov 2022 14:51:45 +0100 Subject: [PATCH 29/82] Remove bad height assignment to dynamic layout CURA-9793 --- .../Recommended/RecommendedSettingSection.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedSettingSection.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedSettingSection.qml index 81cba57d0e..e270a31203 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedSettingSection.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedSettingSection.qml @@ -77,7 +77,7 @@ Item { id: settingColumn width: parent.width - height: childrenRect.height + spacing: 0 anchors.left: parent.left anchors.right: parent.right anchors.top: sectionHeader.bottom From 680a86c896e229238e4b37a3c89bfe3664a94ae7 Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Wed, 30 Nov 2022 15:08:06 +0100 Subject: [PATCH 30/82] Add default height to combobox, not sure why this was never set before. CURA-9793 --- resources/qml/Widgets/ComboBox.qml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/resources/qml/Widgets/ComboBox.qml b/resources/qml/Widgets/ComboBox.qml index efe14497bc..912403a33e 100644 --- a/resources/qml/Widgets/ComboBox.qml +++ b/resources/qml/Widgets/ComboBox.qml @@ -25,6 +25,8 @@ ComboBox enabled: delegateModel.count > 0 + height: UM.Theme.getSize("combobox").height + onVisibleChanged: { popup.close() } states: [ From dbf2ae4f6042cc9511d81b1676f5d5a27062a32b Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Wed, 30 Nov 2022 15:09:05 +0100 Subject: [PATCH 31/82] Fix spacing vertical between Recommended sections and setting items. CURA-9793 --- .../Recommended/RecommendedPrintSetup.qml | 39 ++++++++++--------- .../Recommended/RecommendedSettingSection.qml | 6 ++- .../RecommendedStrengthSelector.qml | 1 - .../RecommendedSupportSelector.qml | 2 - resources/themes/cura-light/theme.json | 2 + 5 files changed, 28 insertions(+), 22 deletions(-) diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedPrintSetup.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedPrintSetup.qml index 7e25785c74..d369d3ef2c 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedPrintSetup.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedPrintSetup.qml @@ -76,28 +76,31 @@ Item Layout.fillWidth: true color: UM.Theme.getColor("lining") } - - UM.Label + ColumnLayout { - text: catalog.i18nc("@label", "Print settings") - font: UM.Theme.getFont("medium") - } + spacing: UM.Theme.getSize("thin_margin").height + UM.Label + { + text: catalog.i18nc("@label", "Reccomended print settings") + font: UM.Theme.getFont("medium") + } - RecommendedStrengthSelector - { - width: parent.width - Layout.fillWidth: true - } + RecommendedStrengthSelector + { + width: parent.width + Layout.fillWidth: true + } - RecommendedSupportSelector - { - width: parent.width - Layout.fillWidth: true - } + RecommendedSupportSelector + { + width: parent.width + Layout.fillWidth: true + } - RecommendedAdhesionSelector { - width: parent.width - Layout.fillWidth: true + RecommendedAdhesionSelector { + width: parent.width + Layout.fillWidth: true + } } } diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedSettingSection.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedSettingSection.qml index e270a31203..0f63a4e2e5 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedSettingSection.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedSettingSection.qml @@ -77,9 +77,13 @@ Item { id: settingColumn width: parent.width - spacing: 0 + spacing: UM.Theme.getSize("thin_margin").height anchors.left: parent.left anchors.right: parent.right anchors.top: sectionHeader.bottom + anchors.topMargin: UM.Theme.getSize("narrow_margin").height + + Layout.preferredHeight: UM.Theme.getSize("recommended_section_setting_item").height + } } \ No newline at end of file diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedStrengthSelector.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedStrengthSelector.qml index a80d735f59..144f78d19e 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedStrengthSelector.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedStrengthSelector.qml @@ -54,7 +54,6 @@ RecommendedSettingSection settingControl: Cura.SingleSettingComboBox { width: parent.width - height: UM.Theme.getSize("combobox").height settingName: "infill_pattern" } } diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedSupportSelector.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedSupportSelector.qml index 119be2c37e..7396f95590 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedSupportSelector.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedSupportSelector.qml @@ -57,7 +57,6 @@ RecommendedSettingSection settingControl: Cura.SingleSettingComboBox { width: parent.width - height: UM.Theme.getSize("combobox").height settingName: "support_structure" } }, @@ -74,7 +73,6 @@ RecommendedSettingSection settingControl: Cura.SingleSettingComboBox { width: parent.width - height: UM.Theme.getSize("combobox").height settingName: "support_type" } } diff --git a/resources/themes/cura-light/theme.json b/resources/themes/cura-light/theme.json index 45db2670d1..8ddb29c45d 100644 --- a/resources/themes/cura-light/theme.json +++ b/resources/themes/cura-light/theme.json @@ -653,6 +653,8 @@ "recommended_button_icon": [1.7, 1.7], + "recommended_section_setting_item": [14.0, 2.0], + "reset_profile_icon": [1, 1] } } From b356335f4f35af557222b4b752a36bee1490d094 Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Wed, 30 Nov 2022 15:10:19 +0100 Subject: [PATCH 32/82] Correct spelling mistake CURA-9793 --- .../PrintSetupSelector/Recommended/RecommendedPrintSetup.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedPrintSetup.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedPrintSetup.qml index d369d3ef2c..5be35f692c 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedPrintSetup.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedPrintSetup.qml @@ -81,7 +81,7 @@ Item spacing: UM.Theme.getSize("thin_margin").height UM.Label { - text: catalog.i18nc("@label", "Reccomended print settings") + text: catalog.i18nc("@label", "Recommended print settings") font: UM.Theme.getFont("medium") } From 6338085999ede6c8258abaddd3fee91c4bf34ec9 Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Wed, 30 Nov 2022 15:11:45 +0100 Subject: [PATCH 33/82] Remove unused fill CURA-9793 --- resources/themes/cura-light/icons/default/Hammer.svg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/themes/cura-light/icons/default/Hammer.svg b/resources/themes/cura-light/icons/default/Hammer.svg index 4fd6cd9ce9..38b2b6a141 100644 --- a/resources/themes/cura-light/icons/default/Hammer.svg +++ b/resources/themes/cura-light/icons/default/Hammer.svg @@ -1,3 +1,3 @@ - + From d617566db4e2d2bd26378de01426673eb51ccb3a Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Wed, 30 Nov 2022 15:36:15 +0100 Subject: [PATCH 34/82] Move show custom button next to setting section title. CURA-9793 --- .../PrintSetupSelectorContents.qml | 30 +++++++------------ .../Recommended/RecommendedPrintSetup.qml | 25 ++++++++++++++-- 2 files changed, 32 insertions(+), 23 deletions(-) diff --git a/resources/qml/PrintSetupSelector/PrintSetupSelectorContents.qml b/resources/qml/PrintSetupSelector/PrintSetupSelectorContents.qml index e53aa693e1..92f0b1d5be 100644 --- a/resources/qml/PrintSetupSelector/PrintSetupSelectorContents.qml +++ b/resources/qml/PrintSetupSelector/PrintSetupSelectorContents.qml @@ -67,6 +67,8 @@ Item top: parent.top } visible: currentModeIndex == PrintSetupSelectorContents.Mode.Recommended + + function onModeChanged() { currentModeIndex = PrintSetupSelectorContents.Mode.Custom } } CustomPrintSetup @@ -116,13 +118,20 @@ Item width: parent.width height: UM.Theme.getSize("default_lining").height color: UM.Theme.getColor("lining") + visible: currentModeIndex == PrintSetupSelectorContents.Mode.Custom } Item { id: buttonRow property real padding: UM.Theme.getSize("default_margin").width - height: recommendedButton.height + 2 * padding + (draggableArea.visible ? draggableArea.height : 0) + height: { + if (currentModeIndex == PrintSetupSelectorContents.Mode.Custom) + { + return recommendedButton.height + 2 * padding + (draggableArea.visible ? draggableArea.height : 0) + } + return 0 + } anchors { @@ -145,25 +154,6 @@ Item onClicked: currentModeIndex = PrintSetupSelectorContents.Mode.Recommended } - Cura.SecondaryButton - { - id: customSettingsButton - anchors.top: parent.top - anchors.right: parent.right - anchors.margins: UM.Theme.getSize("default_margin").width - leftPadding: UM.Theme.getSize("default_margin").width - rightPadding: UM.Theme.getSize("default_margin").width - text: catalog.i18nc("@button", "Custom") - iconSource: UM.Theme.getIcon("ChevronSingleRight") - isIconOnRightSide: true - visible: currentModeIndex == PrintSetupSelectorContents.Mode.Recommended - onClicked: - { - currentModeIndex = PrintSetupSelectorContents.Mode.Custom - updateDragPosition(); - } - } - //Invisible area at the bottom with which you can resize the panel. MouseArea { diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedPrintSetup.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedPrintSetup.qml index 5be35f692c..f6edf88495 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedPrintSetup.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedPrintSetup.qml @@ -16,6 +16,8 @@ Item property bool settingsEnabled: Cura.ExtruderManager.activeExtruderStackId || extrudersEnabledCount.properties.value == 1 property real padding: UM.Theme.getSize("default_margin").width + function onModeChanged() {} + ColumnLayout { spacing: UM.Theme.getSize("default_margin").height @@ -79,10 +81,27 @@ Item ColumnLayout { spacing: UM.Theme.getSize("thin_margin").height - UM.Label + + RowLayout { - text: catalog.i18nc("@label", "Recommended print settings") - font: UM.Theme.getFont("medium") + UM.Label + { + text: catalog.i18nc("@label", "Recommended print settings") + font: UM.Theme.getFont("medium") + } + + Item { Layout.fillWidth: true } // Spacer + + Cura.SecondaryButton + { + id: customSettingsButton + anchors.top: parent.top + anchors.right: parent.right + text: catalog.i18nc("@button", "Show Custom") + textFont: UM.Theme.getFont("medium_bold") + outlineColor: "transparent" + onClicked: onModeChanged() + } } RecommendedStrengthSelector From 522bf60e81bc0c8a029371007ffbe72499b2c57a Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Wed, 30 Nov 2022 15:43:14 +0100 Subject: [PATCH 35/82] Adjust left margins CURA-9793 --- .../Recommended/RecommendedSettingItem.qml | 2 +- .../Recommended/RecommendedSettingSection.qml | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedSettingItem.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedSettingItem.qml index 87a95a12e8..587ce3ed77 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedSettingItem.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedSettingItem.qml @@ -27,7 +27,7 @@ Item anchors.left: parent.left anchors.verticalCenter: parent.verticalCenter // These numbers come from the IconWithText in RecommendedSettingSection - anchors.leftMargin: UM.Theme.getSize("medium_button_icon").width + UM.Theme.getSize("thick_margin").width - UM.Theme.getSize("thick_lining").width + anchors.leftMargin: UM.Theme.getSize("medium_button_icon").width + UM.Theme.getSize("default_margin").width } diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedSettingSection.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedSettingSection.qml index 0f63a4e2e5..c202381326 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedSettingSection.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedSettingSection.qml @@ -40,9 +40,8 @@ Item width: leftColumnWidth anchors.left: parent.left anchors.verticalCenter: parent.verticalCenter - anchors.leftMargin: - UM.Theme.getSize("thick_lining").width source: UM.Theme.getIcon("PrintQuality") - spacing: UM.Theme.getSize("thick_margin").width + spacing: UM.Theme.getSize("default_margin").width iconSize: UM.Theme.getSize("medium_button_icon").width iconColor: UM.Theme.getColor("text") font: UM.Theme.getFont("medium_bold") @@ -66,7 +65,7 @@ Item id: enableSectionSwitch anchors.left: parent.left // These numbers come from the IconWithText in RecommendedSettingSection. - anchors.leftMargin: leftColumnWidth + UM.Theme.getSize("medium_button_icon").width + UM.Theme.getSize("thick_margin").width - (2 * UM.Theme.getSize("thick_lining").width) + anchors.leftMargin: leftColumnWidth + UM.Theme.getSize("medium_button_icon").width + UM.Theme.getSize("default_margin").width anchors.verticalCenter: sectionHeader.verticalCenter visible: false From 487bf41a7b34b49f4ddf01ec6d8e4ad51fabffdb Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Wed, 30 Nov 2022 16:55:04 +0100 Subject: [PATCH 36/82] Add validators to project. CURA-9793 --- resources/qml/ColorDialog.qml | 2 +- resources/qml/Validators/DoubleValidator.qml | 15 +++++++++++++++ resources/qml/Validators/HexColorValidator.qml | 8 ++++++++ resources/qml/qmldir | 4 ++++ 4 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 resources/qml/Validators/DoubleValidator.qml create mode 100644 resources/qml/Validators/HexColorValidator.qml diff --git a/resources/qml/ColorDialog.qml b/resources/qml/ColorDialog.qml index e5216a3404..94416d77d2 100644 --- a/resources/qml/ColorDialog.qml +++ b/resources/qml/ColorDialog.qml @@ -119,7 +119,7 @@ UM.Dialog text = `#${text}`; } } - validator: RegularExpressionValidator { regularExpression: /^#([a-fA-F0-9]{0,6})$/ } + validator: Cura.HexColorValidator {} } Rectangle diff --git a/resources/qml/Validators/DoubleValidator.qml b/resources/qml/Validators/DoubleValidator.qml new file mode 100644 index 0000000000..dc92dbd1ae --- /dev/null +++ b/resources/qml/Validators/DoubleValidator.qml @@ -0,0 +1,15 @@ +// Copyright (c) 2022 UltiMaker B.V. +// Cura is released under the terms of the LGPLv3 or higher. +import QtQuick 2.15 + +RegularExpressionValidator +{ + property int maxBeforeDecimal: 10 + property int maxAfterDecimal: 10 + + regularExpression: + { + // The build in DoubleValidator doesn't handle "," and "." interchangably. + return "^-?[0-9]{0," + maxBeforeDecimal + "}[.,]?[0-9]{0," + maxAfterDecimal + "}$" + } +} \ No newline at end of file diff --git a/resources/qml/Validators/HexColorValidator.qml b/resources/qml/Validators/HexColorValidator.qml new file mode 100644 index 0000000000..2c3ba706ec --- /dev/null +++ b/resources/qml/Validators/HexColorValidator.qml @@ -0,0 +1,8 @@ +// Copyright (c) 2022 UltiMaker B.V. +// Cura is released under the terms of the LGPLv3 or higher. +import QtQuick 2.15 + +RegularExpressionValidator +{ + regularExpression: /^#([a-fA-F0-9]{0,6})$/ +} \ No newline at end of file diff --git a/resources/qml/qmldir b/resources/qml/qmldir index dd594d8583..9eee76eda7 100644 --- a/resources/qml/qmldir +++ b/resources/qml/qmldir @@ -19,6 +19,9 @@ SettingView 1.0 SettingView.qml ProfileMenu 1.0 ProfileMenu.qml PrintSelectorCard 1.0 PrintSelectorCard.qml +# Cura/Validators +DoubleValidator 1.7 DoubleValidator.qml +HexColorValidator 1.7 HexColorValidator.qml # Cura/WelcomePages @@ -42,6 +45,7 @@ SingleSettingExtruderSelectorBar 1.7 SingleSettingExtruderSelectorBar.qml ExtruderButton 1.7 ExtruderButton.qml SingleSettingComboBox 1.7 SingleSettingComboBox.qml SingleSettingSlider 1.7 SingleSettingSlider.qml +SingleSettingTextFieldWithUnit 1.7 SingleSettingTextFieldWithUnit.qml # Cura/MachineSettings From 574b1000f64b2e7b9d2579481fdd631e9d44a9d4 Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Wed, 30 Nov 2022 17:44:58 +0100 Subject: [PATCH 37/82] Add tooltips CURA-9793 --- .../Recommended/RecommendedAdhesionSelector.qml | 2 ++ .../Recommended/RecommendedSettingItem.qml | 10 ++++++++++ .../Recommended/RecommendedSettingSection.qml | 9 ++++----- .../Recommended/RecommendedStrengthSelector.qml | 6 ++++-- .../Recommended/RecommendedSupportSelector.qml | 5 ++++- 5 files changed, 24 insertions(+), 8 deletions(-) diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedAdhesionSelector.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedAdhesionSelector.qml index b73faa543f..59f0818ebd 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedAdhesionSelector.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedAdhesionSelector.qml @@ -17,6 +17,7 @@ RecommendedSettingSection enableSectionSwitchVisible: platformAdhesionType.properties.enabled == "True" enableSectionSwitchChecked: platformAdhesionType.properties.value != "skirt" && platformAdhesionType.properties.value != "none" enableSectionSwitchEnabled: recommendedPrintSetup.settingsEnabled + tooltipText: catalog.i18nc("@label", "Enable printing a brim or raft. This will add a flat area around or under your object which is easy to cut off afterwards.") property var curaRecommendedMode: Cura.RecommendedMode {} @@ -38,6 +39,7 @@ RecommendedSettingSection { Layout.preferredHeight: childrenRect.height settingName: catalog.i18nc("@action:label", "Print with") + tooltipText: catalog.i18nc("adhesion_extruder_nr description", "The extruder train to use for printing the skirt/brim/raft. This is used in multi-extrusion.") settingControl: Cura.SingleSettingExtruderSelectorBar { extruderSettingName: "adhesion_extruder_nr" } } ] diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedSettingItem.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedSettingItem.qml index 587ce3ed77..05cf09d378 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedSettingItem.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedSettingItem.qml @@ -30,6 +30,16 @@ Item anchors.leftMargin: UM.Theme.getSize("medium_button_icon").width + UM.Theme.getSize("default_margin").width } + MouseArea + { + id: tooltipArea + anchors.fill: settingLabel + propagateComposedEvents: true + hoverEnabled: true + onEntered: base.showTooltip(parent, Qt.point(-UM.Theme.getSize("thick_margin").width, 0), tooltipText) + onExited: base.hideTooltip() + } + Loader { diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedSettingSection.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedSettingSection.qml index c202381326..219127c075 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedSettingSection.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedSettingSection.qml @@ -16,9 +16,9 @@ Item property alias enableSectionSwitchVisible: enableSectionSwitch.visible property alias enableSectionSwitchChecked: enableSectionSwitch.checked property alias enableSectionSwitchEnabled: enableSectionSwitch.enabled + property string tooltipText: "test" property var enableSectionClicked: { return } property int leftColumnWidth: Math.floor(width * 0.35) - property var toolTipText: "" property alias contents: settingColumn.children @@ -49,13 +49,12 @@ Item MouseArea { - id: tooltipMouseArea + id: tooltipArea anchors.fill: sectionTitle propagateComposedEvents: true hoverEnabled: true - - onEntered: { print("showTooltip") } - onExited: { print("hideTooltip" ) } + onEntered: base.showTooltip(parent, Qt.point(-UM.Theme.getSize("thick_margin").width, 0), tooltipText) + onExited: base.hideTooltip() } } diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedStrengthSelector.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedStrengthSelector.qml index 144f78d19e..0f0d727d8a 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedStrengthSelector.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedStrengthSelector.qml @@ -16,6 +16,7 @@ RecommendedSettingSection icon: UM.Theme.getIcon("Hammer") enableSectionSwitchVisible: false enableSectionSwitchEnabled: false + tooltipText: "" UM.SettingPropertyProvider { @@ -29,8 +30,8 @@ RecommendedSettingSection contents: [ RecommendedSettingItem { - settingName: catalog.i18nc("@action:label", "Infill Density") - tooltipText: catalog.i18nc("@label", "Gradual infill will gradually increase the amount of infill towards the top.") + settingName: catalog.i18nc("infill_sparse_density description", "Infill Density") + tooltipText: catalog.i18nc("@label", "Adjusts the density of infill of the print.") settingControl: Cura.SingleSettingSlider { height: UM.Theme.getSize("combobox").height @@ -50,6 +51,7 @@ RecommendedSettingSection RecommendedSettingItem { settingName: catalog.i18nc("@action:label", "Infill Pattern") + tooltipText: catalog.i18nc("infill_pattern description", "The pattern of the infill material of the print. The line and zig zag infill swap direction on alternate layers, reducing material cost. The grid, triangle, tri-hexagon, cubic, octet, quarter cubic, cross and concentric patterns are fully printed every layer. Gyroid, cubic, quarter cubic and octet infill change with every layer to provide a more equal distribution of strength over each direction. Lightning infill tries to minimize the infill, by only supporting the ceiling of the object.") settingControl: Cura.SingleSettingComboBox { diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedSupportSelector.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedSupportSelector.qml index 7396f95590..ed619e0993 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedSupportSelector.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedSupportSelector.qml @@ -18,7 +18,7 @@ RecommendedSettingSection enableSectionSwitchVisible: supportEnabled.properties.enabled == "True" enableSectionSwitchChecked: supportEnabled.properties.value == "True" enableSectionSwitchEnabled: recommendedPrintSetup.settingsEnabled - toolTipText: catalog.i18nc("@label", "Generate structures to support parts of the model which have overhangs. Without these structures, such parts would collapse during printing.") + tooltipText: catalog.i18nc("@label", "Generate structures to support parts of the model which have overhangs. Without these structures, such parts would collapse during printing.") function onEnableSectionChanged(state) { supportEnabled.setPropertyValue("value", state) @@ -53,6 +53,7 @@ RecommendedSettingSection RecommendedSettingItem { settingName: catalog.i18nc("@action:label", "Support Type") + tooltipText: catalog.i18nc("support_structure description", "Chooses between the techniques available to generate support. \"Normal\" support creates a support structure directly below the overhanging parts and drops those areas straight down. \"Tree\" support creates branches towards the overhanging areas that support the model on the tips of those branches, and allows the branches to crawl around the model to support it from the build plate as much as possible.") settingControl: Cura.SingleSettingComboBox { @@ -64,11 +65,13 @@ RecommendedSettingSection { Layout.preferredHeight: childrenRect.height settingName: catalog.i18nc("@action:label", "Print with") + tooltipText: catalog.i18nc("support_extruder_nr description", "The extruder train to use for printing the support. This is used in multi-extrusion.") settingControl: Cura.SingleSettingExtruderSelectorBar { extruderSettingName: "support_extruder_nr" } }, RecommendedSettingItem { settingName: catalog.i18nc("@action:label", "Placement") + tooltipText: catalog.i18nc("support_type description", "Adjusts the placement of the support structures. The placement can be set to touching build plate or everywhere. When set to everywhere the support structures will also be printed on the model.") settingControl: Cura.SingleSettingComboBox { From 62bae7df19462db42716c5be79d48704b371a157 Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Thu, 1 Dec 2022 14:03:11 +0100 Subject: [PATCH 38/82] Collapse the setting section when the switch for the section is disabled. Add collapse animation for setting items and setting section. Swap out ColumnLayout for Layout. Animating the Layouts does not seem to be possible. I had to put spacer back into the Column but it is the lesser of two evils. CURA-9793 --- .../RecommendedAdhesionSelector.qml | 8 +++- .../Recommended/RecommendedPrintSetup.qml | 37 +++++++------- .../Recommended/RecommendedSettingItem.qml | 43 ++++++++++++++++- .../Recommended/RecommendedSettingSection.qml | 48 +++++++++++++++++-- .../RecommendedSupportSelector.qml | 9 +++- 5 files changed, 118 insertions(+), 27 deletions(-) diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedAdhesionSelector.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedAdhesionSelector.qml index 59f0818ebd..8a83af10dd 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedAdhesionSelector.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedAdhesionSelector.qml @@ -37,10 +37,14 @@ RecommendedSettingSection contents: [ RecommendedSettingItem { - Layout.preferredHeight: childrenRect.height + isCompressed: enableAdhesionRow.isCompressed settingName: catalog.i18nc("@action:label", "Print with") tooltipText: catalog.i18nc("adhesion_extruder_nr description", "The extruder train to use for printing the skirt/brim/raft. This is used in multi-extrusion.") - settingControl: Cura.SingleSettingExtruderSelectorBar { extruderSettingName: "adhesion_extruder_nr" } + + settingControl: Cura.SingleSettingExtruderSelectorBar + { + extruderSettingName: "adhesion_extruder_nr" + } } ] } diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedPrintSetup.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedPrintSetup.qml index f6edf88495..5231af7232 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedPrintSetup.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedPrintSetup.qml @@ -1,4 +1,4 @@ -//Copyright (c) 2022 Ultimaker B.V. +//Copyright (c) 2022 UltiMaker B.V. //Cura is released under the terms of the LGPLv3 or higher. import QtQuick 2.10 @@ -18,7 +18,7 @@ Item function onModeChanged() {} - ColumnLayout + Column { spacing: UM.Theme.getSize("default_margin").height @@ -48,7 +48,6 @@ Item RecommendedResolutionSelector { id: recommendedResolutionSelector - Layout.fillWidth: true width: parent.width } @@ -56,46 +55,49 @@ Item { width: parent.width visible: !recommendedResolutionSelector.visible - Layout.fillWidth: true } + Item { height: UM.Theme.getSize("default_margin").height } // Spacer ProfileWarningReset { width: parent.width - Layout.fillWidth: true - Layout.topMargin: UM.Theme.getSize("default_margin").height - Layout.bottomMargin: UM.Theme.getSize("thin_margin").height } + Item { height: UM.Theme.getSize("thin_margin").height + UM.Theme.getSize("narrow_margin").height} // Spacer + //Line between the sections. Rectangle { width: parent.width height: UM.Theme.getSize("default_lining").height - Layout.topMargin: UM.Theme.getSize("narrow_margin").height - Layout.bottomMargin: UM.Theme.getSize("narrow_margin").height - Layout.fillWidth: true color: UM.Theme.getColor("lining") } - ColumnLayout - { + + Item { height: UM.Theme.getSize("narrow_margin").height } //Spacer + + Column { + id: settingColumn + width: parent.width spacing: UM.Theme.getSize("thin_margin").height - RowLayout + Item { + id: recommendedPrintSettingsHeader + height: childrenRect.height + width: parent.width UM.Label { + anchors.verticalCenter: parent.verticalCenter + anchors.left: parent.left text: catalog.i18nc("@label", "Recommended print settings") font: UM.Theme.getFont("medium") } - Item { Layout.fillWidth: true } // Spacer - Cura.SecondaryButton { id: customSettingsButton - anchors.top: parent.top + anchors.verticalCenter: parent.verticalCenter anchors.right: parent.right text: catalog.i18nc("@button", "Show Custom") textFont: UM.Theme.getFont("medium_bold") @@ -107,18 +109,15 @@ Item RecommendedStrengthSelector { width: parent.width - Layout.fillWidth: true } RecommendedSupportSelector { width: parent.width - Layout.fillWidth: true } RecommendedAdhesionSelector { width: parent.width - Layout.fillWidth: true } } } diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedSettingItem.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedSettingItem.qml index 05cf09d378..9d61f14704 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedSettingItem.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedSettingItem.qml @@ -1,4 +1,4 @@ -// Copyright (c) 2022 Ultimaker B.V. +// Copyright (c) 2022 UltiMaker B.V. // Cura is released under the terms of the LGPLv3 or higher. import QtQuick 2.10 @@ -11,14 +11,15 @@ import Cura 1.7 as Cura Item { + id: settingItem width: parent.width - Layout.preferredHeight: childrenRect.height Layout.minimumHeight: UM.Theme.getSize("section_header").height Layout.fillWidth: true property alias settingControl: settingContainer.children property alias settingName: settingLabel.text property string tooltipText: "" + property bool isCompressed: false UM.Label { @@ -49,4 +50,42 @@ Item anchors.right: parent.right anchors.verticalCenter: parent.verticalCenter } + + states: + [ + State + { + name: "sectionClosed" // Section is hidden when the switch in parent is off + when: isCompressed + PropertyChanges + { + target: settingItem; + opacity: 0 + height: 0 + implicitHeight: 0 + Layout.preferredHeight: 0 + Layout.minimumHeight: 0 + } + }, + State + { + // All values are default. This state is only here for the animation. + name: "sectionOpened" + when: !isCompressed + } + ] + + transitions: Transition + { + from: "sectionOpened"; to: "sectionClosed" + reversible: true + ParallelAnimation + { + // Animate section compressing as it closes + NumberAnimation { property: "Layout.minimumHeight"; duration: 100; } + // Animate section dissapearring as it closes + NumberAnimation { property: "opacity"; duration: 100; } + + } + } } \ No newline at end of file diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedSettingSection.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedSettingSection.qml index 219127c075..3bdc3cdd65 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedSettingSection.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedSettingSection.qml @@ -1,4 +1,4 @@ -// Copyright (c) 2022 Ultimaker B.V. +// Copyright (c) 2022 UltiMaker B.V. // Cura is released under the terms of the LGPLv3 or higher. import QtQuick 2.10 @@ -10,6 +10,7 @@ import Cura 1.7 as Cura Item { + id: settingSection property alias title: sectionTitle.text property alias icon: sectionTitle.source @@ -19,6 +20,7 @@ Item property string tooltipText: "test" property var enableSectionClicked: { return } property int leftColumnWidth: Math.floor(width * 0.35) + property bool isCompressed: false property alias contents: settingColumn.children @@ -68,7 +70,15 @@ Item anchors.verticalCenter: sectionHeader.verticalCenter visible: false - onClicked: onEnableSectionChanged(enableSectionSwitch.checked) + // This delay forces the setting change to happen after the setting section open/close animation. This is so the animation is smooth. + Timer + { + id: updateTimer + interval: 500 // This interval is set long enough so you can spam click the button on/off without lag. + repeat: false + onTriggered: onEnableSectionChanged(enableSectionSwitch.checked) + } + onClicked: updateTimer.restart() } ColumnLayout @@ -80,8 +90,40 @@ Item anchors.right: parent.right anchors.top: sectionHeader.bottom anchors.topMargin: UM.Theme.getSize("narrow_margin").height + } - Layout.preferredHeight: UM.Theme.getSize("recommended_section_setting_item").height + states: + [ + State + { + name: "settingListClosed" + when: !enableSectionSwitchChecked && enableSectionSwitchEnabled + PropertyChanges + { + target: settingSection + isCompressed: true + implicitHeight: 0 + } + PropertyChanges + { + target: settingColumn + spacing: 0 + } + }, + State + { + // Use default properties. This is only here for the animation. + name: "settingListOpened" + when: enableSectionSwitchChecked && enableSectionSwitchEnabled + } + ] + // Animate section closing + transitions: Transition + { + from: "settingListOpened"; to: "settingListClosed" + reversible: true + // Animate section compressing as it closes + NumberAnimation { property: "implicitHeight"; duration: 100; } } } \ No newline at end of file diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedSupportSelector.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedSupportSelector.qml index ed619e0993..f7f7df0fe3 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedSupportSelector.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedSupportSelector.qml @@ -54,6 +54,7 @@ RecommendedSettingSection { settingName: catalog.i18nc("@action:label", "Support Type") tooltipText: catalog.i18nc("support_structure description", "Chooses between the techniques available to generate support. \"Normal\" support creates a support structure directly below the overhanging parts and drops those areas straight down. \"Tree\" support creates branches towards the overhanging areas that support the model on the tips of those branches, and allows the branches to crawl around the model to support it from the build plate as much as possible.") + isCompressed: enableSupportRow.isCompressed settingControl: Cura.SingleSettingComboBox { @@ -66,12 +67,18 @@ RecommendedSettingSection Layout.preferredHeight: childrenRect.height settingName: catalog.i18nc("@action:label", "Print with") tooltipText: catalog.i18nc("support_extruder_nr description", "The extruder train to use for printing the support. This is used in multi-extrusion.") - settingControl: Cura.SingleSettingExtruderSelectorBar { extruderSettingName: "support_extruder_nr" } + isCompressed: enableSupportRow.isCompressed + + settingControl: Cura.SingleSettingExtruderSelectorBar + { + extruderSettingName: "support_extruder_nr" + } }, RecommendedSettingItem { settingName: catalog.i18nc("@action:label", "Placement") tooltipText: catalog.i18nc("support_type description", "Adjusts the placement of the support structures. The placement can be set to touching build plate or everywhere. When set to everywhere the support structures will also be printed on the model.") + isCompressed: enableSupportRow.isCompressed settingControl: Cura.SingleSettingComboBox { From 01ebee4aea6bd484d3e471a6c2f781aa6cb14cd0 Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Thu, 1 Dec 2022 15:27:14 +0100 Subject: [PATCH 39/82] Cleanup CURA-9793 --- resources/qml/Widgets/SingleSettingComboBox.qml | 4 +++- resources/qml/Widgets/SingleSettingSlider.qml | 5 +---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/resources/qml/Widgets/SingleSettingComboBox.qml b/resources/qml/Widgets/SingleSettingComboBox.qml index f0c43c31f7..151a9b1cd9 100644 --- a/resources/qml/Widgets/SingleSettingComboBox.qml +++ b/resources/qml/Widgets/SingleSettingComboBox.qml @@ -58,7 +58,9 @@ Cura.ComboBox { function onIsValueUsedChanged() { comboboxModel.updateModel() } } - onCurrentIndexChanged: + onCurrentIndexChanged: updateSetting() + + function updateSetting(value) { if (comboboxModel.get(currentIndex) && comboboxModel.get(currentIndex).code) { diff --git a/resources/qml/Widgets/SingleSettingSlider.qml b/resources/qml/Widgets/SingleSettingSlider.qml index 8baccfefe7..855af45417 100644 --- a/resources/qml/Widgets/SingleSettingSlider.qml +++ b/resources/qml/Widgets/SingleSettingSlider.qml @@ -63,10 +63,7 @@ RowLayout id: updateTimer interval: 100 repeat: false - onTriggered: - { - parseValueUpdateSetting() - } + onTriggered: parseValueUpdateSetting() } function parseValueUpdateSetting() From 9c4716416e660b2ede59dab40553064e4d6b5c1e Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Thu, 1 Dec 2022 16:58:29 +0100 Subject: [PATCH 40/82] Add validators that match validators for SettingTextField. CURA-9793 --- resources/qml/Validators/DoubleValidator.qml | 15 --------------- resources/qml/Validators/FloatValidator.qml | 11 +++++++++++ resources/qml/Validators/IntListValidator.qml | 8 ++++++++ resources/qml/Validators/IntValidator.qml | 10 ++++++++++ 4 files changed, 29 insertions(+), 15 deletions(-) delete mode 100644 resources/qml/Validators/DoubleValidator.qml create mode 100644 resources/qml/Validators/FloatValidator.qml create mode 100644 resources/qml/Validators/IntListValidator.qml create mode 100644 resources/qml/Validators/IntValidator.qml diff --git a/resources/qml/Validators/DoubleValidator.qml b/resources/qml/Validators/DoubleValidator.qml deleted file mode 100644 index dc92dbd1ae..0000000000 --- a/resources/qml/Validators/DoubleValidator.qml +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (c) 2022 UltiMaker B.V. -// Cura is released under the terms of the LGPLv3 or higher. -import QtQuick 2.15 - -RegularExpressionValidator -{ - property int maxBeforeDecimal: 10 - property int maxAfterDecimal: 10 - - regularExpression: - { - // The build in DoubleValidator doesn't handle "," and "." interchangably. - return "^-?[0-9]{0," + maxBeforeDecimal + "}[.,]?[0-9]{0," + maxAfterDecimal + "}$" - } -} \ No newline at end of file diff --git a/resources/qml/Validators/FloatValidator.qml b/resources/qml/Validators/FloatValidator.qml new file mode 100644 index 0000000000..62ff981e2e --- /dev/null +++ b/resources/qml/Validators/FloatValidator.qml @@ -0,0 +1,11 @@ +// Copyright (c) 2022 UltiMaker B.V. +// Cura is released under the terms of the LGPLv3 or higher. +import QtQuick 2.15 + +RegularExpressionValidator +{ + property int maxBeforeDecimal: 11 + property int maxAfterDecimal: 3 + + regularExpression: new RegExp("^-?[0-9]{0,%0}[.,]?[0-9]{0,%1}$".arg(maxBeforeDecimal).arg(maxAfterDecimal)) +} \ No newline at end of file diff --git a/resources/qml/Validators/IntListValidator.qml b/resources/qml/Validators/IntListValidator.qml new file mode 100644 index 0000000000..2f5b3c829a --- /dev/null +++ b/resources/qml/Validators/IntListValidator.qml @@ -0,0 +1,8 @@ +// Copyright (c) 2022 UltiMaker B.V. +// Cura is released under the terms of the LGPLv3 or higher. +import QtQuick 2.15 + +RegularExpressionValidator +{ + regularExpression: new RegExp("^\[?(\s*-?[0-9]{0,11}\s*,)*(\s*-?[0-9]{0,11})\s*\]?$") +} \ No newline at end of file diff --git a/resources/qml/Validators/IntValidator.qml b/resources/qml/Validators/IntValidator.qml new file mode 100644 index 0000000000..6b7ced9ce8 --- /dev/null +++ b/resources/qml/Validators/IntValidator.qml @@ -0,0 +1,10 @@ +// Copyright (c) 2022 UltiMaker B.V. +// Cura is released under the terms of the LGPLv3 or higher. +import QtQuick 2.15 + +RegularExpressionValidator +{ + property int maxNumbers: 12 + + regularExpression: new RegExp("^-?[0-9]{0,%0}$".arg(maxNumbers)) +} \ No newline at end of file From df6ea1ea745163c931e4bd9fa3f9a962668d2da5 Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Thu, 1 Dec 2022 17:08:46 +0100 Subject: [PATCH 41/82] Rename TextFieldWithUnit.qml -> TextField and put all base textfield styling in it. CURA-9793 --- resources/qml/qmldir | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/resources/qml/qmldir b/resources/qml/qmldir index 9eee76eda7..109cbc0823 100644 --- a/resources/qml/qmldir +++ b/resources/qml/qmldir @@ -20,7 +20,9 @@ ProfileMenu 1.0 ProfileMenu.qml PrintSelectorCard 1.0 PrintSelectorCard.qml # Cura/Validators -DoubleValidator 1.7 DoubleValidator.qml +FloatValidator 1.7 FloatValidator.qml +IntValidator 1.7 IntValidator +IntListValidator 1.7 IntListValidator HexColorValidator 1.7 HexColorValidator.qml # Cura/WelcomePages @@ -45,7 +47,7 @@ SingleSettingExtruderSelectorBar 1.7 SingleSettingExtruderSelectorBar.qml ExtruderButton 1.7 ExtruderButton.qml SingleSettingComboBox 1.7 SingleSettingComboBox.qml SingleSettingSlider 1.7 SingleSettingSlider.qml -SingleSettingTextFieldWithUnit 1.7 SingleSettingTextFieldWithUnit.qml +SingleSettingTextField 1.7 SingleSettingTextField.qml # Cura/MachineSettings From 73137a140a51e99970b6eab1915691b7a8235629 Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Thu, 1 Dec 2022 17:09:19 +0100 Subject: [PATCH 42/82] Inherit UM.TextField in Cura.TextField and remove redundant properties CURA-9793 --- resources/qml/Widgets/TextField.qml | 81 ++--------------------------- 1 file changed, 3 insertions(+), 78 deletions(-) diff --git a/resources/qml/Widgets/TextField.qml b/resources/qml/Widgets/TextField.qml index 085c7b7742..f16d4abb11 100644 --- a/resources/qml/Widgets/TextField.qml +++ b/resources/qml/Widgets/TextField.qml @@ -4,87 +4,12 @@ import QtQuick 2.10 import QtQuick.Controls 2.3 -import UM 1.5 as UM +import UM 1.7 as UM import Cura 1.1 as Cura - -// -// Cura-style TextField -// -TextField +UM.TextField { id: control - - property alias leftIcon: iconLeft.source - height: UM.Theme.getSize("setting_control").height - - hoverEnabled: true - selectByMouse: true - font: UM.Theme.getFont("default") - color: UM.Theme.getColor("text_field_text") - selectedTextColor: UM.Theme.getColor("text_field_text") - placeholderTextColor: UM.Theme.getColor("text_field_text_disabled") - renderType: Text.NativeRendering - selectionColor: UM.Theme.getColor("text_selection") - leftPadding: iconLeft.visible ? iconLeft.width + UM.Theme.getSize("default_margin").width * 2 : UM.Theme.getSize("thin_margin").width - - states: [ - State - { - name: "disabled" - when: !control.enabled - PropertyChanges { target: control; color: UM.Theme.getColor("text_field_text_disabled")} - PropertyChanges { target: backgroundRectangle; liningColor: UM.Theme.getColor("text_field_border_disabled")} - }, - State - { - name: "invalid" - when: !control.acceptableInput - PropertyChanges { target: backgroundRectangle; color: UM.Theme.getColor("setting_validation_error_background")} - }, - State - { - name: "active" - when: control.activeFocus - PropertyChanges - { - target: backgroundRectangle - liningColor: UM.Theme.getColor("text_field_border_active") - borderColor: UM.Theme.getColor("text_field_border_active") - } - }, - State - { - name: "hovered" - when: control.hovered && !control.activeFocus - PropertyChanges - { - target: backgroundRectangle - liningColor: UM.Theme.getColor("text_field_border_hovered") - } - } - ] - - background: UM.UnderlineBackground - { - id: backgroundRectangle - //Optional icon added on the left hand side. - UM.ColorImage - { - id: iconLeft - - anchors - { - verticalCenter: parent.verticalCenter - left: parent.left - leftMargin: UM.Theme.getSize("default_margin").width - } - - visible: source != "" - height: UM.Theme.getSize("small_button_icon").height - width: visible ? height : 0 - color: control.color - } - } + leftPadding: UM.Theme.getSize("thin_margin").width } From f24e6b19610855f8f42eb75c75ab6d20b685e678 Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Thu, 1 Dec 2022 17:09:41 +0100 Subject: [PATCH 43/82] Fix NumericTextFieldWithUnit not validating text CURA-9793 --- resources/qml/MachineSettings/NumericTextFieldWithUnit.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/qml/MachineSettings/NumericTextFieldWithUnit.qml b/resources/qml/MachineSettings/NumericTextFieldWithUnit.qml index 2484adb912..64beeb9834 100644 --- a/resources/qml/MachineSettings/NumericTextFieldWithUnit.qml +++ b/resources/qml/MachineSettings/NumericTextFieldWithUnit.qml @@ -59,7 +59,7 @@ UM.TooltipArea UM.SettingPropertyProvider { id: propertyProvider - watchedProperties: [ "value", "description" ] + watchedProperties: [ "value", "description", "validationState" ] } UM.Label From dfb6c04d00579ba5a9f13d0b74530dd8cdc609ce Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Fri, 2 Dec 2022 11:48:50 +0100 Subject: [PATCH 44/82] Add SingleSettingTextField.qml Added a workaround for states of inheriting components. See comments for details. CURA-9793 --- .../RecommendedStrengthSelector.qml | 12 ++ .../qml/Widgets/SingleSettingTextField.qml | 154 ++++++++++++++++++ 2 files changed, 166 insertions(+) create mode 100644 resources/qml/Widgets/SingleSettingTextField.qml diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedStrengthSelector.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedStrengthSelector.qml index 0f0d727d8a..dd603df195 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedStrengthSelector.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedStrengthSelector.qml @@ -58,6 +58,18 @@ RecommendedSettingSection width: parent.width settingName: "infill_pattern" } + }, + RecommendedSettingItem + { + settingName: catalog.i18nc("@action:label", "Shell Thickness") + + settingControl: Cura.SingleSettingTextField + { + width: parent.width + settingName: "wall_thickness" + validator: Cura.FloatValidator {} + unitText: catalog.i18nc("@label", "mm") + } } ] } diff --git a/resources/qml/Widgets/SingleSettingTextField.qml b/resources/qml/Widgets/SingleSettingTextField.qml new file mode 100644 index 0000000000..c128a5070e --- /dev/null +++ b/resources/qml/Widgets/SingleSettingTextField.qml @@ -0,0 +1,154 @@ +// Copyright (c) 2022 UltiMaker B.V. +// Cura is released under the terms of the LGPLv3 or higher. + +import QtQuick 2.10 +import QtQuick.Controls 2.3 +import QtQuick.Layouts 1.3 + +import UM 1.7 as UM +import Cura 1.7 as Cura + +// This text field allows you to edit a single setting. The setting can be passed by "settingName". +// You must specify a validator with Validator. We store our default setting validators in qml/Validators +UM.TextField +{ + id: control + property alias settingName: propertyProvider.key + + // Resolving the value in the textField. + Binding + { + target: control + property: "text" + + value: + { + if (control.activeFocus) + { + // This stops the text being reformatted as you edit. For example "10.1" -Edit-> "10." -Auto Format-> "10.0". + return control.text + } + return propertyProvider.properties.value + } + + } + + property UM.SettingPropertyProvider propertyProvider: UM.SettingPropertyProvider + { + id: propertyProvider + containerStack: Cura.MachineManager.activeMachine + watchedProperties: [ "value", "validationState" ] + } + + Connections + { + target: propertyProvider + function onContainerStackChanged() { updateTimer.restart() } + function onIsValueUsedChanged() { updateTimer.restart() } + } + + // Restart update timer right after releasing a key. This stops lag while typing, but you still get warning and error + // textfield styling while typing. + Keys.onReleased: updateTimer.restart() + // Forces formatting when you finish editing "10.1" -Edit-> "10." -Focus Change-> "10" + onActiveFocusChanged: updateTime.restart() + + // Updates to the setting are delayed by interval. This stops lag caused by calling the + // parseValueUpdateSetting() function being called repeatedly while changing the text value. + Timer + { + id: updateTimer + interval: 50 + repeat: false + onTriggered: parseValueUpdateSetting() + } + + function parseValueUpdateSetting() + { + // Do some parsing of text here + updateSetting(text); + } + + function updateSetting(value) + { + if (propertyProvider && text != propertyProvider.properties.value) + { + propertyProvider.setPropertyValue("value", text) + } + } + + // Forced to override parent states using overrideState. Otherwise hover in TextField.qml would override the validation states. + // The first state to evaluate true applies styling. States in inheriting components get appended to the state list of their parent. + overrideState: true + states: + [ + State + { + name: "validationError" + when: propertyProvider.properties.validationState == "ValidatorState.Exception" || propertyProvider.properties.validationState == "ValidatorState.MinimumError" || propertyProvider.properties.validationState == "ValidatorState.MaximumError" + PropertyChanges + { + target: background + liningColor: UM.Theme.getColor("setting_validation_error") + color: UM.Theme.getColor("setting_validation_error_background") + } + }, + State + { + name: "validationWarning" + when: propertyProvider.properties.validationState == "ValidatorState.MinimumWarning" || propertyProvider.properties.validationState == "ValidatorState.MaximumWarning" + PropertyChanges + { + target: background + liningColor: UM.Theme.getColor("setting_validation_warning") + color: UM.Theme.getColor("setting_validation_warning_background") + } + }, + State + { + name: "disabled" + when: !control.enabled + PropertyChanges + { + target: control + color: UM.Theme.getColor("text_field_text_disabled") + } + PropertyChanges + { + target: background + liningColor: UM.Theme.getColor("text_field_border_disabled") + } + }, + State + { + name: "invalid" + when: !control.acceptableInput + PropertyChanges + { + target: background + color: UM.Theme.getColor("setting_validation_error_background") + } + }, + State + { + name: "active" + when: control.activeFocus + PropertyChanges + { + target: background + liningColor: UM.Theme.getColor("text_field_border_active") + borderColor: UM.Theme.getColor("text_field_border_active") + } + }, + State + { + name: "hovered" + when: control.hovered && !control.activeFocus + PropertyChanges + { + target: background + liningColor: UM.Theme.getColor("text_field_border_hovered") + } + } + ] +} From 5b76e3dd7c06b6b0ab64518959257dccc982dfd9 Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Fri, 2 Dec 2022 12:41:04 +0100 Subject: [PATCH 45/82] Add component with icon generic component. Add print walls and print top/bottom settings to recommended menu CURA-9793 --- .../RecommendedStrengthSelector.qml | 35 +++++++++++++++---- .../cura-light/icons/default/PrintWalls.svg | 12 +++++++ 2 files changed, 41 insertions(+), 6 deletions(-) create mode 100644 resources/themes/cura-light/icons/default/PrintWalls.svg diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedStrengthSelector.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedStrengthSelector.qml index dd603df195..54f005bb9e 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedStrengthSelector.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedStrengthSelector.qml @@ -3,8 +3,9 @@ import QtQuick 2.7 import QtQuick.Controls 2.15 +import QtQuick.Layouts 2.10 -import UM 1.5 as UM +import UM 1.7 as UM import Cura 1.7 as Cura @@ -63,12 +64,34 @@ RecommendedSettingSection { settingName: catalog.i18nc("@action:label", "Shell Thickness") - settingControl: Cura.SingleSettingTextField + settingControl: RowLayout { - width: parent.width - settingName: "wall_thickness" - validator: Cura.FloatValidator {} - unitText: catalog.i18nc("@label", "mm") + anchors.fill: parent + spacing: UM.Theme.getSize("default_margin").width + UM.ComponentWithIcon + { + Layout.fillWidth: true + source: UM.Theme.getIcon("PrintWalls") + displayComponent: Cura.SingleSettingTextField + { + width: parent.width + settingName: "wall_thickness" + validator: Cura.FloatValidator {} + unitText: catalog.i18nc("@label", "mm") + } + } + UM.ComponentWithIcon + { + Layout.fillWidth: true + source: UM.Theme.getIcon("PrintTopBottom") + displayComponent: Cura.SingleSettingTextField + { + width: parent.width + settingName: "top_bottom_thickness" + validator: Cura.FloatValidator {} + unitText: catalog.i18nc("@label", "mm") + } + } } } ] diff --git a/resources/themes/cura-light/icons/default/PrintWalls.svg b/resources/themes/cura-light/icons/default/PrintWalls.svg new file mode 100644 index 0000000000..156a87177d --- /dev/null +++ b/resources/themes/cura-light/icons/default/PrintWalls.svg @@ -0,0 +1,12 @@ + + + + + + + + + + + + From 02572311bf732e24a39829afbeb28ce39b2598b2 Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Fri, 2 Dec 2022 16:19:29 +0100 Subject: [PATCH 46/82] Components were clickable when hidden. CURA-9793 --- .../PrintSetupSelector/Recommended/RecommendedSettingItem.qml | 1 + 1 file changed, 1 insertion(+) diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedSettingItem.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedSettingItem.qml index 9d61f14704..1b5ad8bd17 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedSettingItem.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedSettingItem.qml @@ -65,6 +65,7 @@ Item implicitHeight: 0 Layout.preferredHeight: 0 Layout.minimumHeight: 0 + enabled: false // Components can still be clickable with height 0 so they need to be disabled as well. } }, State From df8d0e9b469a6682d08c71655f6d8c1b05d07418 Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Fri, 2 Dec 2022 18:01:12 +0100 Subject: [PATCH 47/82] Make it easier to override how the settingComboBox updates a setting. CURA-9793 --- resources/qml/Widgets/SingleSettingComboBox.qml | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/resources/qml/Widgets/SingleSettingComboBox.qml b/resources/qml/Widgets/SingleSettingComboBox.qml index 151a9b1cd9..5c56fedb9c 100644 --- a/resources/qml/Widgets/SingleSettingComboBox.qml +++ b/resources/qml/Widgets/SingleSettingComboBox.qml @@ -58,13 +58,19 @@ Cura.ComboBox { function onIsValueUsedChanged() { comboboxModel.updateModel() } } - onCurrentIndexChanged: updateSetting() + onCurrentIndexChanged: parseValueAndUpdateSetting() + + function parseValueAndUpdateSetting() + { + if (comboboxModel.get(currentIndex) && comboboxModel.get(currentIndex).code != propertyProvider.properties.value) + { + updateSetting(comboboxModel.get(currentIndex).code) + } + + } function updateSetting(value) { - if (comboboxModel.get(currentIndex) && comboboxModel.get(currentIndex).code) - { - propertyProvider.setPropertyValue("value", comboboxModel.get(currentIndex).code) - } + propertyProvider.setPropertyValue("value", value) } } From 540d81029327a4824d5dfccd855bec98b0be2adf Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Mon, 5 Dec 2022 10:23:40 +0100 Subject: [PATCH 48/82] The slider was not forcing its setting value to stay the same when changes were made in the "Advanced" menu. This is because the slider updating and setting updating functions were intertwined. I've seperated them so that the slider no longer interferes with changes to the setting. The Shell thickness settings were not being read or set correctly. I fixed this by setting the value to all extruders and reading from extruder 1. This setting is not set per machine but for all extruders. Not sure why. CURA-9793 --- .../RecommendedStrengthSelector.qml | 7 +++ resources/qml/Widgets/SingleSettingSlider.qml | 61 ++++++++++--------- .../qml/Widgets/SingleSettingTextField.qml | 31 ++++++++-- 3 files changed, 65 insertions(+), 34 deletions(-) diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedStrengthSelector.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedStrengthSelector.qml index 54f005bb9e..61079c8fca 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedStrengthSelector.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedStrengthSelector.qml @@ -58,6 +58,11 @@ RecommendedSettingSection { width: parent.width settingName: "infill_pattern" + + function updateSetting(value) + { + Cura.MachineManager.setSettingForAllExtruders("infill_pattern", "value", value) + } } }, RecommendedSettingItem @@ -76,6 +81,7 @@ RecommendedSettingSection { width: parent.width settingName: "wall_thickness" + updateAllExtruders: true validator: Cura.FloatValidator {} unitText: catalog.i18nc("@label", "mm") } @@ -88,6 +94,7 @@ RecommendedSettingSection { width: parent.width settingName: "top_bottom_thickness" + updateAllExtruders: true validator: Cura.FloatValidator {} unitText: catalog.i18nc("@label", "mm") } diff --git a/resources/qml/Widgets/SingleSettingSlider.qml b/resources/qml/Widgets/SingleSettingSlider.qml index 855af45417..8fc81f6c2f 100644 --- a/resources/qml/Widgets/SingleSettingSlider.qml +++ b/resources/qml/Widgets/SingleSettingSlider.qml @@ -8,25 +8,29 @@ import UM 1.7 as UM import Cura 1.7 as Cura import QtQuick.Layouts 1.3 +// This silder allows changing of a single setting. Only the setting name has to be passed in to "settingName". +// All of the setting updating logic is handled by this component. +// This component allows you to choose values between minValue -> maxValue and rounds them to the nearest 10. + RowLayout { height: childrenRect.height spacing: UM.Theme.getSize("default_margin").width - property alias settingName: settingPropertyProvider.key + property alias settingName: propertyProvider.key property alias enabled: settingSlider.enabled property bool roundToNearestTen: false property int maxValue: 100 property int minValue: 0 + property int previousValue: -1 UM.SettingPropertyProvider { - id: settingPropertyProvider + id: propertyProvider containerStackId: Cura.MachineManager.activeStackId watchedProperties: [ "value" ] storeIndex: 0 - } UM.Label { Layout.fillWidth: false; text: minValue } @@ -41,55 +45,56 @@ RowLayout from: minValue; to: maxValue; stepSize: 1 // set initial value from stack - value: parseInt(settingPropertyProvider.properties.value) + value: parseInt(propertyProvider.properties.value) // When the slider is released trigger an update immediately. This forces the slider to snap to the rounded value. - onPressedChanged: if(!pressed) { parseValueUpdateSetting() } + onPressedChanged: if(!pressed) { roundSliderValueUpdateSetting() } } UM.Label { Layout.fillWidth: false; text: maxValue } Connections { - target: settingPropertyProvider + target: propertyProvider function onContainerStackChanged() { updateTimer.restart() } function onIsValueUsedChanged() { updateTimer.restart() } } - // Updates to the setting are delayed by interval. This stops lag caused by calling the - // parseValueUpdateSetting() function being call repeatedly while dragging the slider. + // Updates to the setting are delayed by interval. This reduces lag by waiting a bit after a setting change to update the slider contents. Timer { id: updateTimer interval: 100 repeat: false - onTriggered: parseValueUpdateSetting() + onTriggered: parseValueUpdateSetting(false) } - function parseValueUpdateSetting() + function updateSlider(value) { - // Work around, the `settingPropertyProvider.properties.value` is initially `undefined`. As - // `parseInt(settingPropertyProvider.properties.value)` is parsed as 0 and is initially set as - // the slider value. By setting this 0 value an update is triggered setting the actual - // sitting value to 0. - if (isNaN(parseInt(settingPropertyProvider.properties.value))) - { - return; - } + settingSlider.value = value + } - // Don't update if the setting value, if the slider has the same value - if (parseInt(settingPropertyProvider.properties.value) == settingSlider.value) - { - return; - } - - // Round the slider value to the nearest multiple of 10 (simulate step size of 10) + function roundSliderValueUpdateSetting() + { + // If the user interacts with the slider we round the value and update the setting. + print("roundSliderValueUpdateSetting()") const roundedSliderValue = roundToNearestTen ? Math.round(settingSlider.value / 10) * 10 : Math.round(settingSlider.value) + settingSlider.value = roundedSliderValue + updateSetting(roundedSliderValue) + } - // Update the slider value to represent the rounded value - settingSlider.value = roundedSliderValue; - updateSetting(roundedSliderValue); + function parseValueUpdateSetting(triggerUpdate) + { + // Only run when the setting value is updated by something other than the slider. + // This sets the slider value based on the setting value, it does not update the setting value. + + if (parseInt(propertyProvider.properties.value) == settingSlider.value) + { + return + } + + settingSlider.value = propertyProvider.properties.value } // Override this function to update a setting differently diff --git a/resources/qml/Widgets/SingleSettingTextField.qml b/resources/qml/Widgets/SingleSettingTextField.qml index c128a5070e..f3cc433ace 100644 --- a/resources/qml/Widgets/SingleSettingTextField.qml +++ b/resources/qml/Widgets/SingleSettingTextField.qml @@ -15,6 +15,10 @@ UM.TextField id: control property alias settingName: propertyProvider.key + // If true, all extruders will have "settingName" property updated. + // The displayed value will be read from the first extruder instead of the machine. + property bool updateAllExtruders: false + // Resolving the value in the textField. Binding { @@ -28,6 +32,15 @@ UM.TextField // This stops the text being reformatted as you edit. For example "10.1" -Edit-> "10." -Auto Format-> "10.0". return control.text } + + if (( propertyProvider.properties.resolve != "None" && propertyProvider.properties.resolve) && ( propertyProvider.properties.stackLevels[0] != 0) && ( propertyProvider.properties.stackLevels[0] != 1)) + { + // We have a resolve function. Indicates that the setting is not settable per extruder and that + // we have to choose between the resolved value (default) and the global value + // (if user has explicitly set this). + return base.resolve + } + return propertyProvider.properties.value } @@ -36,8 +49,8 @@ UM.TextField property UM.SettingPropertyProvider propertyProvider: UM.SettingPropertyProvider { id: propertyProvider - containerStack: Cura.MachineManager.activeMachine - watchedProperties: [ "value", "validationState" ] + watchedProperties: [ "value", "validationState", "resolve" ] + containerStackId: updateAllExtruders ? Cura.ExtruderManager.extruderIds[0] : Cura.MachineManager.activeMachine } Connections @@ -51,7 +64,7 @@ UM.TextField // textfield styling while typing. Keys.onReleased: updateTimer.restart() // Forces formatting when you finish editing "10.1" -Edit-> "10." -Focus Change-> "10" - onActiveFocusChanged: updateTime.restart() + onActiveFocusChanged: updateTimer.restart() // Updates to the setting are delayed by interval. This stops lag caused by calling the // parseValueUpdateSetting() function being called repeatedly while changing the text value. @@ -65,13 +78,19 @@ UM.TextField function parseValueUpdateSetting() { - // Do some parsing of text here - updateSetting(text); + if (propertyProvider && text != propertyProvider.properties.value) + { + updateSetting(text); + } } function updateSetting(value) { - if (propertyProvider && text != propertyProvider.properties.value) + if (updateAllExtruders) + { + Cura.MachineManager.setSettingForAllExtruders(propertyProvider.key, "value", value) + } + else { propertyProvider.setPropertyValue("value", text) } From d7e1aa08ac155b0ac54340035cdf70267c1592c1 Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Mon, 5 Dec 2022 11:32:24 +0100 Subject: [PATCH 49/82] Update the single setting components to optionally update all extruders when a setting is settable per extruder or limited to extruder. This forces all extruders to have their settings updated but only displays the value from a single extruder. CURA-9793 --- .../RecommendedStrengthSelector.qml | 6 +----- .../qml/Widgets/SingleSettingComboBox.qml | 20 +++++++++++++++--- resources/qml/Widgets/SingleSettingSlider.qml | 21 +++++++++++++++---- .../qml/Widgets/SingleSettingTextField.qml | 9 +++++--- 4 files changed, 41 insertions(+), 15 deletions(-) diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedStrengthSelector.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedStrengthSelector.qml index 61079c8fca..52a2197b99 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedStrengthSelector.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedStrengthSelector.qml @@ -39,6 +39,7 @@ RecommendedSettingSection width: parent.width settingName: "infill_sparse_density" roundToNearestTen: true + updateAllExtruders: true // disable slider when gradual support is enabled enabled: parseInt(infillSteps.properties.value) == 0 @@ -58,11 +59,6 @@ RecommendedSettingSection { width: parent.width settingName: "infill_pattern" - - function updateSetting(value) - { - Cura.MachineManager.setSettingForAllExtruders("infill_pattern", "value", value) - } } }, RecommendedSettingItem diff --git a/resources/qml/Widgets/SingleSettingComboBox.qml b/resources/qml/Widgets/SingleSettingComboBox.qml index 5c56fedb9c..0767c271ca 100644 --- a/resources/qml/Widgets/SingleSettingComboBox.qml +++ b/resources/qml/Widgets/SingleSettingComboBox.qml @@ -11,10 +11,17 @@ import Cura 1.7 as Cura // This ComboBox allows changing of a single setting. Only the setting name has to be passed in to "settingName". // All of the setting updating logic is handled by this component. // This uses the "options" value of a setting to populate the drop down. This will only work for settings with "options" +// If the setting is limited to a single extruder or is settable with different values per extruder use "updateAllExtruders: true" Cura.ComboBox { textRole: "text" property alias settingName: propertyProvider.key + // If true, all extruders will have "settingName" property updated. + // The displayed value will be read from the extruder with index "defaultExtruderIndex" instead of the machine. + property bool updateAllExtruders: false + // This is only used if updateAllExtruders == true + property int defaultExtruderIndex: 0 + model: ListModel { id: comboboxModel @@ -47,8 +54,8 @@ Cura.ComboBox { property UM.SettingPropertyProvider propertyProvider: UM.SettingPropertyProvider { id: propertyProvider - containerStack: Cura.MachineManager.activeMachine - watchedProperties: [ "value" , "options"] + containerStackId: updateAllExtruders ? Cura.ExtruderManager.extruderIds[defaultExtruderIndex] : Cura.MachineManager.activeMachine.id + watchedProperties: ["value" , "options"] } Connections @@ -71,6 +78,13 @@ Cura.ComboBox { function updateSetting(value) { - propertyProvider.setPropertyValue("value", value) + if (updateAllExtruders) + { + Cura.MachineManager.setSettingForAllExtruders(propertyProvider.key, "value", value) + } + else + { + propertyProvider.setPropertyValue("value", value) + } } } diff --git a/resources/qml/Widgets/SingleSettingSlider.qml b/resources/qml/Widgets/SingleSettingSlider.qml index 8fc81f6c2f..f1b0f2c54d 100644 --- a/resources/qml/Widgets/SingleSettingSlider.qml +++ b/resources/qml/Widgets/SingleSettingSlider.qml @@ -11,7 +11,7 @@ import QtQuick.Layouts 1.3 // This silder allows changing of a single setting. Only the setting name has to be passed in to "settingName". // All of the setting updating logic is handled by this component. // This component allows you to choose values between minValue -> maxValue and rounds them to the nearest 10. - +// If the setting is limited to a single extruder or is settable with different values per extruder use "updateAllExtruders: true" RowLayout { height: childrenRect.height @@ -20,6 +20,12 @@ RowLayout property alias settingName: propertyProvider.key property alias enabled: settingSlider.enabled + // If true, all extruders will have "settingName" property updated. + // The displayed value will be read from the extruder with index "defaultExtruderIndex" instead of the machine. + property bool updateAllExtruders: false + // This is only used if updateAllExtruders == true + property int defaultExtruderIndex: 0 + property bool roundToNearestTen: false property int maxValue: 100 property int minValue: 0 @@ -28,8 +34,8 @@ RowLayout UM.SettingPropertyProvider { id: propertyProvider - containerStackId: Cura.MachineManager.activeStackId - watchedProperties: [ "value" ] + containerStackId: updateAllExtruders ? Cura.ExtruderManager.extruderIds[defaultExtruderIndex] : Cura.MachineManager.activeMachine.id + watchedProperties: ["value"] storeIndex: 0 } @@ -99,6 +105,13 @@ RowLayout // Override this function to update a setting differently function updateSetting(value) { - propertyProvider.setPropertyValue("value", value) + if (updateAllExtruders) + { + Cura.MachineManager.setSettingForAllExtruders(propertyProvider.key, "value", value) + } + else + { + propertyProvider.setPropertyValue("value", value) + } } } diff --git a/resources/qml/Widgets/SingleSettingTextField.qml b/resources/qml/Widgets/SingleSettingTextField.qml index f3cc433ace..72edf58681 100644 --- a/resources/qml/Widgets/SingleSettingTextField.qml +++ b/resources/qml/Widgets/SingleSettingTextField.qml @@ -10,14 +10,17 @@ import Cura 1.7 as Cura // This text field allows you to edit a single setting. The setting can be passed by "settingName". // You must specify a validator with Validator. We store our default setting validators in qml/Validators +// If the setting is limited to a single extruder or is settable with different values per extruder use "updateAllExtruders: true" UM.TextField { id: control property alias settingName: propertyProvider.key // If true, all extruders will have "settingName" property updated. - // The displayed value will be read from the first extruder instead of the machine. + // The displayed value will be read from the extruder with index "defaultExtruderIndex" instead of the machine. property bool updateAllExtruders: false + // This is only used if updateAllExtruders == true + property int defaultExtruderIndex: 0 // Resolving the value in the textField. Binding @@ -49,8 +52,8 @@ UM.TextField property UM.SettingPropertyProvider propertyProvider: UM.SettingPropertyProvider { id: propertyProvider - watchedProperties: [ "value", "validationState", "resolve" ] - containerStackId: updateAllExtruders ? Cura.ExtruderManager.extruderIds[0] : Cura.MachineManager.activeMachine + watchedProperties: ["value", "validationState", "resolve"] + containerStackId: updateAllExtruders ? Cura.ExtruderManager.extruderIds[defaultExtruderIndex] : Cura.MachineManager.activeMachine.id } Connections From 29172014ad0f7a095403bca2cf384f09977af3da Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Mon, 5 Dec 2022 11:37:18 +0100 Subject: [PATCH 50/82] Add all new recommended items to ignored custom settings keys. This stops the reset setting button from appearing even though we have changed these settings. CURA-9793 --- cura/Settings/SimpleModeSettingsManager.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cura/Settings/SimpleModeSettingsManager.py b/cura/Settings/SimpleModeSettingsManager.py index af8707f235..44d2ce2cbb 100644 --- a/cura/Settings/SimpleModeSettingsManager.py +++ b/cura/Settings/SimpleModeSettingsManager.py @@ -57,6 +57,12 @@ class SimpleModeSettingsManager(QObject): # changed, we consider it as a user customized profile in the Simple ("Recommended") Mode. __ignored_custom_setting_keys = ["support_enable", "infill_sparse_density", + "infill_pattern", "gradual_infill_steps", + "wall_thickness", + "top_bottom_thickness", + "support_structure", + "support_extruder_nr", + "support_type", "adhesion_type", - "support_extruder_nr"] + "adhesion_extruder_nr"] From 6d474dfe408dabccdcd6412daa83dcc15993ea70 Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Mon, 5 Dec 2022 11:56:22 +0100 Subject: [PATCH 51/82] Remove comments CURA-9793 --- .../qml/MachineSettings/ComboBoxWithOptions.qml | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/resources/qml/MachineSettings/ComboBoxWithOptions.qml b/resources/qml/MachineSettings/ComboBoxWithOptions.qml index 9f5f89dde1..18c8745f17 100644 --- a/resources/qml/MachineSettings/ComboBoxWithOptions.qml +++ b/resources/qml/MachineSettings/ComboBoxWithOptions.qml @@ -85,20 +85,6 @@ UM.TooltipArea currentIndex = i } } -// // Options come in as a string-representation of an OrderedDict -// if(propertyProvider.properties.options) -// { -// var options = propertyProvider.properties.options.match(/^OrderedDict\(\[\((.*)\)\]\)$/); -// if(options) -// { -// options = options[1].split("), ("); -// for(var i = 0; i < options.length; i++) -// { -// var option = options[i].substring(1, options[i].length - 1).split("', '"); -// append({ text: option[1], value: option[0] }); -// } -// } -// } } Component.onCompleted: updateModel() From 741a112282bda591ae42fa2077de33d98f63d7a5 Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Mon, 5 Dec 2022 14:05:22 +0100 Subject: [PATCH 52/82] Remove recommended adhesion selector. CURA-9793 --- .../Recommended/RecommendedAdhesionSelector.qml | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedAdhesionSelector.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedAdhesionSelector.qml index 8a83af10dd..7deef3cd3e 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedAdhesionSelector.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedAdhesionSelector.qml @@ -33,18 +33,4 @@ RecommendedSettingSection function onEnableSectionChanged(state) { curaRecommendedMode.setAdhesion(state) } - - contents: [ - RecommendedSettingItem - { - isCompressed: enableAdhesionRow.isCompressed - settingName: catalog.i18nc("@action:label", "Print with") - tooltipText: catalog.i18nc("adhesion_extruder_nr description", "The extruder train to use for printing the skirt/brim/raft. This is used in multi-extrusion.") - - settingControl: Cura.SingleSettingExtruderSelectorBar - { - extruderSettingName: "adhesion_extruder_nr" - } - } - ] } From ce5691c12dc79b4af1b75bef56f1d3a6d8ec83bf Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Mon, 5 Dec 2022 14:42:35 +0100 Subject: [PATCH 53/82] Apply suggestions from code review Co-authored-by: Jelle Spijker --- .../qml/PrintSetupSelector/PrintSetupSelectorContents.qml | 8 ++++++-- .../Recommended/RecommendedAdhesionSelector.qml | 2 +- .../Recommended/RecommendedPrintSetup.qml | 2 +- .../Recommended/RecommendedSettingItem.qml | 2 +- .../Recommended/RecommendedSettingSection.qml | 4 ++-- .../Recommended/RecommendedStrengthSelector.qml | 2 +- .../Recommended/RecommendedSupportSelector.qml | 3 ++- resources/qml/Validators/FloatValidator.qml | 3 ++- resources/qml/Validators/HexColorValidator.qml | 3 ++- resources/qml/Validators/IntListValidator.qml | 3 ++- resources/qml/Validators/IntValidator.qml | 1 + resources/qml/Widgets/SingleSettingComboBox.qml | 2 +- .../qml/Widgets/SingleSettingExtruderSelectorBar.qml | 3 +++ resources/qml/Widgets/SingleSettingSlider.qml | 3 ++- resources/qml/Widgets/SingleSettingTextField.qml | 2 +- 15 files changed, 28 insertions(+), 15 deletions(-) diff --git a/resources/qml/PrintSetupSelector/PrintSetupSelectorContents.qml b/resources/qml/PrintSetupSelector/PrintSetupSelectorContents.qml index 92f0b1d5be..9d3da51356 100644 --- a/resources/qml/PrintSetupSelector/PrintSetupSelectorContents.qml +++ b/resources/qml/PrintSetupSelector/PrintSetupSelectorContents.qml @@ -68,7 +68,10 @@ Item } visible: currentModeIndex == PrintSetupSelectorContents.Mode.Recommended - function onModeChanged() { currentModeIndex = PrintSetupSelectorContents.Mode.Custom } + function onModeChanged() + { + currentModeIndex = PrintSetupSelectorContents.Mode.Custom; + } } CustomPrintSetup @@ -125,7 +128,8 @@ Item { id: buttonRow property real padding: UM.Theme.getSize("default_margin").width - height: { + height: + { if (currentModeIndex == PrintSetupSelectorContents.Mode.Custom) { return recommendedButton.height + 2 * padding + (draggableArea.visible ? draggableArea.height : 0) diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedAdhesionSelector.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedAdhesionSelector.qml index 7deef3cd3e..3d0c4ac82c 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedAdhesionSelector.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedAdhesionSelector.qml @@ -1,4 +1,4 @@ -// Copyright (c) 2022 UltiMaker B.V. +// Copyright (c) 2022 UltiMaker // Cura is released under the terms of the LGPLv3 or higher. import QtQuick 2.7 diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedPrintSetup.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedPrintSetup.qml index 5231af7232..1149ef220f 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedPrintSetup.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedPrintSetup.qml @@ -1,4 +1,4 @@ -//Copyright (c) 2022 UltiMaker B.V. +// Copyright (c) 2022 UltiMaker //Cura is released under the terms of the LGPLv3 or higher. import QtQuick 2.10 diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedSettingItem.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedSettingItem.qml index 1b5ad8bd17..ca9869db68 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedSettingItem.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedSettingItem.qml @@ -1,4 +1,4 @@ -// Copyright (c) 2022 UltiMaker B.V. +// Copyright (c) 2022 UltiMaker // Cura is released under the terms of the LGPLv3 or higher. import QtQuick 2.10 diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedSettingSection.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedSettingSection.qml index 3bdc3cdd65..a8cfaee79f 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedSettingSection.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedSettingSection.qml @@ -1,4 +1,4 @@ -// Copyright (c) 2022 UltiMaker B.V. +// Copyright (c) 2022 UltiMaker // Cura is released under the terms of the LGPLv3 or higher. import QtQuick 2.10 @@ -17,7 +17,7 @@ Item property alias enableSectionSwitchVisible: enableSectionSwitch.visible property alias enableSectionSwitchChecked: enableSectionSwitch.checked property alias enableSectionSwitchEnabled: enableSectionSwitch.enabled - property string tooltipText: "test" + property string tooltipText: "" property var enableSectionClicked: { return } property int leftColumnWidth: Math.floor(width * 0.35) property bool isCompressed: false diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedStrengthSelector.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedStrengthSelector.qml index 52a2197b99..53a54cdc94 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedStrengthSelector.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedStrengthSelector.qml @@ -1,4 +1,4 @@ -// Copyright (c) 2022 Ultimaker B.V. +// Copyright (c) 2022 Ultimaker // Cura is released under the terms of the LGPLv3 or higher. import QtQuick 2.7 diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedSupportSelector.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedSupportSelector.qml index f7f7df0fe3..457585936f 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedSupportSelector.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedSupportSelector.qml @@ -20,7 +20,8 @@ RecommendedSettingSection enableSectionSwitchEnabled: recommendedPrintSetup.settingsEnabled tooltipText: catalog.i18nc("@label", "Generate structures to support parts of the model which have overhangs. Without these structures, such parts would collapse during printing.") - function onEnableSectionChanged(state) { + function onEnableSectionChanged(state) + { supportEnabled.setPropertyValue("value", state) } diff --git a/resources/qml/Validators/FloatValidator.qml b/resources/qml/Validators/FloatValidator.qml index 62ff981e2e..55f2fbae00 100644 --- a/resources/qml/Validators/FloatValidator.qml +++ b/resources/qml/Validators/FloatValidator.qml @@ -1,5 +1,6 @@ -// Copyright (c) 2022 UltiMaker B.V. +// Copyright (c) 2022 UltiMaker // Cura is released under the terms of the LGPLv3 or higher. + import QtQuick 2.15 RegularExpressionValidator diff --git a/resources/qml/Validators/HexColorValidator.qml b/resources/qml/Validators/HexColorValidator.qml index 2c3ba706ec..4a15000b8a 100644 --- a/resources/qml/Validators/HexColorValidator.qml +++ b/resources/qml/Validators/HexColorValidator.qml @@ -1,5 +1,6 @@ -// Copyright (c) 2022 UltiMaker B.V. +// Copyright (c) 2022 UltiMaker // Cura is released under the terms of the LGPLv3 or higher. + import QtQuick 2.15 RegularExpressionValidator diff --git a/resources/qml/Validators/IntListValidator.qml b/resources/qml/Validators/IntListValidator.qml index 2f5b3c829a..f0b9d790e2 100644 --- a/resources/qml/Validators/IntListValidator.qml +++ b/resources/qml/Validators/IntListValidator.qml @@ -1,5 +1,6 @@ -// Copyright (c) 2022 UltiMaker B.V. +// Copyright (c) 2022 UltiMaker // Cura is released under the terms of the LGPLv3 or higher. + import QtQuick 2.15 RegularExpressionValidator diff --git a/resources/qml/Validators/IntValidator.qml b/resources/qml/Validators/IntValidator.qml index 6b7ced9ce8..29b04ea94c 100644 --- a/resources/qml/Validators/IntValidator.qml +++ b/resources/qml/Validators/IntValidator.qml @@ -1,5 +1,6 @@ // Copyright (c) 2022 UltiMaker B.V. // Cura is released under the terms of the LGPLv3 or higher. + import QtQuick 2.15 RegularExpressionValidator diff --git a/resources/qml/Widgets/SingleSettingComboBox.qml b/resources/qml/Widgets/SingleSettingComboBox.qml index 0767c271ca..9d3f0402c3 100644 --- a/resources/qml/Widgets/SingleSettingComboBox.qml +++ b/resources/qml/Widgets/SingleSettingComboBox.qml @@ -1,4 +1,4 @@ -// Copyright (c) 2022 UltiMaker B.V. +// Copyright (c) 2022 UltiMaker // Cura is released under the terms of the LGPLv3 or higher. import QtQuick 2.10 diff --git a/resources/qml/Widgets/SingleSettingExtruderSelectorBar.qml b/resources/qml/Widgets/SingleSettingExtruderSelectorBar.qml index c4045b57f0..389f70f4f9 100644 --- a/resources/qml/Widgets/SingleSettingExtruderSelectorBar.qml +++ b/resources/qml/Widgets/SingleSettingExtruderSelectorBar.qml @@ -1,3 +1,6 @@ +// Copyright (c) 2022 UltiMaker +// Cura is released under the terms of the LGPLv3 or higher. + import QtQuick 2.12 import QtQuick.Controls 2.12 import QtQuick.Layouts 1.3 diff --git a/resources/qml/Widgets/SingleSettingSlider.qml b/resources/qml/Widgets/SingleSettingSlider.qml index f1b0f2c54d..91ff9c1ed4 100644 --- a/resources/qml/Widgets/SingleSettingSlider.qml +++ b/resources/qml/Widgets/SingleSettingSlider.qml @@ -104,7 +104,8 @@ RowLayout } // Override this function to update a setting differently - function updateSetting(value) { + function updateSetting(value) + { if (updateAllExtruders) { Cura.MachineManager.setSettingForAllExtruders(propertyProvider.key, "value", value) diff --git a/resources/qml/Widgets/SingleSettingTextField.qml b/resources/qml/Widgets/SingleSettingTextField.qml index 72edf58681..4def7f4179 100644 --- a/resources/qml/Widgets/SingleSettingTextField.qml +++ b/resources/qml/Widgets/SingleSettingTextField.qml @@ -1,4 +1,4 @@ -// Copyright (c) 2022 UltiMaker B.V. +// Copyright (c) 2022 UltiMaker // Cura is released under the terms of the LGPLv3 or higher. import QtQuick 2.10 From f034c115be8b28e09e73799a4dc5949996bbf2cf Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Mon, 5 Dec 2022 15:11:48 +0100 Subject: [PATCH 54/82] Rename slider theme items CURA-9793 --- .../resources/qml/MonitorBuildplateConfiguration.qml | 2 +- resources/themes/cura-light/theme.json | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/UM3NetworkPrinting/resources/qml/MonitorBuildplateConfiguration.qml b/plugins/UM3NetworkPrinting/resources/qml/MonitorBuildplateConfiguration.qml index 0bd57e76d8..a81bec3884 100644 --- a/plugins/UM3NetworkPrinting/resources/qml/MonitorBuildplateConfiguration.qml +++ b/plugins/UM3NetworkPrinting/resources/qml/MonitorBuildplateConfiguration.qml @@ -27,7 +27,7 @@ Item Row { height: parent.height - spacing: UM.Theme.getSize("print_setup_slider_handle").width // TODO: Theme! (Should be same as extruder spacing) + spacing: UM.Theme.getSize("slider_handle").width // TODO: Theme! (Should be same as extruder spacing) // This wrapper ensures that the buildplate icon is located centered // below an extruder icon. diff --git a/resources/themes/cura-light/theme.json b/resources/themes/cura-light/theme.json index e61f7938fc..f2d7cbcced 100644 --- a/resources/themes/cura-light/theme.json +++ b/resources/themes/cura-light/theme.json @@ -490,9 +490,9 @@ "print_setup_widget": [38.0, 30.0], "print_setup_extruder_box": [0.0, 6.0], - "print_setup_slider_groove": [0.16, 0.16], - "print_setup_slider_handle": [1.3, 1.3], - "print_setup_slider_tickmarks": [0.3, 0.3], + "slider_groove": [0.16, 0.16], + "slider_handle": [1.3, 1.3], + "slider_tickmarks": [0.3, 0.3], "print_setup_big_item": [28, 2.5], "print_setup_icon": [1.2, 1.2], "drag_icon": [1.416, 0.25], From 80e9f64c85d8bf9af8a1a0065a2711ad254e9240 Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Mon, 5 Dec 2022 15:30:51 +0100 Subject: [PATCH 55/82] Fix overwritten theme name for slider Add property for background ticks. CURA-9793 --- resources/themes/cura-light/theme.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/resources/themes/cura-light/theme.json b/resources/themes/cura-light/theme.json index f2d7cbcced..2cb4aa91db 100644 --- a/resources/themes/cura-light/theme.json +++ b/resources/themes/cura-light/theme.json @@ -490,9 +490,9 @@ "print_setup_widget": [38.0, 30.0], "print_setup_extruder_box": [0.0, 6.0], - "slider_groove": [0.16, 0.16], - "slider_handle": [1.3, 1.3], - "slider_tickmarks": [0.3, 0.3], + "slider_widget_groove": [0.16, 0.16], + "slider_widget_handle": [1.3, 1.3], + "slider_widget_tickmarks": [0.3, 0.3], "print_setup_big_item": [28, 2.5], "print_setup_icon": [1.2, 1.2], "drag_icon": [1.416, 0.25], From 5a415b832442d5144a66d5e5fe6c9bb91d48ca0c Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Mon, 5 Dec 2022 16:55:48 +0100 Subject: [PATCH 56/82] Remove black fill from icons. This fill prevents themeing CURA-9793 --- .../cura-light/icons/default/Hammer.svg | 2 +- .../cura-light/icons/default/PrintWalls.svg | 20 +++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/resources/themes/cura-light/icons/default/Hammer.svg b/resources/themes/cura-light/icons/default/Hammer.svg index 38b2b6a141..c32f27a0e2 100644 --- a/resources/themes/cura-light/icons/default/Hammer.svg +++ b/resources/themes/cura-light/icons/default/Hammer.svg @@ -1,3 +1,3 @@ - + diff --git a/resources/themes/cura-light/icons/default/PrintWalls.svg b/resources/themes/cura-light/icons/default/PrintWalls.svg index 156a87177d..f582a5599d 100644 --- a/resources/themes/cura-light/icons/default/PrintWalls.svg +++ b/resources/themes/cura-light/icons/default/PrintWalls.svg @@ -1,12 +1,12 @@ - - - - - - - - - - + + + + + + + + + + From c495f0de3fa4866e915e57a50e8da2119fb499ec Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Mon, 5 Dec 2022 17:11:05 +0100 Subject: [PATCH 57/82] Hide extruder selector when there is only one extruder. CURA-9793 --- .../Recommended/RecommendedSupportSelector.qml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedSupportSelector.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedSupportSelector.qml index 457585936f..50bfbcbbcf 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedSupportSelector.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedSupportSelector.qml @@ -68,10 +68,14 @@ RecommendedSettingSection Layout.preferredHeight: childrenRect.height settingName: catalog.i18nc("@action:label", "Print with") tooltipText: catalog.i18nc("support_extruder_nr description", "The extruder train to use for printing the support. This is used in multi-extrusion.") - isCompressed: enableSupportRow.isCompressed + // Hide this component when there is only one extruder + enabled: machineExtruderCount.properties.value > 1 + visible: machineExtruderCount.properties.value > 1 + isCompressed: enableSupportRow.isCompressed || machineExtruderCount.properties.value <= 1 settingControl: Cura.SingleSettingExtruderSelectorBar { + extruderSettingName: "support_extruder_nr" } }, From 3ddebe7a84b5e6fa4f3a7b95aec7c2838c2b18a8 Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Tue, 6 Dec 2022 10:37:06 +0100 Subject: [PATCH 58/82] The extrudersCHanged signal was incorrectly being emitted before the global stack had updated. This was causing the extruderIds to always return the old extruderIds to connected qml components. The setting slider was incorrectly setting the slider value when updating the model. CURA-9793 --- cura/Settings/ExtruderManager.py | 12 ++++++++---- .../Recommended/RecommendedStrengthSelector.qml | 1 + resources/qml/Widgets/SingleSettingSlider.qml | 2 -- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/cura/Settings/ExtruderManager.py b/cura/Settings/ExtruderManager.py index f429a0de19..aff1498a2a 100755 --- a/cura/Settings/ExtruderManager.py +++ b/cura/Settings/ExtruderManager.py @@ -2,13 +2,14 @@ # Cura is released under the terms of the LGPLv3 or higher. from PyQt6.QtCore import pyqtSignal, pyqtProperty, QObject, QVariant # For communicating data and events to Qt. + +from UM.Application import Application from UM.FlameProfiler import pyqtSlot import cura.CuraApplication # To get the global container stack to find the current machine. from cura.Settings.GlobalStack import GlobalStack from UM.Logger import Logger from UM.Scene.Iterator.DepthFirstIterator import DepthFirstIterator -from UM.Scene.SceneNode import SceneNode from UM.Scene.Selection import Selection from UM.Scene.Iterator.BreadthFirstIterator import BreadthFirstIterator from UM.Settings.ContainerRegistry import ContainerRegistry # Finding containers by ID. @@ -45,13 +46,18 @@ class ExtruderManager(QObject): self._selected_object_extruders = [] # type: List[Union[str, "ExtruderStack"]] Selection.selectionChanged.connect(self.resetSelectedObjectExtruders) + Application.getInstance().globalContainerStackChanged.connect(self.emitExtrudersChanged) # When the machine is swapped we must update the active machine extruders - extrudersChanged = pyqtSignal(QVariant) + extrudersChanged = pyqtSignal() """Signal to notify other components when the list of extruders for a machine definition changes.""" activeExtruderChanged = pyqtSignal() """Notify when the user switches the currently active extruder.""" + def emitExtrudersChanged(self): + # The emit function can't be directly connected to another signal. This wrapper function is required. + self.extrudersChanged.emit() + @pyqtProperty(str, notify = activeExtruderChanged) def activeExtruderStackId(self) -> Optional[str]: """Gets the unique identifier of the currently active extruder stack. @@ -375,8 +381,6 @@ class ExtruderManager(QObject): extruders_changed = True self.fixSingleExtrusionMachineExtruderDefinition(global_stack) - if extruders_changed: - self.extrudersChanged.emit(global_stack_id) # After 3.4, all single-extrusion machines have their own extruder definition files instead of reusing # "fdmextruder". We need to check a machine here so its extruder definition is correct according to this. diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedStrengthSelector.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedStrengthSelector.qml index 53a54cdc94..7424aed01c 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedStrengthSelector.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedStrengthSelector.qml @@ -59,6 +59,7 @@ RecommendedSettingSection { width: parent.width settingName: "infill_pattern" + updateAllExtruders: true } }, RecommendedSettingItem diff --git a/resources/qml/Widgets/SingleSettingSlider.qml b/resources/qml/Widgets/SingleSettingSlider.qml index 91ff9c1ed4..24692f75fc 100644 --- a/resources/qml/Widgets/SingleSettingSlider.qml +++ b/resources/qml/Widgets/SingleSettingSlider.qml @@ -83,9 +83,7 @@ RowLayout function roundSliderValueUpdateSetting() { // If the user interacts with the slider we round the value and update the setting. - print("roundSliderValueUpdateSetting()") const roundedSliderValue = roundToNearestTen ? Math.round(settingSlider.value / 10) * 10 : Math.round(settingSlider.value) - settingSlider.value = roundedSliderValue updateSetting(roundedSliderValue) } From ea5d4a8211c6b89ba01540b27100916b3d30ca29 Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Tue, 6 Dec 2022 10:38:49 +0100 Subject: [PATCH 59/82] Make tickmarks bigger to avoid issues with pixel rounding errors causing the tickmarks to appear above or below the background line. CURA-9793 --- resources/themes/cura-light/theme.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/themes/cura-light/theme.json b/resources/themes/cura-light/theme.json index 2cb4aa91db..6bf89a92fa 100644 --- a/resources/themes/cura-light/theme.json +++ b/resources/themes/cura-light/theme.json @@ -492,7 +492,7 @@ "print_setup_extruder_box": [0.0, 6.0], "slider_widget_groove": [0.16, 0.16], "slider_widget_handle": [1.3, 1.3], - "slider_widget_tickmarks": [0.3, 0.3], + "slider_widget_tickmarks": [0.5, 0.5], "print_setup_big_item": [28, 2.5], "print_setup_icon": [1.2, 1.2], "drag_icon": [1.416, 0.25], From 362877dee13d25bf64e5e9db26b7f884b48cbc5c Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Tue, 6 Dec 2022 10:50:04 +0100 Subject: [PATCH 60/82] Add new recommended mode tooltips and remove extra margin at the bottom of tooltips. CURA-9793 --- .../Recommended/RecommendedStrengthSelector.qml | 6 ++++-- .../Recommended/RecommendedSupportSelector.qml | 6 +++--- resources/qml/PrintSetupTooltip.qml | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedStrengthSelector.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedStrengthSelector.qml index 7424aed01c..086f9a7728 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedStrengthSelector.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedStrengthSelector.qml @@ -17,7 +17,7 @@ RecommendedSettingSection icon: UM.Theme.getIcon("Hammer") enableSectionSwitchVisible: false enableSectionSwitchEnabled: false - tooltipText: "" + tooltipText: catalog.i18nc("@label", "The following settings define the strength of your part.") UM.SettingPropertyProvider { @@ -53,7 +53,8 @@ RecommendedSettingSection RecommendedSettingItem { settingName: catalog.i18nc("@action:label", "Infill Pattern") - tooltipText: catalog.i18nc("infill_pattern description", "The pattern of the infill material of the print. The line and zig zag infill swap direction on alternate layers, reducing material cost. The grid, triangle, tri-hexagon, cubic, octet, quarter cubic, cross and concentric patterns are fully printed every layer. Gyroid, cubic, quarter cubic and octet infill change with every layer to provide a more equal distribution of strength over each direction. Lightning infill tries to minimize the infill, by only supporting the ceiling of the object.") + tooltipText: catalog.i18nc("@label", + "The pattern of the infill material of the print:\n\nFor quick prints of non functional model choose line, zig zag or lighting infill.\n\nFor functional part not subjected to a lot of stress we reccomend grid or triangle or tri hexagon.\n\nFor functional 3D prints which require high strenght in multiple directions use cubic, cubic subdivision, quarter cubic, octet, and gyroid.") settingControl: Cura.SingleSettingComboBox { @@ -65,6 +66,7 @@ RecommendedSettingSection RecommendedSettingItem { settingName: catalog.i18nc("@action:label", "Shell Thickness") + tooltipText: catalog.i18nc("@label", "Defines the tickness of your part side walls, roof and floor.") settingControl: RowLayout { diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedSupportSelector.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedSupportSelector.qml index 50bfbcbbcf..e9c4ff69cd 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedSupportSelector.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedSupportSelector.qml @@ -18,7 +18,7 @@ RecommendedSettingSection enableSectionSwitchVisible: supportEnabled.properties.enabled == "True" enableSectionSwitchChecked: supportEnabled.properties.value == "True" enableSectionSwitchEnabled: recommendedPrintSetup.settingsEnabled - tooltipText: catalog.i18nc("@label", "Generate structures to support parts of the model which have overhangs. Without these structures, such parts would collapse during printing.") + tooltipText: catalog.i18nc("@label", "Generate structures to support parts of the model which have overhangs. Without these structures, these parts would collapse during printing.") function onEnableSectionChanged(state) { @@ -54,7 +54,7 @@ RecommendedSettingSection RecommendedSettingItem { settingName: catalog.i18nc("@action:label", "Support Type") - tooltipText: catalog.i18nc("support_structure description", "Chooses between the techniques available to generate support. \"Normal\" support creates a support structure directly below the overhanging parts and drops those areas straight down. \"Tree\" support creates branches towards the overhanging areas that support the model on the tips of those branches, and allows the branches to crawl around the model to support it from the build plate as much as possible.") + tooltipText: catalog.i18nc("@label", "Chooses between the techniques available to generate support. \n\n\"Normal\" support creates a support structure directly below the overhanging parts and drops those areas straight down. \n\n\"Tree\" support creates branches towards the overhanging areas that support the model on the tips of those branches, and allows the branches to crawl around the model to support it from the build plate as much as possible.") isCompressed: enableSupportRow.isCompressed settingControl: Cura.SingleSettingComboBox @@ -67,7 +67,7 @@ RecommendedSettingSection { Layout.preferredHeight: childrenRect.height settingName: catalog.i18nc("@action:label", "Print with") - tooltipText: catalog.i18nc("support_extruder_nr description", "The extruder train to use for printing the support. This is used in multi-extrusion.") + tooltipText: catalog.i18nc("@label", "The extruder train to use for printing the support. This is used in multi-extrusion.") // Hide this component when there is only one extruder enabled: machineExtruderCount.properties.value > 1 visible: machineExtruderCount.properties.value > 1 diff --git a/resources/qml/PrintSetupTooltip.qml b/resources/qml/PrintSetupTooltip.qml index af4280342c..195f7fb204 100644 --- a/resources/qml/PrintSetupTooltip.qml +++ b/resources/qml/PrintSetupTooltip.qml @@ -11,7 +11,7 @@ UM.PointingRectangle id: base property real sourceWidth: 0 width: UM.Theme.getSize("tooltip").width - height: textScroll.height + UM.Theme.getSize("tooltip_margins").height * 2 + height: textScroll.height + UM.Theme.getSize("tooltip_margins").height color: UM.Theme.getColor("tooltip") arrowSize: UM.Theme.getSize("default_arrow").width From 93d1f05aec2c4ef45ebfe7db4846505964344dd6 Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Tue, 6 Dec 2022 12:07:07 +0100 Subject: [PATCH 61/82] Remove ignored changes list. All changes will now trigger the reset setting button to appear CURA-9793 --- cura/Settings/SimpleModeSettingsManager.py | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/cura/Settings/SimpleModeSettingsManager.py b/cura/Settings/SimpleModeSettingsManager.py index 44d2ce2cbb..7ea21ed295 100644 --- a/cura/Settings/SimpleModeSettingsManager.py +++ b/cura/Settings/SimpleModeSettingsManager.py @@ -42,27 +42,8 @@ class SimpleModeSettingsManager(QObject): for extruder_stack in global_stack.extruderList: user_setting_keys.update(extruder_stack.userChanges.getAllKeys()) - # remove settings that are visible in recommended (we don't show the reset button for those) - for skip_key in self.__ignored_custom_setting_keys: - if skip_key in user_setting_keys: - user_setting_keys.remove(skip_key) - has_customized_user_settings = len(user_setting_keys) > 0 if has_customized_user_settings != self._is_profile_customized: self._is_profile_customized = has_customized_user_settings self.isProfileCustomizedChanged.emit() - - # These are the settings included in the Simple ("Recommended") Mode, so only when the other settings have been - # changed, we consider it as a user customized profile in the Simple ("Recommended") Mode. - __ignored_custom_setting_keys = ["support_enable", - "infill_sparse_density", - "infill_pattern", - "gradual_infill_steps", - "wall_thickness", - "top_bottom_thickness", - "support_structure", - "support_extruder_nr", - "support_type", - "adhesion_type", - "adhesion_extruder_nr"] From bec02cf312e08888006850a3ff41e6a279647f32 Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Tue, 6 Dec 2022 12:08:00 +0100 Subject: [PATCH 62/82] Fix extruder icon text scaling. I've added a new font size here since there is not any real way I can see to scale the font based on the component size. This is because we do some magic with the font numbers before passing them to the QML. CURA-9793 --- resources/qml/ExtruderButton.qml | 2 ++ resources/qml/ExtruderIcon.qml | 1 + resources/qml/Toolbar.qml | 1 + .../SingleSettingExtruderSelectorBar.qml | 1 + resources/themes/cura-light/theme.json | 20 +++++++++++++++++++ 5 files changed, 25 insertions(+) diff --git a/resources/qml/ExtruderButton.qml b/resources/qml/ExtruderButton.qml index df1a72e765..3ad77660c6 100644 --- a/resources/qml/ExtruderButton.qml +++ b/resources/qml/ExtruderButton.qml @@ -12,12 +12,14 @@ UM.ToolbarButton id: base property var extruder + property var extrdurerNumberFont: UM.Theme.getFont("small_emphasis") toolItem: ExtruderIcon { materialColor: extruder.color extruderEnabled: extruder.stack.isEnabled iconVariant: "default" + font: extruderNumberFont property int index: extruder.index } diff --git a/resources/qml/ExtruderIcon.qml b/resources/qml/ExtruderIcon.qml index 718f1bcd87..c59521cdc3 100644 --- a/resources/qml/ExtruderIcon.qml +++ b/resources/qml/ExtruderIcon.qml @@ -14,6 +14,7 @@ Item property bool extruderEnabled: true property var iconSize: UM.Theme.getSize("extruder_icon").width property string iconVariant: "medium" + property alias font: extruderNumberText.font implicitWidth: iconSize implicitHeight: iconSize diff --git a/resources/qml/Toolbar.qml b/resources/qml/Toolbar.qml index e003c6cd6f..894f280240 100644 --- a/resources/qml/Toolbar.qml +++ b/resources/qml/Toolbar.qml @@ -142,6 +142,7 @@ Item text: catalog.i18ncp("@label %1 is filled in with the name of an extruder", "Print Selected Model with %1", "Print Selected Models with %1", UM.Selection.selectionCount).arg(extruder.name) checked: Cura.ExtruderManager.selectedObjectExtruders.indexOf(extruder.id) != -1 enabled: UM.Selection.hasSelection && extruder.stack.isEnabled + font: UM.Theme.getFont("small_emphasis") onClicked: { diff --git a/resources/qml/Widgets/SingleSettingExtruderSelectorBar.qml b/resources/qml/Widgets/SingleSettingExtruderSelectorBar.qml index 389f70f4f9..80f77304c3 100644 --- a/resources/qml/Widgets/SingleSettingExtruderSelectorBar.qml +++ b/resources/qml/Widgets/SingleSettingExtruderSelectorBar.qml @@ -61,6 +61,7 @@ Row extruder: model checked: extruder.index == selectedIndex iconScale: 0.8 + font: UM.Theme.getFont("tiny_emphasis") buttonSize: UM.Theme.getSize("small_button").width onClicked: extruder.enabled && onClickExtruder(extruder.index) } diff --git a/resources/themes/cura-light/theme.json b/resources/themes/cura-light/theme.json index 6bf89a92fa..ad32573288 100644 --- a/resources/themes/cura-light/theme.json +++ b/resources/themes/cura-light/theme.json @@ -172,6 +172,26 @@ "size": 0.9, "weight": 700, "family": "Noto Sans" + }, + "tiny_emphasis": { + "size": 0.7, + "weight": 700, + "family": "Noto Sans" + }, + "tiny_emphasis_ja_JP": { + "size": 0.7, + "weight": 700, + "family": "Noto Sans" + }, + "tiny_emphasis_zh_CN": { + "size": 0.7, + "weight": 700, + "family": "Noto Sans" + }, + "tiny_emphasis_zh_TW": { + "size": 0.7, + "weight": 700, + "family": "Noto Sans" } }, From d8cf234a17507c46ecb913f0166f65135e033946 Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Wed, 7 Dec 2022 12:25:33 +0100 Subject: [PATCH 63/82] Use different signal for triggering update to extrduderIds. **This is a hack**. Actually fixing this problem could take days. CURA-9793 --- cura/Settings/ExtruderManager.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/cura/Settings/ExtruderManager.py b/cura/Settings/ExtruderManager.py index aff1498a2a..dec4a74d27 100755 --- a/cura/Settings/ExtruderManager.py +++ b/cura/Settings/ExtruderManager.py @@ -46,17 +46,22 @@ class ExtruderManager(QObject): self._selected_object_extruders = [] # type: List[Union[str, "ExtruderStack"]] Selection.selectionChanged.connect(self.resetSelectedObjectExtruders) - Application.getInstance().globalContainerStackChanged.connect(self.emitExtrudersChanged) # When the machine is swapped we must update the active machine extruders + Application.getInstance().globalContainerStackChanged.connect(self.emitGlobalStackExtrudersChanged) # When the machine is swapped we must update the active machine extruders - extrudersChanged = pyqtSignal() + # Don't use this unless you are reading from ExtruderManager.extruderIds when receiving the signal + globalStackExtrudersChanged = pyqtSignal() + + # This signal actually emits before the global stacks extruders are updated, changing this behaviour breaks too many things + # Use globalStackExtrudersChanged = pyqtSignal() if you want a trigger when the extrduerIds property changes. + extrudersChanged = pyqtSignal(QVariant) """Signal to notify other components when the list of extruders for a machine definition changes.""" activeExtruderChanged = pyqtSignal() """Notify when the user switches the currently active extruder.""" - def emitExtrudersChanged(self): + def emitGlobalStackExtrudersChanged(self): # The emit function can't be directly connected to another signal. This wrapper function is required. - self.extrudersChanged.emit() + self.globalStackExtrudersChanged.emit() @pyqtProperty(str, notify = activeExtruderChanged) def activeExtruderStackId(self) -> Optional[str]: @@ -381,6 +386,8 @@ class ExtruderManager(QObject): extruders_changed = True self.fixSingleExtrusionMachineExtruderDefinition(global_stack) + if extruders_changed: + self.extrudersChanged.emit(global_stack_id) # After 3.4, all single-extrusion machines have their own extruder definition files instead of reusing # "fdmextruder". We need to check a machine here so its extruder definition is correct according to this. From 396057a56f4305ec711bb6ff918b1f6a4ab969fa Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Wed, 7 Dec 2022 16:14:17 +0100 Subject: [PATCH 64/82] Correct typo in name CURA-9793 --- resources/qml/ExtruderButton.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/qml/ExtruderButton.qml b/resources/qml/ExtruderButton.qml index 3ad77660c6..9a760bafc9 100644 --- a/resources/qml/ExtruderButton.qml +++ b/resources/qml/ExtruderButton.qml @@ -12,7 +12,7 @@ UM.ToolbarButton id: base property var extruder - property var extrdurerNumberFont: UM.Theme.getFont("small_emphasis") + property var extruderNumberFont: UM.Theme.getFont("small_emphasis") toolItem: ExtruderIcon { From 0e5ad96207c8dab6efebd5e799460469c5621ea9 Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Wed, 7 Dec 2022 16:15:09 +0100 Subject: [PATCH 65/82] Fix bad call to keys function on string. Also fix assigning currentIndex to correct Component. CURA-9793 --- resources/qml/MachineSettings/ComboBoxWithOptions.qml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/resources/qml/MachineSettings/ComboBoxWithOptions.qml b/resources/qml/MachineSettings/ComboBoxWithOptions.qml index 18c8745f17..2c82f07c6f 100644 --- a/resources/qml/MachineSettings/ComboBoxWithOptions.qml +++ b/resources/qml/MachineSettings/ComboBoxWithOptions.qml @@ -74,6 +74,12 @@ UM.TooltipArea return } + if (typeof propertyProvider.properties["options"] == "string") + { + return + } + + for (var i = 0; i < propertyProvider.properties["options"].keys().length; i++) { var key = propertyProvider.properties["options"].keys()[i] @@ -82,7 +88,7 @@ UM.TooltipArea if (propertyProvider.properties.value == key) { - currentIndex = i + comboBox.currentIndex = i } } } @@ -126,7 +132,7 @@ UM.TooltipArea onActivated: { var newValue = model.get(index).value - if (propertyProvider.properties.value != newValue) + if (propertyProvider.properties.value != newValue && newValue != undefined) { if (setValueFunction !== null) { @@ -134,6 +140,7 @@ UM.TooltipArea } else { + print("SETTING PROPERTY VALUE: " + newValue) propertyProvider.setPropertyValue("value", newValue) } forceUpdateOnChangeFunction() From f6012293907f8e930ebb3a8c65459381e8785fa5 Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Wed, 7 Dec 2022 16:27:42 +0100 Subject: [PATCH 66/82] Move Validators to UM, so they can be used in UM components. Update all TextFieldWithUnit to use our FloatValidator. This component now has proper styling when the input is invalid. The DoubleValidator was flagging numbers with a "." in them as an incorrect input (I assume this is because the region was set to europe on the OS where "," is common). The workaround is to use our FloatValidator which validates both "." and "," CURA-9793 --- resources/qml/ColorDialog.qml | 8 ++++---- .../Recommended/RecommendedStrengthSelector.qml | 4 ++-- resources/qml/Validators/FloatValidator.qml | 12 ------------ resources/qml/Validators/HexColorValidator.qml | 9 --------- resources/qml/Validators/IntListValidator.qml | 9 --------- resources/qml/Validators/IntValidator.qml | 11 ----------- resources/qml/qmldir | 6 ------ 7 files changed, 6 insertions(+), 53 deletions(-) delete mode 100644 resources/qml/Validators/FloatValidator.qml delete mode 100644 resources/qml/Validators/HexColorValidator.qml delete mode 100644 resources/qml/Validators/IntListValidator.qml delete mode 100644 resources/qml/Validators/IntValidator.qml diff --git a/resources/qml/ColorDialog.qml b/resources/qml/ColorDialog.qml index 94416d77d2..36da26158d 100644 --- a/resources/qml/ColorDialog.qml +++ b/resources/qml/ColorDialog.qml @@ -1,4 +1,4 @@ -// Copyright (c) 2022 Ultimaker B.V. +// Copyright (c) 2022 UltiMaker // Cura is released under the terms of the LGPLv3 or higher. import QtQuick 2.15 @@ -6,8 +6,8 @@ import QtQuick.Controls 2.2 import QtQuick.Window 2.1 import QtQuick.Layouts 1.1 -import UM 1.5 as UM -import Cura 1.1 as Cura +import UM 1.7 as UM +import Cura 1.7 as Cura /* @@ -119,7 +119,7 @@ UM.Dialog text = `#${text}`; } } - validator: Cura.HexColorValidator {} + validator: UM.HexColorValidator {} } Rectangle diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedStrengthSelector.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedStrengthSelector.qml index 086f9a7728..4adca95102 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedStrengthSelector.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedStrengthSelector.qml @@ -81,7 +81,7 @@ RecommendedSettingSection width: parent.width settingName: "wall_thickness" updateAllExtruders: true - validator: Cura.FloatValidator {} + validator: UM.FloatValidator {} unitText: catalog.i18nc("@label", "mm") } } @@ -94,7 +94,7 @@ RecommendedSettingSection width: parent.width settingName: "top_bottom_thickness" updateAllExtruders: true - validator: Cura.FloatValidator {} + validator: UM.FloatValidator {} unitText: catalog.i18nc("@label", "mm") } } diff --git a/resources/qml/Validators/FloatValidator.qml b/resources/qml/Validators/FloatValidator.qml deleted file mode 100644 index 55f2fbae00..0000000000 --- a/resources/qml/Validators/FloatValidator.qml +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright (c) 2022 UltiMaker -// Cura is released under the terms of the LGPLv3 or higher. - -import QtQuick 2.15 - -RegularExpressionValidator -{ - property int maxBeforeDecimal: 11 - property int maxAfterDecimal: 3 - - regularExpression: new RegExp("^-?[0-9]{0,%0}[.,]?[0-9]{0,%1}$".arg(maxBeforeDecimal).arg(maxAfterDecimal)) -} \ No newline at end of file diff --git a/resources/qml/Validators/HexColorValidator.qml b/resources/qml/Validators/HexColorValidator.qml deleted file mode 100644 index 4a15000b8a..0000000000 --- a/resources/qml/Validators/HexColorValidator.qml +++ /dev/null @@ -1,9 +0,0 @@ -// Copyright (c) 2022 UltiMaker -// Cura is released under the terms of the LGPLv3 or higher. - -import QtQuick 2.15 - -RegularExpressionValidator -{ - regularExpression: /^#([a-fA-F0-9]{0,6})$/ -} \ No newline at end of file diff --git a/resources/qml/Validators/IntListValidator.qml b/resources/qml/Validators/IntListValidator.qml deleted file mode 100644 index f0b9d790e2..0000000000 --- a/resources/qml/Validators/IntListValidator.qml +++ /dev/null @@ -1,9 +0,0 @@ -// Copyright (c) 2022 UltiMaker -// Cura is released under the terms of the LGPLv3 or higher. - -import QtQuick 2.15 - -RegularExpressionValidator -{ - regularExpression: new RegExp("^\[?(\s*-?[0-9]{0,11}\s*,)*(\s*-?[0-9]{0,11})\s*\]?$") -} \ No newline at end of file diff --git a/resources/qml/Validators/IntValidator.qml b/resources/qml/Validators/IntValidator.qml deleted file mode 100644 index 29b04ea94c..0000000000 --- a/resources/qml/Validators/IntValidator.qml +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright (c) 2022 UltiMaker B.V. -// Cura is released under the terms of the LGPLv3 or higher. - -import QtQuick 2.15 - -RegularExpressionValidator -{ - property int maxNumbers: 12 - - regularExpression: new RegExp("^-?[0-9]{0,%0}$".arg(maxNumbers)) -} \ No newline at end of file diff --git a/resources/qml/qmldir b/resources/qml/qmldir index 109cbc0823..8fce82c858 100644 --- a/resources/qml/qmldir +++ b/resources/qml/qmldir @@ -19,12 +19,6 @@ SettingView 1.0 SettingView.qml ProfileMenu 1.0 ProfileMenu.qml PrintSelectorCard 1.0 PrintSelectorCard.qml -# Cura/Validators -FloatValidator 1.7 FloatValidator.qml -IntValidator 1.7 IntValidator -IntListValidator 1.7 IntListValidator -HexColorValidator 1.7 HexColorValidator.qml - # Cura/WelcomePages WizardPanel 1.0 WizardPanel.qml From 443252ae10765a0d33facc31a00414df85da78f8 Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Wed, 7 Dec 2022 16:57:35 +0100 Subject: [PATCH 67/82] =?UTF-8?q?Use=20globalStackExtruderIds=20instead=20?= =?UTF-8?q?of=20extruderIds.=20extruderIds=20notifys=20change=20before=20t?= =?UTF-8?q?he=20extruders=20change=20when=20doing=20a=20machine=20swap.=20?= =?UTF-8?q?Fixing=20this=20will=20take=20a=20long=20time=20so=20this=20is?= =?UTF-8?q?=20a=20workaround.=20If=20you=20are=20reading=20this=20?= =?UTF-8?q?=F0=9F=99=8F=20good=20luck=20fixing=20it=20=F0=9F=99=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CURA-9793 --- cura/Settings/ExtruderManager.py | 7 +++++++ resources/qml/Widgets/SingleSettingComboBox.qml | 2 +- resources/qml/Widgets/SingleSettingSlider.qml | 2 +- resources/qml/Widgets/SingleSettingTextField.qml | 2 +- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/cura/Settings/ExtruderManager.py b/cura/Settings/ExtruderManager.py index dec4a74d27..8d38c7d46e 100755 --- a/cura/Settings/ExtruderManager.py +++ b/cura/Settings/ExtruderManager.py @@ -63,6 +63,13 @@ class ExtruderManager(QObject): # The emit function can't be directly connected to another signal. This wrapper function is required. self.globalStackExtrudersChanged.emit() + @pyqtProperty("QVariantMap", notify = globalStackExtrudersChanged) + def globalStackExtruderIds(self) -> Dict[str, str]: + # The extruderIds property notifys changed before the extruders are changed on switching machines + # trying to fix this broke to many things. This is a workaround. Don't use this unless you need to read + # extruderIds directly after a machine update. + return self.extruderIds + @pyqtProperty(str, notify = activeExtruderChanged) def activeExtruderStackId(self) -> Optional[str]: """Gets the unique identifier of the currently active extruder stack. diff --git a/resources/qml/Widgets/SingleSettingComboBox.qml b/resources/qml/Widgets/SingleSettingComboBox.qml index 9d3f0402c3..95b2c5d86a 100644 --- a/resources/qml/Widgets/SingleSettingComboBox.qml +++ b/resources/qml/Widgets/SingleSettingComboBox.qml @@ -54,7 +54,7 @@ Cura.ComboBox { property UM.SettingPropertyProvider propertyProvider: UM.SettingPropertyProvider { id: propertyProvider - containerStackId: updateAllExtruders ? Cura.ExtruderManager.extruderIds[defaultExtruderIndex] : Cura.MachineManager.activeMachine.id + containerStackId: updateAllExtruders ? Cura.ExtruderManager.globalStackExtruderIds[defaultExtruderIndex] : Cura.MachineManager.activeMachine.id watchedProperties: ["value" , "options"] } diff --git a/resources/qml/Widgets/SingleSettingSlider.qml b/resources/qml/Widgets/SingleSettingSlider.qml index 24692f75fc..2dbb104032 100644 --- a/resources/qml/Widgets/SingleSettingSlider.qml +++ b/resources/qml/Widgets/SingleSettingSlider.qml @@ -34,7 +34,7 @@ RowLayout UM.SettingPropertyProvider { id: propertyProvider - containerStackId: updateAllExtruders ? Cura.ExtruderManager.extruderIds[defaultExtruderIndex] : Cura.MachineManager.activeMachine.id + containerStackId: updateAllExtruders ? Cura.ExtruderManager.globalStackExtruderIds[defaultExtruderIndex] : Cura.MachineManager.activeMachine.id watchedProperties: ["value"] storeIndex: 0 } diff --git a/resources/qml/Widgets/SingleSettingTextField.qml b/resources/qml/Widgets/SingleSettingTextField.qml index 4def7f4179..6d9586caa5 100644 --- a/resources/qml/Widgets/SingleSettingTextField.qml +++ b/resources/qml/Widgets/SingleSettingTextField.qml @@ -53,7 +53,7 @@ UM.TextField { id: propertyProvider watchedProperties: ["value", "validationState", "resolve"] - containerStackId: updateAllExtruders ? Cura.ExtruderManager.extruderIds[defaultExtruderIndex] : Cura.MachineManager.activeMachine.id + containerStackId: updateAllExtruders ? Cura.ExtruderManager.globalStackExtruderIds[defaultExtruderIndex] : Cura.MachineManager.activeMachine.id } Connections From 8012cb5360722161553e3469ca7bd2a8d9314c7a Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Wed, 7 Dec 2022 17:16:26 +0100 Subject: [PATCH 68/82] Signal are being emmitted before settings are updated. This is causing the combobox to update with the previous value. Only when using infill_pattern setting though. No idea what is causing this. This is a workaround for now. CURA-9793 --- .../qml/Widgets/SingleSettingComboBox.qml | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/resources/qml/Widgets/SingleSettingComboBox.qml b/resources/qml/Widgets/SingleSettingComboBox.qml index 95b2c5d86a..0055c00262 100644 --- a/resources/qml/Widgets/SingleSettingComboBox.qml +++ b/resources/qml/Widgets/SingleSettingComboBox.qml @@ -44,6 +44,10 @@ Cura.ComboBox { if (propertyProvider.properties.value == key) { + print("propertyProvider.properties.value: " + propertyProvider.properties.value) + print("key: " + key) + print("currentIndex: " + currentIndex) + print("i: " + i) // The combobox is cleared after each value change so the currentIndex must be set each time. currentIndex = i } @@ -51,6 +55,17 @@ Cura.ComboBox { } } + // Updates to the setting are delayed by interval. The signal onIsValueUsedChanged() is emitted early for some reason. + // This causes the selected value in the combobox to be updated to the previous value. (This issue is present with infill_pattern setting) + // This is a hack. If you see this in the future, try removing it and see if the combobox still works. + Timer + { + id: updateTimer + interval: 100 + repeat: false + onTriggered: comboboxModel.updateModel(false) + } + property UM.SettingPropertyProvider propertyProvider: UM.SettingPropertyProvider { id: propertyProvider @@ -61,8 +76,8 @@ Cura.ComboBox { Connections { target: propertyProvider - function onContainerStackChanged() { comboboxModel.updateModel() } - function onIsValueUsedChanged() { comboboxModel.updateModel() } + function onContainerStackChanged() { updateTimer.restart() } + function onIsValueUsedChanged() { updateTimer.restart() } } onCurrentIndexChanged: parseValueAndUpdateSetting() @@ -80,6 +95,7 @@ Cura.ComboBox { { if (updateAllExtruders) { + print("UPDATING ALL WITH VALUE: " + value) Cura.MachineManager.setSettingForAllExtruders(propertyProvider.key, "value", value) } else From ca0cd5069b781485088c10a1645676d7ea866e17 Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Wed, 7 Dec 2022 17:30:12 +0100 Subject: [PATCH 69/82] Remove leftover print statements CURA-9793 --- resources/qml/MachineSettings/ComboBoxWithOptions.qml | 1 - resources/qml/Widgets/SingleSettingComboBox.qml | 5 ----- 2 files changed, 6 deletions(-) diff --git a/resources/qml/MachineSettings/ComboBoxWithOptions.qml b/resources/qml/MachineSettings/ComboBoxWithOptions.qml index 2c82f07c6f..33ec84aaa2 100644 --- a/resources/qml/MachineSettings/ComboBoxWithOptions.qml +++ b/resources/qml/MachineSettings/ComboBoxWithOptions.qml @@ -140,7 +140,6 @@ UM.TooltipArea } else { - print("SETTING PROPERTY VALUE: " + newValue) propertyProvider.setPropertyValue("value", newValue) } forceUpdateOnChangeFunction() diff --git a/resources/qml/Widgets/SingleSettingComboBox.qml b/resources/qml/Widgets/SingleSettingComboBox.qml index 0055c00262..7b4381b9b5 100644 --- a/resources/qml/Widgets/SingleSettingComboBox.qml +++ b/resources/qml/Widgets/SingleSettingComboBox.qml @@ -44,10 +44,6 @@ Cura.ComboBox { if (propertyProvider.properties.value == key) { - print("propertyProvider.properties.value: " + propertyProvider.properties.value) - print("key: " + key) - print("currentIndex: " + currentIndex) - print("i: " + i) // The combobox is cleared after each value change so the currentIndex must be set each time. currentIndex = i } @@ -95,7 +91,6 @@ Cura.ComboBox { { if (updateAllExtruders) { - print("UPDATING ALL WITH VALUE: " + value) Cura.MachineManager.setSettingForAllExtruders(propertyProvider.key, "value", value) } else From bcdfa808a8c7fa8011f63fff1d294005a20d6e70 Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Wed, 7 Dec 2022 17:33:13 +0100 Subject: [PATCH 70/82] Switch to checking enabled extruder count for showing print with Component. This is because we want the SingleSettingExtruderBar to be hidden when there are 1 or less extruders, but also when there are 1 or less enabled extruders. CURA-9793 --- cura/Settings/ExtruderManager.py | 8 +++++++ .../RecommendedSupportSelector.qml | 22 +++---------------- 2 files changed, 11 insertions(+), 19 deletions(-) diff --git a/cura/Settings/ExtruderManager.py b/cura/Settings/ExtruderManager.py index 8d38c7d46e..eea3055abe 100755 --- a/cura/Settings/ExtruderManager.py +++ b/cura/Settings/ExtruderManager.py @@ -7,6 +7,7 @@ from UM.Application import Application from UM.FlameProfiler import pyqtSlot import cura.CuraApplication # To get the global container stack to find the current machine. +from UM.Util import parseBool from cura.Settings.GlobalStack import GlobalStack from UM.Logger import Logger from UM.Scene.Iterator.DepthFirstIterator import DepthFirstIterator @@ -70,6 +71,13 @@ class ExtruderManager(QObject): # extruderIds directly after a machine update. return self.extruderIds + @pyqtProperty(int, notify = extrudersChanged) + def enabledExtruderCount(self) -> int: + global_container_stack = self._application.getGlobalContainerStack() + if global_container_stack: + return len([extruder for extruder in global_container_stack.extruderList if parseBool(extruder.getMetaDataEntry("enabled", "True"))]) + return 0 + @pyqtProperty(str, notify = activeExtruderChanged) def activeExtruderStackId(self) -> Optional[str]: """Gets the unique identifier of the currently active extruder stack. diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedSupportSelector.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedSupportSelector.qml index e9c4ff69cd..5176436b0c 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedSupportSelector.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedSupportSelector.qml @@ -34,22 +34,6 @@ RecommendedSettingSection storeIndex: 0 } - property UM.SettingPropertyProvider supportExtruderNr: UM.SettingPropertyProvider - { - containerStack: Cura.MachineManager.activeMachine - key: "support_extruder_nr" - watchedProperties: [ "value" ] - storeIndex: 0 - } - - property UM.SettingPropertyProvider machineExtruderCount: UM.SettingPropertyProvider - { - containerStack: Cura.MachineManager.activeMachine - key: "machine_extruder_count" - watchedProperties: ["value"] - storeIndex: 0 - } - contents: [ RecommendedSettingItem { @@ -69,9 +53,9 @@ RecommendedSettingSection settingName: catalog.i18nc("@action:label", "Print with") tooltipText: catalog.i18nc("@label", "The extruder train to use for printing the support. This is used in multi-extrusion.") // Hide this component when there is only one extruder - enabled: machineExtruderCount.properties.value > 1 - visible: machineExtruderCount.properties.value > 1 - isCompressed: enableSupportRow.isCompressed || machineExtruderCount.properties.value <= 1 + enabled: Cura.ExtruderManager.enabledExtruderCount > 1 + visible: Cura.ExtruderManager.enabledExtruderCount > 1 + isCompressed: enableSupportRow.isCompressed || Cura.ExtruderManager.enabledExtruderCount <= 1 settingControl: Cura.SingleSettingExtruderSelectorBar { From 91170e0aefa491bb6100c9caf494c653eace158b Mon Sep 17 00:00:00 2001 From: Jelle Spijker Date: Thu, 8 Dec 2022 07:43:57 +0100 Subject: [PATCH 71/82] Apply suggestions from code review --- .../Recommended/RecommendedSupportSelector.qml | 2 +- resources/qml/Widgets/SingleSettingComboBox.qml | 3 ++- resources/qml/Widgets/SingleSettingSlider.qml | 10 ++++++++-- resources/qml/Widgets/SingleSettingTextField.qml | 10 ++++++++-- 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedSupportSelector.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedSupportSelector.qml index 5176436b0c..2ae6dfcb41 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedSupportSelector.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedSupportSelector.qml @@ -1,4 +1,4 @@ -// Copyright (c) 2022 UltiMaker B.V. +// Copyright (c) 2022 UltiMaker // Cura is released under the terms of the LGPLv3 or higher. import QtQuick 2.10 diff --git a/resources/qml/Widgets/SingleSettingComboBox.qml b/resources/qml/Widgets/SingleSettingComboBox.qml index 7b4381b9b5..0f2b4bbd08 100644 --- a/resources/qml/Widgets/SingleSettingComboBox.qml +++ b/resources/qml/Widgets/SingleSettingComboBox.qml @@ -22,7 +22,8 @@ Cura.ComboBox { // This is only used if updateAllExtruders == true property int defaultExtruderIndex: 0 - model: ListModel { + model: ListModel + { id: comboboxModel // The propertyProvider has not loaded the setting when this components onComplete triggers. Populating the model diff --git a/resources/qml/Widgets/SingleSettingSlider.qml b/resources/qml/Widgets/SingleSettingSlider.qml index 2dbb104032..98dfdc222b 100644 --- a/resources/qml/Widgets/SingleSettingSlider.qml +++ b/resources/qml/Widgets/SingleSettingSlider.qml @@ -62,8 +62,14 @@ RowLayout Connections { target: propertyProvider - function onContainerStackChanged() { updateTimer.restart() } - function onIsValueUsedChanged() { updateTimer.restart() } + function onContainerStackChanged() + { + comboboxModel.updateModel() + } + function onIsValueUsedChanged() + { + comboboxModel.updateModel() + } } // Updates to the setting are delayed by interval. This reduces lag by waiting a bit after a setting change to update the slider contents. diff --git a/resources/qml/Widgets/SingleSettingTextField.qml b/resources/qml/Widgets/SingleSettingTextField.qml index 6d9586caa5..10bf283a11 100644 --- a/resources/qml/Widgets/SingleSettingTextField.qml +++ b/resources/qml/Widgets/SingleSettingTextField.qml @@ -59,8 +59,14 @@ UM.TextField Connections { target: propertyProvider - function onContainerStackChanged() { updateTimer.restart() } - function onIsValueUsedChanged() { updateTimer.restart() } + function onContainerStackChanged() + { + updateTimer.restart() + } + function onIsValueUsedChanged() + { + updateTimer.restart() + } } // Restart update timer right after releasing a key. This stops lag while typing, but you still get warning and error From 9a03094bfd5af7ff6cddba726e13a75856885458 Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Thu, 8 Dec 2022 09:34:16 +0100 Subject: [PATCH 72/82] Stop the text field from updating if the text has not changed. This was causing the custom mode text boxes to be updated instantly. 0.0 -delete-> 0. -instant update -> 0.0 This is because the recommended mode text fields would update to "0." see that as a change from "0.0" and update the property. This triggered an update in the Custom mode textfield. CURA-9793 --- resources/qml/Widgets/SingleSettingTextField.qml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/resources/qml/Widgets/SingleSettingTextField.qml b/resources/qml/Widgets/SingleSettingTextField.qml index 10bf283a11..1a8d7ae703 100644 --- a/resources/qml/Widgets/SingleSettingTextField.qml +++ b/resources/qml/Widgets/SingleSettingTextField.qml @@ -87,6 +87,12 @@ UM.TextField function parseValueUpdateSetting() { + if (propertyProvider.properties.value == text || parseInt(propertyProvide.properties.value) == parseInt(text)) + { + // Don't set the property value from the control. It already has the same value + return + } + if (propertyProvider && text != propertyProvider.properties.value) { updateSetting(text); From 435c67f97a5388a7795169caf806419c74eed462 Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Thu, 8 Dec 2022 09:53:06 +0100 Subject: [PATCH 73/82] revert changes to functions CURA-9793 --- resources/qml/Widgets/SingleSettingSlider.qml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/qml/Widgets/SingleSettingSlider.qml b/resources/qml/Widgets/SingleSettingSlider.qml index 98dfdc222b..3c0cf24339 100644 --- a/resources/qml/Widgets/SingleSettingSlider.qml +++ b/resources/qml/Widgets/SingleSettingSlider.qml @@ -64,11 +64,11 @@ RowLayout target: propertyProvider function onContainerStackChanged() { - comboboxModel.updateModel() + updateTimer.restart() } function onIsValueUsedChanged() { - comboboxModel.updateModel() + updateTimer.restart() } } From 82fd34f1680893f3d8cafbe128ed4758f2fb8ff9 Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Thu, 8 Dec 2022 09:56:36 +0100 Subject: [PATCH 74/82] Fix same property value check. CURA-9793 --- resources/qml/Widgets/SingleSettingTextField.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/qml/Widgets/SingleSettingTextField.qml b/resources/qml/Widgets/SingleSettingTextField.qml index 1a8d7ae703..7dde652263 100644 --- a/resources/qml/Widgets/SingleSettingTextField.qml +++ b/resources/qml/Widgets/SingleSettingTextField.qml @@ -87,7 +87,7 @@ UM.TextField function parseValueUpdateSetting() { - if (propertyProvider.properties.value == text || parseInt(propertyProvide.properties.value) == parseInt(text)) + if (propertyProvider.properties.value == text || (parseFloat(propertyProvider.properties.value) == parseFloat(text) && !isNan(parseFloat(text)))) { // Don't set the property value from the control. It already has the same value return From e6f4055df544c77bb64a2da3b2e0cd69d03769c1 Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Thu, 8 Dec 2022 13:11:14 +0100 Subject: [PATCH 75/82] Remove part of hack for fixing extrudersCHanged signal at the wrong time. Other things rely on the extruders changed signal so it is better to just emit it again at the correct time. CURA-9793 --- cura/Settings/ExtruderManager.py | 17 ++++------------- resources/qml/Widgets/SingleSettingComboBox.qml | 2 +- resources/qml/Widgets/SingleSettingSlider.qml | 2 +- .../qml/Widgets/SingleSettingTextField.qml | 2 +- 4 files changed, 7 insertions(+), 16 deletions(-) diff --git a/cura/Settings/ExtruderManager.py b/cura/Settings/ExtruderManager.py index eea3055abe..e83b053d89 100755 --- a/cura/Settings/ExtruderManager.py +++ b/cura/Settings/ExtruderManager.py @@ -49,11 +49,6 @@ class ExtruderManager(QObject): Selection.selectionChanged.connect(self.resetSelectedObjectExtruders) Application.getInstance().globalContainerStackChanged.connect(self.emitGlobalStackExtrudersChanged) # When the machine is swapped we must update the active machine extruders - # Don't use this unless you are reading from ExtruderManager.extruderIds when receiving the signal - globalStackExtrudersChanged = pyqtSignal() - - # This signal actually emits before the global stacks extruders are updated, changing this behaviour breaks too many things - # Use globalStackExtrudersChanged = pyqtSignal() if you want a trigger when the extrduerIds property changes. extrudersChanged = pyqtSignal(QVariant) """Signal to notify other components when the list of extruders for a machine definition changes.""" @@ -62,14 +57,10 @@ class ExtruderManager(QObject): def emitGlobalStackExtrudersChanged(self): # The emit function can't be directly connected to another signal. This wrapper function is required. - self.globalStackExtrudersChanged.emit() - - @pyqtProperty("QVariantMap", notify = globalStackExtrudersChanged) - def globalStackExtruderIds(self) -> Dict[str, str]: - # The extruderIds property notifys changed before the extruders are changed on switching machines - # trying to fix this broke to many things. This is a workaround. Don't use this unless you need to read - # extruderIds directly after a machine update. - return self.extruderIds + # The extrudersChanged signal is emitted early when changing machines. This triggers it a second time + # after the extruder have changed properly. This is important for any QML using ExtruderManager.extruderIds + # This is a hack, but other behaviour relys on the updating in this order. + self.extrudersChanged.emit(self._application.getGlobalContainerStack().getId()) @pyqtProperty(int, notify = extrudersChanged) def enabledExtruderCount(self) -> int: diff --git a/resources/qml/Widgets/SingleSettingComboBox.qml b/resources/qml/Widgets/SingleSettingComboBox.qml index 0f2b4bbd08..4807359484 100644 --- a/resources/qml/Widgets/SingleSettingComboBox.qml +++ b/resources/qml/Widgets/SingleSettingComboBox.qml @@ -66,7 +66,7 @@ Cura.ComboBox { property UM.SettingPropertyProvider propertyProvider: UM.SettingPropertyProvider { id: propertyProvider - containerStackId: updateAllExtruders ? Cura.ExtruderManager.globalStackExtruderIds[defaultExtruderIndex] : Cura.MachineManager.activeMachine.id + containerStackId: updateAllExtruders ? Cura.ExtruderManager.extruderIds[defaultExtruderIndex] : Cura.MachineManager.activeMachine.id watchedProperties: ["value" , "options"] } diff --git a/resources/qml/Widgets/SingleSettingSlider.qml b/resources/qml/Widgets/SingleSettingSlider.qml index 3c0cf24339..a941a348b8 100644 --- a/resources/qml/Widgets/SingleSettingSlider.qml +++ b/resources/qml/Widgets/SingleSettingSlider.qml @@ -34,7 +34,7 @@ RowLayout UM.SettingPropertyProvider { id: propertyProvider - containerStackId: updateAllExtruders ? Cura.ExtruderManager.globalStackExtruderIds[defaultExtruderIndex] : Cura.MachineManager.activeMachine.id + containerStackId: updateAllExtruders ? Cura.ExtruderManager.extruderIds[defaultExtruderIndex] : Cura.MachineManager.activeMachine.id watchedProperties: ["value"] storeIndex: 0 } diff --git a/resources/qml/Widgets/SingleSettingTextField.qml b/resources/qml/Widgets/SingleSettingTextField.qml index 7dde652263..d1dc3aab90 100644 --- a/resources/qml/Widgets/SingleSettingTextField.qml +++ b/resources/qml/Widgets/SingleSettingTextField.qml @@ -53,7 +53,7 @@ UM.TextField { id: propertyProvider watchedProperties: ["value", "validationState", "resolve"] - containerStackId: updateAllExtruders ? Cura.ExtruderManager.globalStackExtruderIds[defaultExtruderIndex] : Cura.MachineManager.activeMachine.id + containerStackId: updateAllExtruders ? Cura.ExtruderManager.extruderIds[defaultExtruderIndex] : Cura.MachineManager.activeMachine.id } Connections From aaab6339129e1f49182684a265b35671e698ad3e Mon Sep 17 00:00:00 2001 From: "c.lamboo" Date: Thu, 8 Dec 2022 13:18:29 +0100 Subject: [PATCH 76/82] Move labels into `Slider` component CURA-9793 --- resources/qml/Widgets/SingleSettingSlider.qml | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/resources/qml/Widgets/SingleSettingSlider.qml b/resources/qml/Widgets/SingleSettingSlider.qml index a941a348b8..1277e2ccda 100644 --- a/resources/qml/Widgets/SingleSettingSlider.qml +++ b/resources/qml/Widgets/SingleSettingSlider.qml @@ -6,16 +6,14 @@ import QtQuick.Controls 2.15 import UM 1.7 as UM import Cura 1.7 as Cura -import QtQuick.Layouts 1.3 // This silder allows changing of a single setting. Only the setting name has to be passed in to "settingName". // All of the setting updating logic is handled by this component. // This component allows you to choose values between minValue -> maxValue and rounds them to the nearest 10. // If the setting is limited to a single extruder or is settable with different values per extruder use "updateAllExtruders: true" -RowLayout +Item { height: childrenRect.height - spacing: UM.Theme.getSize("default_margin").width property alias settingName: propertyProvider.key property alias enabled: settingSlider.enabled @@ -39,12 +37,9 @@ RowLayout storeIndex: 0 } - UM.Label { Layout.fillWidth: false; text: minValue } - UM.Slider { id: settingSlider - Layout.fillWidth: true width: parent.width @@ -54,11 +49,15 @@ RowLayout value: parseInt(propertyProvider.properties.value) // When the slider is released trigger an update immediately. This forces the slider to snap to the rounded value. - onPressedChanged: if(!pressed) { roundSliderValueUpdateSetting() } + onPressedChanged: function(pressed) + { + if(!pressed) + { + roundSliderValueUpdateSetting(); + } + } } - UM.Label { Layout.fillWidth: false; text: maxValue } - Connections { target: propertyProvider From e03b4e07f90cfa427f9533f45536397f70ce434c Mon Sep 17 00:00:00 2001 From: "c.lamboo" Date: Thu, 8 Dec 2022 17:11:04 +0100 Subject: [PATCH 77/82] Simplify rounding Use sliders stepSize and snapMode properties CURA-9793 --- .../RecommendedStrengthSelector.qml | 1 - resources/qml/Widgets/SingleSettingSlider.qml | 46 ++++++------------- 2 files changed, 15 insertions(+), 32 deletions(-) diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedStrengthSelector.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedStrengthSelector.qml index 4adca95102..57383e6018 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedStrengthSelector.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedStrengthSelector.qml @@ -38,7 +38,6 @@ RecommendedSettingSection height: UM.Theme.getSize("combobox").height width: parent.width settingName: "infill_sparse_density" - roundToNearestTen: true updateAllExtruders: true // disable slider when gradual support is enabled enabled: parseInt(infillSteps.properties.value) == 0 diff --git a/resources/qml/Widgets/SingleSettingSlider.qml b/resources/qml/Widgets/SingleSettingSlider.qml index 1277e2ccda..27e2be562c 100644 --- a/resources/qml/Widgets/SingleSettingSlider.qml +++ b/resources/qml/Widgets/SingleSettingSlider.qml @@ -11,24 +11,25 @@ import Cura 1.7 as Cura // All of the setting updating logic is handled by this component. // This component allows you to choose values between minValue -> maxValue and rounds them to the nearest 10. // If the setting is limited to a single extruder or is settable with different values per extruder use "updateAllExtruders: true" -Item +UM.Slider { - height: childrenRect.height + id: settingSlider property alias settingName: propertyProvider.key - property alias enabled: settingSlider.enabled // If true, all extruders will have "settingName" property updated. // The displayed value will be read from the extruder with index "defaultExtruderIndex" instead of the machine. property bool updateAllExtruders: false // This is only used if updateAllExtruders == true property int defaultExtruderIndex: 0 - - property bool roundToNearestTen: false - property int maxValue: 100 - property int minValue: 0 property int previousValue: -1 + // set range from 0 to 100 + from: 0; to: 100 + // set stepSize to 10 and set snapMode to snap on release snapMode is needed + // otherwise the used percentage and slider handle show different values + stepSize: 10; snapMode: Slider.SnapOnRelease + UM.SettingPropertyProvider { id: propertyProvider @@ -37,24 +38,15 @@ Item storeIndex: 0 } - UM.Slider + // set initial value from stack + value: parseInt(propertyProvider.properties.value) + + // When the slider is released trigger an update immediately. This forces the slider to snap to the rounded value. + onPressedChanged: function(pressed) { - id: settingSlider - - width: parent.width - - from: minValue; to: maxValue; stepSize: 1 - - // set initial value from stack - value: parseInt(propertyProvider.properties.value) - - // When the slider is released trigger an update immediately. This forces the slider to snap to the rounded value. - onPressedChanged: function(pressed) + if(!pressed) { - if(!pressed) - { - roundSliderValueUpdateSetting(); - } + updateSetting(settingSlider.value); } } @@ -85,14 +77,6 @@ Item settingSlider.value = value } - function roundSliderValueUpdateSetting() - { - // If the user interacts with the slider we round the value and update the setting. - const roundedSliderValue = roundToNearestTen ? Math.round(settingSlider.value / 10) * 10 : Math.round(settingSlider.value) - updateSetting(roundedSliderValue) - } - - function parseValueUpdateSetting(triggerUpdate) { // Only run when the setting value is updated by something other than the slider. From 1e6184448ce823e8a4513ef861fd34786e23d992 Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Mon, 12 Dec 2022 11:44:21 +0100 Subject: [PATCH 78/82] Apply suggestions from code review Co-authored-by: Casper Lamboo Co-authored-by: Jelle Spijker --- cura/Settings/ExtruderManager.py | 1 + resources/qml/MachineSettings/ComboBoxWithOptions.qml | 8 ++++---- .../Recommended/RecommendedAdhesionSelector.qml | 7 ++++--- .../Recommended/RecommendedPrintSetup.qml | 6 ++++-- .../Recommended/RecommendedSettingItem.qml | 2 -- .../Recommended/RecommendedStrengthSelector.qml | 4 ++-- .../Recommended/RecommendedSupportSelector.qml | 1 - resources/qml/Toolbar.qml | 6 +++--- resources/qml/Widgets/SingleSettingComboBox.qml | 4 ++-- .../qml/Widgets/SingleSettingExtruderSelectorBar.qml | 4 ++-- resources/qml/Widgets/SingleSettingTextField.qml | 8 ++++---- 11 files changed, 26 insertions(+), 25 deletions(-) diff --git a/cura/Settings/ExtruderManager.py b/cura/Settings/ExtruderManager.py index e83b053d89..e465b6bb68 100755 --- a/cura/Settings/ExtruderManager.py +++ b/cura/Settings/ExtruderManager.py @@ -56,6 +56,7 @@ class ExtruderManager(QObject): """Notify when the user switches the currently active extruder.""" def emitGlobalStackExtrudersChanged(self): + # HACK # The emit function can't be directly connected to another signal. This wrapper function is required. # The extrudersChanged signal is emitted early when changing machines. This triggers it a second time # after the extruder have changed properly. This is important for any QML using ExtruderManager.extruderIds diff --git a/resources/qml/MachineSettings/ComboBoxWithOptions.qml b/resources/qml/MachineSettings/ComboBoxWithOptions.qml index 33ec84aaa2..7ba7c0f701 100644 --- a/resources/qml/MachineSettings/ComboBoxWithOptions.qml +++ b/resources/qml/MachineSettings/ComboBoxWithOptions.qml @@ -74,7 +74,7 @@ UM.TooltipArea return } - if (typeof propertyProvider.properties["options"] == "string") + if (typeof propertyProvider.properties["options"] === "string") { return } @@ -84,9 +84,9 @@ UM.TooltipArea { var key = propertyProvider.properties["options"].keys()[i] var value = propertyProvider.properties["options"][key] - append({ text: value, code: key}) + append({ text: value, code: key }) - if (propertyProvider.properties.value == key) + if (propertyProvider.properties.value === key) { comboBox.currentIndex = i } @@ -132,7 +132,7 @@ UM.TooltipArea onActivated: { var newValue = model.get(index).value - if (propertyProvider.properties.value != newValue && newValue != undefined) + if (propertyProvider.properties.value !== newValue && newValue !== undefined) { if (setValueFunction !== null) { diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedAdhesionSelector.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedAdhesionSelector.qml index 3d0c4ac82c..2183ef7d5e 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedAdhesionSelector.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedAdhesionSelector.qml @@ -14,8 +14,8 @@ RecommendedSettingSection title: catalog.i18nc("@label", "Adhesion") icon: UM.Theme.getIcon("Adhesion") - enableSectionSwitchVisible: platformAdhesionType.properties.enabled == "True" - enableSectionSwitchChecked: platformAdhesionType.properties.value != "skirt" && platformAdhesionType.properties.value != "none" + enableSectionSwitchVisible: platformAdhesionType.properties.enabled === "True" + enableSectionSwitchChecked: platformAdhesionType.properties.value !== "skirt" && platformAdhesionType.properties.value !== "none" enableSectionSwitchEnabled: recommendedPrintSetup.settingsEnabled tooltipText: catalog.i18nc("@label", "Enable printing a brim or raft. This will add a flat area around or under your object which is easy to cut off afterwards.") @@ -30,7 +30,8 @@ RecommendedSettingSection storeIndex: 0 } - function onEnableSectionChanged(state) { + function onEnableSectionChanged(state) + { curaRecommendedMode.setAdhesion(state) } } diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedPrintSetup.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedPrintSetup.qml index 179f2606f8..f78ae38dce 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedPrintSetup.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedPrintSetup.qml @@ -77,7 +77,8 @@ Item Item { height: UM.Theme.getSize("narrow_margin").height } //Spacer - Column { + Column + { id: settingColumn width: parent.width spacing: UM.Theme.getSize("thin_margin").height @@ -117,7 +118,8 @@ Item width: parent.width } - RecommendedAdhesionSelector { + RecommendedAdhesionSelector + { width: parent.width } } diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedSettingItem.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedSettingItem.qml index ca9869db68..e07bc3b643 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedSettingItem.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedSettingItem.qml @@ -41,7 +41,6 @@ Item onExited: base.hideTooltip() } - Loader { id: settingContainer @@ -86,7 +85,6 @@ Item NumberAnimation { property: "Layout.minimumHeight"; duration: 100; } // Animate section dissapearring as it closes NumberAnimation { property: "opacity"; duration: 100; } - } } } \ No newline at end of file diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedStrengthSelector.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedStrengthSelector.qml index 57383e6018..0e15397fd7 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedStrengthSelector.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedStrengthSelector.qml @@ -1,4 +1,4 @@ -// Copyright (c) 2022 Ultimaker +// Copyright (c) 2022 UltiMaker // Cura is released under the terms of the LGPLv3 or higher. import QtQuick 2.7 @@ -40,7 +40,7 @@ RecommendedSettingSection settingName: "infill_sparse_density" updateAllExtruders: true // disable slider when gradual support is enabled - enabled: parseInt(infillSteps.properties.value) == 0 + enabled: parseInt(infillSteps.properties.value) === 0 function updateSetting(value) { diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedSupportSelector.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedSupportSelector.qml index 2ae6dfcb41..44b3d28e24 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedSupportSelector.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedSupportSelector.qml @@ -59,7 +59,6 @@ RecommendedSettingSection settingControl: Cura.SingleSettingExtruderSelectorBar { - extruderSettingName: "support_extruder_nr" } }, diff --git a/resources/qml/Toolbar.qml b/resources/qml/Toolbar.qml index 894f280240..fd48ef7448 100644 --- a/resources/qml/Toolbar.qml +++ b/resources/qml/Toolbar.qml @@ -137,10 +137,10 @@ Item delegate: Cura.ExtruderButton { extruder: model - isTopElement: extrudersModel.getItem(0).id == model.id - isBottomElement: extrudersModel.getItem(extrudersModel.rowCount() - 1).id == model.id + isTopElement: extrudersModel.getItem(0).id === model.id + isBottomElement: extrudersModel.getItem(extrudersModel.rowCount() - 1).id === model.id text: catalog.i18ncp("@label %1 is filled in with the name of an extruder", "Print Selected Model with %1", "Print Selected Models with %1", UM.Selection.selectionCount).arg(extruder.name) - checked: Cura.ExtruderManager.selectedObjectExtruders.indexOf(extruder.id) != -1 + checked: Cura.ExtruderManager.selectedObjectExtruders.indexOf(extruder.id) !== -1 enabled: UM.Selection.hasSelection && extruder.stack.isEnabled font: UM.Theme.getFont("small_emphasis") diff --git a/resources/qml/Widgets/SingleSettingComboBox.qml b/resources/qml/Widgets/SingleSettingComboBox.qml index 4807359484..338e14b144 100644 --- a/resources/qml/Widgets/SingleSettingComboBox.qml +++ b/resources/qml/Widgets/SingleSettingComboBox.qml @@ -43,7 +43,7 @@ Cura.ComboBox { var value = propertyProvider.properties["options"][key] comboboxModel.append({ text: value, code: key}) - if (propertyProvider.properties.value == key) + if (propertyProvider.properties.value === key) { // The combobox is cleared after each value change so the currentIndex must be set each time. currentIndex = i @@ -81,7 +81,7 @@ Cura.ComboBox { function parseValueAndUpdateSetting() { - if (comboboxModel.get(currentIndex) && comboboxModel.get(currentIndex).code != propertyProvider.properties.value) + if (comboboxModel.get(currentIndex) && comboboxModel.get(currentIndex).code !== propertyProvider.properties.value) { updateSetting(comboboxModel.get(currentIndex).code) } diff --git a/resources/qml/Widgets/SingleSettingExtruderSelectorBar.qml b/resources/qml/Widgets/SingleSettingExtruderSelectorBar.qml index 80f77304c3..d753bb9167 100644 --- a/resources/qml/Widgets/SingleSettingExtruderSelectorBar.qml +++ b/resources/qml/Widgets/SingleSettingExtruderSelectorBar.qml @@ -56,10 +56,10 @@ Row Cura.ExtruderButton { - anchors.margins : 0 + anchors.margins: 0 padding: 0 extruder: model - checked: extruder.index == selectedIndex + checked: extruder.index === selectedIndex iconScale: 0.8 font: UM.Theme.getFont("tiny_emphasis") buttonSize: UM.Theme.getSize("small_button").width diff --git a/resources/qml/Widgets/SingleSettingTextField.qml b/resources/qml/Widgets/SingleSettingTextField.qml index d1dc3aab90..5bff7fdb5a 100644 --- a/resources/qml/Widgets/SingleSettingTextField.qml +++ b/resources/qml/Widgets/SingleSettingTextField.qml @@ -87,13 +87,13 @@ UM.TextField function parseValueUpdateSetting() { - if (propertyProvider.properties.value == text || (parseFloat(propertyProvider.properties.value) == parseFloat(text) && !isNan(parseFloat(text)))) + if (propertyProvider.properties.value === text || (parseFloat(propertyProvider.properties.value) === parseFloat(text))) { // Don't set the property value from the control. It already has the same value return } - if (propertyProvider && text != propertyProvider.properties.value) + if (propertyProvider && text !== propertyProvider.properties.value) { updateSetting(text); } @@ -119,7 +119,7 @@ UM.TextField State { name: "validationError" - when: propertyProvider.properties.validationState == "ValidatorState.Exception" || propertyProvider.properties.validationState == "ValidatorState.MinimumError" || propertyProvider.properties.validationState == "ValidatorState.MaximumError" + when: propertyProvider.properties.validationState === "ValidatorState.Exception" || propertyProvider.properties.validationState === "ValidatorState.MinimumError" || propertyProvider.properties.validationState === "ValidatorState.MaximumError" PropertyChanges { target: background @@ -130,7 +130,7 @@ UM.TextField State { name: "validationWarning" - when: propertyProvider.properties.validationState == "ValidatorState.MinimumWarning" || propertyProvider.properties.validationState == "ValidatorState.MaximumWarning" + when: propertyProvider.properties.validationState === "ValidatorState.MinimumWarning" || propertyProvider.properties.validationState === "ValidatorState.MaximumWarning" PropertyChanges { target: background From c6cc9ee6ec1025b8b101d0339a0b6b4913034aeb Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Mon, 12 Dec 2022 14:05:39 +0100 Subject: [PATCH 79/82] Update validators for SettingTextField to use strings from our validators. You can't access the components directly from javascript without instantiating them so they are instantiated here first. CURA-9793 --- resources/qml/Settings/SettingTextField.qml | 23 +++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/resources/qml/Settings/SettingTextField.qml b/resources/qml/Settings/SettingTextField.qml index 4e72bca93e..366fd06517 100644 --- a/resources/qml/Settings/SettingTextField.qml +++ b/resources/qml/Settings/SettingTextField.qml @@ -4,7 +4,7 @@ import QtQuick 2.15 import QtQuick.Controls 2.15 -import UM 1.5 as UM +import UM 1.7 as UM SettingItem { @@ -159,7 +159,26 @@ SettingItem // should be done as little as possible) clip: definition.type == "str" || definition.type == "[int]" - validator: RegularExpressionValidator { regularExpression: (definition.type == "[int]") ? /^\[?(\s*-?[0-9]{0,11}\s*,)*(\s*-?[0-9]{0,11})\s*\]?$/ : (definition.type == "int") ? /^-?[0-9]{0,12}$/ : (definition.type == "float") ? /^-?[0-9]{0,11}[.,]?[0-9]{0,3}$/ : /^.*$/ } // definition.type property from parent loader used to disallow fractional number entry + readonly property UM.IntValidator intValidator: UM.IntValidator {} + readonly property UM.FloatValidator floatValidator: UM.FloatValidator {} + readonly property UM.IntListValidator intListValidator: UM.IntListValidator {} + validator: RegularExpressionValidator + { + regularExpression: + { + switch (definition.type) + { + case "[int]": + return new RegExp(intListValidator.regexString) + case "int": + return new RegExp(intValidator.regexString) + case "float": + return new RegExp(floatValidator.regexString) + default: + return new RegExp("^.*$") + } + } + } Binding { From f52638ca756b84c26ec0a54f4a540e527e49092a Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Mon, 12 Dec 2022 14:06:30 +0100 Subject: [PATCH 80/82] Update extrudermanager in tests to mock Application. CURA-9793 --- tests/conftest.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index efe9141e29..377a525ba7 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -6,6 +6,7 @@ from unittest.mock import MagicMock, patch import pytest +from UM.Application import Application from UM.Qt.QtApplication import QtApplication # QtApplication import is required, even though it isn't used. from cura.CuraApplication import CuraApplication @@ -22,6 +23,12 @@ def application() -> CuraApplication: app = MagicMock() return app +@pytest.fixture() +def um_application() -> Application: + app = MagicMock() + app.getInstance = MagicMock(return_value=app) + return app + # Returns a MachineActionManager instance. @pytest.fixture() @@ -43,14 +50,15 @@ def container_registry(application, global_stack) -> ContainerRegistry: @pytest.fixture() -def extruder_manager(application, container_registry) -> ExtruderManager: +def extruder_manager(application, um_application, container_registry) -> ExtruderManager: if ExtruderManager.getInstance() is not None: # Reset the data ExtruderManager._ExtruderManager__instance = None with patch("cura.CuraApplication.CuraApplication.getInstance", MagicMock(return_value=application)): with patch("UM.Settings.ContainerRegistry.ContainerRegistry.getInstance", MagicMock(return_value=container_registry)): - manager = ExtruderManager() + with patch("UM.Application.Application.getInstance", um_application): + manager = ExtruderManager() return manager From 8780a2c4a0048db7f24b17b49266b12a6a64c3cd Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Mon, 12 Dec 2022 14:12:32 +0100 Subject: [PATCH 81/82] Move validators to top of file. CURA-9793 --- resources/qml/Settings/SettingTextField.qml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/resources/qml/Settings/SettingTextField.qml b/resources/qml/Settings/SettingTextField.qml index 366fd06517..d8e90e4951 100644 --- a/resources/qml/Settings/SettingTextField.qml +++ b/resources/qml/Settings/SettingTextField.qml @@ -14,6 +14,11 @@ SettingItem property string textBeforeEdit property bool textHasChanged property bool focusGainedByClick: false + + readonly property UM.IntValidator intValidator: UM.IntValidator {} + readonly property UM.FloatValidator floatValidator: UM.FloatValidator {} + readonly property UM.IntListValidator intListValidator: UM.IntListValidator {} + onFocusReceived: { textHasChanged = false; @@ -159,9 +164,6 @@ SettingItem // should be done as little as possible) clip: definition.type == "str" || definition.type == "[int]" - readonly property UM.IntValidator intValidator: UM.IntValidator {} - readonly property UM.FloatValidator floatValidator: UM.FloatValidator {} - readonly property UM.IntListValidator intListValidator: UM.IntListValidator {} validator: RegularExpressionValidator { regularExpression: From e05c70ae38956887837b88fa458ab51da8977fd8 Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Mon, 12 Dec 2022 14:22:38 +0100 Subject: [PATCH 82/82] Refactor ComponentWithIcon to use contents instead of loader. CURA-9793 --- .../Recommended/RecommendedSettingItem.qml | 2 +- .../Recommended/RecommendedStrengthSelector.qml | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedSettingItem.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedSettingItem.qml index e07bc3b643..ceebc3808e 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedSettingItem.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedSettingItem.qml @@ -41,7 +41,7 @@ Item onExited: base.hideTooltip() } - Loader + Item { id: settingContainer height: childrenRect.height diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedStrengthSelector.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedStrengthSelector.qml index 0e15397fd7..75e8abd676 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedStrengthSelector.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedStrengthSelector.qml @@ -75,7 +75,8 @@ RecommendedSettingSection { Layout.fillWidth: true source: UM.Theme.getIcon("PrintWalls") - displayComponent: Cura.SingleSettingTextField + + Cura.SingleSettingTextField { width: parent.width settingName: "wall_thickness" @@ -88,7 +89,8 @@ RecommendedSettingSection { Layout.fillWidth: true source: UM.Theme.getIcon("PrintTopBottom") - displayComponent: Cura.SingleSettingTextField + + Cura.SingleSettingTextField { width: parent.width settingName: "top_bottom_thickness"