From f9a5cb33fd6202a27573fc1a3e52a8f43d6f7b2d Mon Sep 17 00:00:00 2001 From: casper Date: Wed, 9 Mar 2022 15:26:55 +0100 Subject: [PATCH 01/24] Implement basic styling of material management page CURA-8979 --- resources/qml/ColorDialog.qml | 11 - .../Preferences/Materials/MaterialsPage.qml | 401 +++----- .../Preferences/Materials/MaterialsSlot.qml | 7 +- .../Preferences/Materials/MaterialsView.qml | 871 ++++++++++-------- 4 files changed, 648 insertions(+), 642 deletions(-) diff --git a/resources/qml/ColorDialog.qml b/resources/qml/ColorDialog.qml index 3818ea5cb4..be587a4f25 100644 --- a/resources/qml/ColorDialog.qml +++ b/resources/qml/ColorDialog.qml @@ -21,17 +21,6 @@ UM.Dialog property alias swatchGridColumns: colorSwatchGrid.columns - // In this case we would like to let the content of the dialog determine the size of the dialog - // however with the current implementation of the dialog this is not possible, so instead we calculate - // the size of the dialog ourselves. - minimumWidth: content.width + 4 * margin - minimumHeight: - content.height // content height - + buttonRow.height // button row height - + 5 * margin // top and bottom margin and margin between buttons and content - width: minimumWidth - height: minimumHeight - property alias color: colorInput.text property var swatchColors: [ "#2161AF", "#57AFB2", "#F7B32D", "#E33D4A", "#C088AD", diff --git a/resources/qml/Preferences/Materials/MaterialsPage.qml b/resources/qml/Preferences/Materials/MaterialsPage.qml index c9e6cf07a1..a9012e91b6 100644 --- a/resources/qml/Preferences/Materials/MaterialsPage.qml +++ b/resources/qml/Preferences/Materials/MaterialsPage.qml @@ -3,13 +3,12 @@ import QtQuick 2.7 import QtQuick.Controls 2.15 -import QtQuick.Layouts 1.3 import QtQuick.Dialogs 1.2 import UM 1.5 as UM import Cura 1.5 as Cura -Item +UM.ManagementPage { id: base @@ -36,12 +35,6 @@ Item property var extruder_position: Cura.ExtruderManager.activeExtruderIndex property var active_root_material_id: Cura.MachineManager.currentRootMaterialId[extruder_position] - UM.I18nCatalog - { - id: catalog - name: "cura" - } - function resetExpandedActiveMaterial() { materialListView.expandActiveMaterial(active_root_material_id) @@ -74,57 +67,14 @@ Item } } - // Main layout - Label - { - id: titleLabel - anchors - { - top: parent.top - left: parent.left - right: parent.right - margins: 5 * screenScaleFactor - } - font.pointSize: 18 - text: catalog.i18nc("@title:tab", "Materials") - } + title: catalog.i18nc("@title:tab", "Materials") + scrollviewCaption: catalog.i18nc("@label", "Materials compatible with active printer:") + `
${Cura.MachineManager.activeMachine.name}` - // Button Row - Row - { - id: buttonRow - anchors - { - left: parent.left - right: parent.right - top: titleLabel.bottom - } - height: childrenRect.height - - // Activate button - Button - { - id: activateMenuButton - text: catalog.i18nc("@action:button", "Activate") - icon.name: "list-activate" - enabled: !isCurrentItemActivated && Cura.MachineManager.activeMachine.hasMaterials - onClicked: - { - forceActiveFocus() - - // Set the current material as the one to be activated (needed to force the UI update) - base.newRootMaterialIdToSwitchTo = base.currentItem.root_material_id - const extruder_position = Cura.ExtruderManager.activeExtruderIndex - Cura.MachineManager.setMaterial(extruder_position, base.currentItem.container_node) - } - } - - // Create button - Button + buttons: [ + Cura.SecondaryButton { id: createMenuButton - text: catalog.i18nc("@action:button", "Create") - icon.name: "list-add" + text: catalog.i18nc("@action:button", "Create new") enabled: Cura.MachineManager.activeMachine.hasMaterials onClicked: { @@ -132,72 +82,22 @@ Item base.newRootMaterialIdToSwitchTo = base.materialManagementModel.createMaterial(); base.toActivateNewMaterial = true; } - } - - // Duplicate button - Button - { - id: duplicateMenuButton - text: catalog.i18nc("@action:button", "Duplicate"); - icon.name: "list-add" - enabled: base.hasCurrentItem - onClicked: - { - forceActiveFocus(); - base.newRootMaterialIdToSwitchTo = base.materialManagementModel.duplicateMaterial(base.currentItem.container_node); - base.toActivateNewMaterial = true; - } - } - - // Remove button - Button - { - id: removeMenuButton - text: catalog.i18nc("@action:button", "Remove") - icon.name: "list-remove" - enabled: base.hasCurrentItem && !base.currentItem.is_read_only && !base.isCurrentItemActivated && base.materialManagementModel.canMaterialBeRemoved(base.currentItem.container_node) - - onClicked: - { - forceActiveFocus(); - confirmRemoveMaterialDialog.open(); - } - } - - // Import button - Button + }, + Cura.SecondaryButton { id: importMenuButton text: catalog.i18nc("@action:button", "Import") - icon.name: "document-import" onClicked: { forceActiveFocus(); importMaterialDialog.open(); } enabled: Cura.MachineManager.activeMachine.hasMaterials - } - - // Export button - Button - { - id: exportMenuButton - text: catalog.i18nc("@action:button", "Export") - icon.name: "document-export" - onClicked: - { - forceActiveFocus(); - exportMaterialDialog.open(); - } - enabled: base.hasCurrentItem - } - - //Sync button. - Button + }, + Cura.SecondaryButton { id: syncMaterialsButton - text: catalog.i18nc("@action:button Sending materials to printers", "Sync with Printers") - icon.name: "sync-synchronizing" + text: catalog.i18nc("@action:button", "Sync with Printers") onClicked: { forceActiveFocus(); @@ -205,181 +105,176 @@ Item } visible: Cura.MachineManager.activeMachine.supportsMaterialExport } - } + ] - Item + onHamburgeButtonClicked: menu.popup(content_item, content_item.width - menu.width, hamburger_button.height) + + listContent: ScrollView { - id: contentsItem - anchors - { - top: titleLabel.bottom - left: parent.left - right: parent.right - bottom: parent.bottom - margins: 5 * screenScaleFactor - bottomMargin: 0 - } + id: materialScrollView + anchors.fill: parent + anchors.margins: parent.border.width + width: (parent.width * 0.4) | 0 + clip: true - } - - Item - { - anchors + ScrollBar.vertical: UM.ScrollBar { - top: buttonRow.bottom - topMargin: UM.Theme.getSize("default_margin").height - left: parent.left - right: parent.right - bottom: parent.bottom - } - - SystemPalette { id: palette } - - Label - { - id: captionLabel + id: materialScrollBar + parent: materialScrollView anchors { top: parent.top - left: parent.left - } - visible: text != "" - text: - { - var caption = catalog.i18nc("@action:label", "Printer") + ": " + Cura.MachineManager.activeMachine.name; - if (Cura.MachineManager.activeMachine.hasVariants) - { - var activeVariantName = "" - if(Cura.MachineManager.activeStack != null) - { - activeVariantName = Cura.MachineManager.activeStack.variant.name - } - caption += ", " + Cura.MachineManager.activeDefinitionVariantsName + ": " + activeVariantName; - } - return caption; - } - width: materialScrollView.width - elide: Text.ElideRight - } - - ScrollView - { - id: materialScrollView - anchors - { - top: captionLabel.visible ? captionLabel.bottom : parent.top - topMargin: captionLabel.visible ? UM.Theme.getSize("default_margin").height : 0 + right: parent.right bottom: parent.bottom - left: parent.left } - width: (parent.width * 0.4) | 0 + } + contentHeight: materialListView.height //For some reason, this is not determined automatically with this ScrollView. Very weird! - clip: true - ScrollBar.vertical: UM.ScrollBar + MaterialsList + { + id: materialListView + width: materialScrollView.width - materialScrollBar.width + } + } + + + Item + { + id: content_item + anchors.fill: parent + + Cura.Menu + { + id: menu + Cura.MenuItem { - id: materialScrollBar - parent: materialScrollView - anchors + id: activateMenuButton + text: catalog.i18nc("@action:button", "Activate") + onClicked: { - top: parent.top - right: parent.right - bottom: parent.bottom + forceActiveFocus() + + // Set the current material as the one to be activated (needed to force the UI update) + base.newRootMaterialIdToSwitchTo = base.currentItem.root_material_id + const extruder_position = Cura.ExtruderManager.activeExtruderIndex + Cura.MachineManager.setMaterial(extruder_position, base.currentItem.container_node) } } - contentHeight: materialListView.height //For some reason, this is not determined automatically with this ScrollView. Very weird! - - MaterialsList + Cura.MenuItem { - id: materialListView - width: materialScrollView.width - materialScrollBar.width + id: duplicateMenuButton + text: catalog.i18nc("@action:button", "Duplicate"); + enabled: base.hasCurrentItem + onClicked: + { + forceActiveFocus(); + base.newRootMaterialIdToSwitchTo = base.materialManagementModel.duplicateMaterial(base.currentItem.container_node); + base.toActivateNewMaterial = true; + } + } + Cura.MenuItem + { + id: removeMenuButton + text: catalog.i18nc("@action:button", "Remove") + enabled: base.hasCurrentItem && !base.currentItem.is_read_only && !base.isCurrentItemActivated && base.materialManagementModel.canMaterialBeRemoved(base.currentItem.container_node) + + onClicked: + { + forceActiveFocus(); + confirmRemoveMaterialDialog.open(); + } + } + Cura.MenuItem + { + id: exportMenuButton + text: catalog.i18nc("@action:button", "Export") + onClicked: + { + forceActiveFocus(); + exportMaterialDialog.open(); + } + enabled: base.hasCurrentItem } } MaterialsDetailsPanel { id: materialDetailsPanel - anchors + anchors.fill: parent + } + + // Dialogs + Cura.MessageDialog + { + id: confirmRemoveMaterialDialog + title: catalog.i18nc("@title:window", "Confirm Remove") + property string materialName: base.currentItem !== null ? base.currentItem.name : "" + + text: catalog.i18nc("@label (%1 is object name)", "Are you sure you wish to remove %1? This cannot be undone!").arg(materialName) + standardButtons: Dialog.Yes | Dialog.No + onAccepted: { - left: materialScrollView.right - leftMargin: UM.Theme.getSize("default_margin").width - top: parent.top - bottom: parent.bottom - right: parent.right + // Set the active material as the fallback. It will be selected when the current material is deleted + base.newRootMaterialIdToSwitchTo = base.active_root_material_id + base.materialManagementModel.removeMaterial(base.currentItem.container_node); } } - } - // Dialogs - Cura.MessageDialog - { - id: confirmRemoveMaterialDialog - title: catalog.i18nc("@title:window", "Confirm Remove") - property string materialName: base.currentItem !== null ? base.currentItem.name : "" - - text: catalog.i18nc("@label (%1 is object name)", "Are you sure you wish to remove %1? This cannot be undone!").arg(materialName) - standardButtons: Dialog.Yes | Dialog.No - onAccepted: + FileDialog { - // Set the active material as the fallback. It will be selected when the current material is deleted - base.newRootMaterialIdToSwitchTo = base.active_root_material_id - base.materialManagementModel.removeMaterial(base.currentItem.container_node); - } - } - - FileDialog - { - id: importMaterialDialog - title: catalog.i18nc("@title:window", "Import Material") - selectExisting: true - nameFilters: Cura.ContainerManager.getContainerNameFilters("material") - folder: CuraApplication.getDefaultPath("dialog_material_path") - onAccepted: - { - const result = Cura.ContainerManager.importMaterialContainer(fileUrl); - - const messageDialog = Qt.createQmlObject("import Cura 1.5 as Cura; Cura.MessageDialog { onClosed: destroy() }", base); - messageDialog.standardButtons = Dialog.Ok; - messageDialog.title = catalog.i18nc("@title:window", "Import Material"); - switch (result.status) + id: importMaterialDialog + title: catalog.i18nc("@title:window", "Import Material") + selectExisting: true + nameFilters: Cura.ContainerManager.getContainerNameFilters("material") + folder: CuraApplication.getDefaultPath("dialog_material_path") + onAccepted: { - case "success": - messageDialog.text = catalog.i18nc("@info:status Don't translate the XML tag !", "Successfully imported material %1").arg(fileUrl); - break; - default: - messageDialog.text = catalog.i18nc("@info:status Don't translate the XML tags or !", "Could not import material %1: %2").arg(fileUrl).arg(result.message); - break; + const result = Cura.ContainerManager.importMaterialContainer(fileUrl); + + const messageDialog = Qt.createQmlObject("import Cura 1.5 as Cura; Cura.MessageDialog { onClosed: destroy() }", base); + messageDialog.standardButtons = Dialog.Ok; + messageDialog.title = catalog.i18nc("@title:window", "Import Material"); + switch (result.status) + { + case "success": + messageDialog.text = catalog.i18nc("@info:status Don't translate the XML tag !", "Successfully imported material %1").arg(fileUrl); + break; + default: + messageDialog.text = catalog.i18nc("@info:status Don't translate the XML tags or !", "Could not import material %1: %2").arg(fileUrl).arg(result.message); + break; + } + messageDialog.open(); + CuraApplication.setDefaultPath("dialog_material_path", folder); } - messageDialog.open(); - CuraApplication.setDefaultPath("dialog_material_path", folder); } - } - FileDialog - { - id: exportMaterialDialog - title: catalog.i18nc("@title:window", "Export Material") - selectExisting: false - nameFilters: Cura.ContainerManager.getContainerNameFilters("material") - folder: CuraApplication.getDefaultPath("dialog_material_path") - onAccepted: + FileDialog { - const result = Cura.ContainerManager.exportContainer(base.currentItem.root_material_id, selectedNameFilter, fileUrl); - - const messageDialog = Qt.createQmlObject("import Cura 1.5 as Cura; Cura.MessageDialog { onClosed: destroy() }", base); - messageDialog.title = catalog.i18nc("@title:window", "Export Material"); - messageDialog.standardButtons = Dialog.Ok; - switch (result.status) + id: exportMaterialDialog + title: catalog.i18nc("@title:window", "Export Material") + selectExisting: false + nameFilters: Cura.ContainerManager.getContainerNameFilters("material") + folder: CuraApplication.getDefaultPath("dialog_material_path") + onAccepted: { - case "error": - messageDialog.text = catalog.i18nc("@info:status Don't translate the XML tags and !", "Failed to export material to %1: %2").arg(fileUrl).arg(result.message); - break; - case "success": - messageDialog.text = catalog.i18nc("@info:status Don't translate the XML tag !", "Successfully exported material to %1").arg(result.path); - break; - } - messageDialog.open(); + const result = Cura.ContainerManager.exportContainer(base.currentItem.root_material_id, selectedNameFilter, fileUrl); - CuraApplication.setDefaultPath("dialog_material_path", folder); + const messageDialog = Qt.createQmlObject("import Cura 1.5 as Cura; Cura.MessageDialog { onClosed: destroy() }", base); + messageDialog.title = catalog.i18nc("@title:window", "Export Material"); + messageDialog.standardButtons = Dialog.Ok; + switch (result.status) + { + case "error": + messageDialog.text = catalog.i18nc("@info:status Don't translate the XML tags and !", "Failed to export material to %1: %2").arg(fileUrl).arg(result.message); + break; + case "success": + messageDialog.text = catalog.i18nc("@info:status Don't translate the XML tag !", "Successfully exported material to %1").arg(result.path); + break; + } + messageDialog.open(); + + CuraApplication.setDefaultPath("dialog_material_path", folder); + } } } } diff --git a/resources/qml/Preferences/Materials/MaterialsSlot.qml b/resources/qml/Preferences/Materials/MaterialsSlot.qml index cd8c05fbf9..03c7d5dc9d 100644 --- a/resources/qml/Preferences/Materials/MaterialsSlot.qml +++ b/resources/qml/Preferences/Materials/MaterialsSlot.qml @@ -35,10 +35,9 @@ Rectangle { id: swatch color: material != null ? material.color_code : "transparent" - border.width: UM.Theme.getSize("default_lining").width - border.color: "black" - width: UM.Theme.getSize("favorites_button_icon").width - height: UM.Theme.getSize("favorites_button_icon").height + width: UM.Theme.getSize("icon_indicator").width + height: UM.Theme.getSize("icon_indicator").height + radius: width / 2 anchors.verticalCenter: materialSlot.verticalCenter anchors.left: materialSlot.left anchors.leftMargin: UM.Theme.getSize("default_margin").width diff --git a/resources/qml/Preferences/Materials/MaterialsView.qml b/resources/qml/Preferences/Materials/MaterialsView.qml index 915d36ff57..56b71efe34 100644 --- a/resources/qml/Preferences/Materials/MaterialsView.qml +++ b/resources/qml/Preferences/Materials/MaterialsView.qml @@ -4,6 +4,7 @@ import QtQuick 2.7 import QtQuick.Controls 2.15 import QtQuick.Dialogs 1.2 +import QtQuick.Layouts 1.3 import UM 1.5 as UM import Cura 1.0 as Cura @@ -82,398 +83,520 @@ Item } } - ScrollView + Rectangle { - id: informationPage + color: UM.Theme.getColor("main_background") + anchors { top: pageSelectorTabRow.bottom + topMargin: -UM.Theme.getSize("default_lining").width left: parent.left right: parent.right bottom: parent.bottom } + border.width: UM.Theme.getSize("default_lining").width + border.color: UM.Theme.getColor("thick_lining") + visible: base.hasCurrentItem - ScrollBar.vertical: UM.ScrollBar + ScrollView { - parent: informationPage + id: informationPage anchors { - top: parent.top + fill: parent + topMargin: UM.Theme.getSize("thin_margin").height + bottomMargin: UM.Theme.getSize("thin_margin").height + leftMargin: UM.Theme.getSize("thin_margin").width + rightMargin: UM.Theme.getSize("thin_margin").width + } + + ScrollBar.vertical: UM.ScrollBar + { + parent: informationPage + anchors + { + top: parent.top + right: parent.right + bottom: parent.bottom + } + } + ScrollBar.horizontal.policy: ScrollBar.AlwaysOff + clip: true + visible: pageSelectorTabRow.currentItem.activeView === "information" + + property real columnWidth: Math.floor(width / 2 - UM.Theme.getSize("narrow_margin").width) + property real rowHeight: UM.Theme.getSize("setting_control").height + + Column + { + width: informationPage.width + spacing: UM.Theme.getSize("narrow_margin").height + + Cura.MessageDialog + { + id: confirmDiameterChangeDialog + + title: catalog.i18nc("@title:window", "Confirm Diameter Change") + text: catalog.i18nc("@label (%1 is a number)", "The new filament diameter is set to %1 mm, which is not compatible with the current extruder. Do you wish to continue?".arg(new_diameter_value)) + standardButtons: Dialog.Yes | Dialog.No + + property var new_diameter_value: null + property var old_diameter_value: null + property var old_approximate_diameter_value: null + + onAccepted: + { + base.setMetaDataEntry("approximate_diameter", old_approximate_diameter_value, getApproximateDiameter(new_diameter_value).toString()); + base.setMetaDataEntry("properties/diameter", properties.diameter, new_diameter_value); + // CURA-6868 Make sure to update the extruder to user a diameter-compatible material. + Cura.MachineManager.updateMaterialWithVariant() + base.resetSelectedMaterial() + } + + onRejected: + { + base.properties.diameter = old_diameter_value; + diameterSpinBox.value = Qt.binding(function() { return base.properties.diameter }) + } + } + + Row + { + spacing: UM.Theme.getSize("narrow_margin").width + UM.Label + { + height: informationPage.rowHeight + width: informationPage.columnWidth + text: catalog.i18nc("@label", "Display Name") + } + Cura.TextField + { + id: displayNameTextField; + width: informationPage.columnWidth; + text: properties.name; + enabled: base.editingEnabled; + onEditingFinished: base.updateMaterialDisplayName(properties.name, text) + } + } + + Row + { + spacing: UM.Theme.getSize("narrow_margin").width + UM.Label + { + height: informationPage.rowHeight + width: informationPage.columnWidth + text: catalog.i18nc("@label", "Brand") + } + Cura.TextField + { + id: brandTextField + width: informationPage.columnWidth + text: properties.brand + enabled: base.editingEnabled + onEditingFinished: base.updateMaterialBrand(properties.brand, text) + } + } + + Row + { + spacing: UM.Theme.getSize("narrow_margin").width + UM.Label + { + height: informationPage.rowHeight + width: informationPage.columnWidth + text: catalog.i18nc("@label", "Material Type") + } + Cura.TextField + { + id: materialTypeField + width: informationPage.columnWidth + text: properties.material + enabled: base.editingEnabled + onEditingFinished: base.updateMaterialType(properties.material, text) + } + } + + Row + { + spacing: UM.Theme.getSize("narrow_margin").width + UM.Label + { + height: informationPage.rowHeight + width: informationPage.columnWidth + verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Color") + } + + Row + { + width: informationPage.columnWidth + spacing: Math.round(UM.Theme.getSize("default_margin").width / 2) + + // color indicator square + Item + { + id: colorSelector + + anchors.verticalCenter: parent.verticalCenter + + width: childrenRect.width + 2 * UM.Theme.getSize("narrow_margin").width + height: childrenRect.height + 2 * UM.Theme.getSize("narrow_margin").height + + Rectangle + { + color: properties.color_code + width: UM.Theme.getSize("icon_indicator").width + height: UM.Theme.getSize("icon_indicator").height + radius: width / 2 + anchors.centerIn: parent + } + + // open the color selection dialog on click + MouseArea + { + anchors.fill: parent + onClicked: colorDialog.open() + enabled: base.editingEnabled + } + } + + // pretty color name text field + Cura.TextField + { + id: colorLabel; + width: parent.width - colorSelector.width - parent.spacing + text: properties.color_name; + enabled: base.editingEnabled + onEditingFinished: base.setMetaDataEntry("color_name", properties.color_name, text) + } + + // popup dialog to select a new color + // if successful it sets the properties.color_code value to the new color + Cura.ColorDialog + { + id: colorDialog + title: catalog.i18nc("@title", "Material color picker") + color: properties.color_code + onAccepted: base.setMetaDataEntry("color_code", properties.color_code, color) + } + } + } + + UM.Label + { + width: parent.width + height: parent.rowHeight + font: UM.Theme.getFont("default_bold") + verticalAlignment: Qt.AlignVCenter + text: catalog.i18nc("@label", "Properties") + } + + Row + { + height: parent.rowHeight + spacing: UM.Theme.getSize("narrow_margin").width + UM.Label + { + height: informationPage.rowHeight + width: informationPage.columnWidth + text: catalog.i18nc("@label", "Density") + } + Cura.SpinBox + { + enabled: base.editingEnabled + id: densitySpinBox + width: informationPage.columnWidth + value: properties.density + decimals: 2 + suffix: " g/cm³" + stepSize: 0.01 + + onEditingFinished: base.setMetaDataEntry("properties/density", properties.density, value) + onValueChanged: updateCostPerMeter() + } + } + + Row + { + height: parent.rowHeight + spacing: UM.Theme.getSize("narrow_margin").width + UM.Label + { + height: informationPage.rowHeight + width: informationPage.columnWidth + text: catalog.i18nc("@label", "Diameter") + } + Cura.SpinBox + { + enabled: base.editingEnabled + id: diameterSpinBox + width: informationPage.columnWidth + value: properties.diameter + decimals: 2 + suffix: " mm" + stepSize: 0.01 + + onEditingFinished: + { + // This does not use a SettingPropertyProvider, because we need to make the change to all containers + // which derive from the same base_file + var old_diameter = Cura.ContainerManager.getContainerMetaDataEntry(base.containerId, "properties/diameter"); + var old_approximate_diameter = Cura.ContainerManager.getContainerMetaDataEntry(base.containerId, "approximate_diameter"); + var new_approximate_diameter = getApproximateDiameter(value); + if (new_approximate_diameter != Cura.ExtruderManager.getActiveExtruderStack().approximateMaterialDiameter) + { + confirmDiameterChangeDialog.old_diameter_value = old_diameter; + confirmDiameterChangeDialog.new_diameter_value = value; + confirmDiameterChangeDialog.old_approximate_diameter_value = old_approximate_diameter; + + confirmDiameterChangeDialog.open() + } + else { + base.setMetaDataEntry("approximate_diameter", old_approximate_diameter, getApproximateDiameter(value).toString()); + base.setMetaDataEntry("properties/diameter", properties.diameter, value); + } + } + onValueChanged: updateCostPerMeter() + } + } + + Row + { + height: parent.rowHeight + spacing: UM.Theme.getSize("narrow_margin").width + UM.Label + { + height: informationPage.rowHeight + width: informationPage.columnWidth + text: catalog.i18nc("@label", "Filament Cost") + } + Cura.SpinBox + { + id: spoolCostSpinBox + width: informationPage.columnWidth + value: base.getMaterialPreferenceValue(properties.guid, "spool_cost") + to: 100000000 + editable: true + prefix: base.currency + " " + decimals: 2 + + onValueChanged: + { + base.setMaterialPreferenceValue(properties.guid, "spool_cost", parseFloat(value)) + updateCostPerMeter() + } + } + } + + Row + { + height: parent.rowHeight + spacing: UM.Theme.getSize("narrow_margin").width + UM.Label + { + height: informationPage.rowHeight + width: informationPage.columnWidth + text: catalog.i18nc("@label", "Filament weight") + } + Cura.SpinBox + { + id: spoolWeightSpinBox + width: informationPage.columnWidth + value: base.getMaterialPreferenceValue(properties.guid, "spool_weight", Cura.ContainerManager.getContainerMetaDataEntry(properties.container_id, "properties/weight")) + stepSize: 100 + to: 10000 + editable: true + suffix: " g" + + onValueChanged: + { + base.setMaterialPreferenceValue(properties.guid, "spool_weight", parseFloat(value)) + updateCostPerMeter() + } + } + } + + Row + { + height: parent.rowHeight + spacing: UM.Theme.getSize("narrow_margin").width + UM.Label + { + height: informationPage.rowHeight + width: informationPage.columnWidth + text: catalog.i18nc("@label", "Filament length") + } + UM.Label + { + width: informationPage.columnWidth + text: "~ %1 m".arg(Math.round(base.spoolLength)) + height: informationPage.rowHeight + } + } + + Row + { + height: parent.rowHeight + spacing: UM.Theme.getSize("narrow_margin").width + UM.Label + { + height: informationPage.rowHeight + width: informationPage.columnWidth + text: catalog.i18nc("@label", "Cost per Meter") + } + UM.Label + { + height: informationPage.rowHeight + width: informationPage.columnWidth + text: "~ %1 %2/m".arg(base.costPerMeter.toFixed(2)).arg(base.currency) + } + } + + UM.Label + { + height: parent.rowHeight + width: informationPage.width + text: catalog.i18nc("@label", "This material is linked to %1 and shares some of its properties.").arg(base.linkedMaterialNames) + wrapMode: Text.WordWrap + visible: unlinkMaterialButton.visible + } + Cura.SecondaryButton + { + id: unlinkMaterialButton + text: catalog.i18nc("@label", "Unlink Material") + visible: base.linkedMaterialNames != "" + onClicked: + { + Cura.ContainerManager.unlinkMaterial(base.currentMaterialNode) + base.reevaluateLinkedMaterials = true + } + } + + UM.Label + { + width: informationPage.width + height: parent.rowHeight + text: catalog.i18nc("@label", "Description") + } + ReadOnlyTextArea + { + text: properties.description + width: informationPage.width + height: 0.4 * informationPage.width + wrapMode: Text.WordWrap + + readOnly: !base.editingEnabled + + onEditingFinished: base.setMetaDataEntry("description", properties.description, text) + } + + UM.Label + { + width: informationPage.width + height: parent.rowHeight + text: catalog.i18nc("@label", "Adhesion Information") + } + + ReadOnlyTextArea + { + text: properties.adhesion_info + width: informationPage.width + height: 0.4 * informationPage.width + wrapMode: Text.WordWrap + readOnly: !base.editingEnabled + + onEditingFinished: base.setMetaDataEntry("adhesion_info", properties.adhesion_info, text) + } + } + } + + ListView + { + anchors + { + top: pageSelectorTabRow.bottom + left: parent.left right: parent.right bottom: parent.bottom } - } - ScrollBar.horizontal.policy: ScrollBar.AlwaysOff - clip: true - visible: pageSelectorTabRow.currentItem.activeView === "information" - property real columnWidth: (width * 0.5 - UM.Theme.getSize("default_margin").width) | 0 - - Flow - { - id: containerGrid - - x: UM.Theme.getSize("default_margin").width - y: UM.Theme.getSize("default_lining").height - - width: base.width - property real rowHeight: brandTextField.height + UM.Theme.getSize("default_lining").height - - Cura.MessageDialog + model: UM.SettingDefinitionsModel { - id: confirmDiameterChangeDialog - - title: catalog.i18nc("@title:window", "Confirm Diameter Change") - text: catalog.i18nc("@label (%1 is a number)", "The new filament diameter is set to %1 mm, which is not compatible with the current extruder. Do you wish to continue?".arg(new_diameter_value)) - standardButtons: Dialog.Yes | Dialog.No - - property var new_diameter_value: null - property var old_diameter_value: null - property var old_approximate_diameter_value: null - - onAccepted: - { - base.setMetaDataEntry("approximate_diameter", old_approximate_diameter_value, getApproximateDiameter(new_diameter_value).toString()); - base.setMetaDataEntry("properties/diameter", properties.diameter, new_diameter_value); - // CURA-6868 Make sure to update the extruder to user a diameter-compatible material. - Cura.MachineManager.updateMaterialWithVariant() - base.resetSelectedMaterial() - } - - onRejected: - { - base.properties.diameter = old_diameter_value; - diameterSpinBox.value = Qt.binding(function() { return base.properties.diameter }) - } - } - - Label { width: informationPage.columnWidth; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Display Name") } - Cura.TextField - { - id: displayNameTextField; - width: informationPage.columnWidth; - text: properties.name; - enabled: base.editingEnabled; - onEditingFinished: base.updateMaterialDisplayName(properties.name, text) - } - - Label { width: informationPage.columnWidth; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Brand") } - Cura.TextField - { - id: brandTextField - width: informationPage.columnWidth - text: properties.brand - enabled: base.editingEnabled - onEditingFinished: base.updateMaterialBrand(properties.brand, text) - } - - Label { width: informationPage.columnWidth; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Material Type") } - Cura.TextField - { - id: materialTypeField - width: informationPage.columnWidth - text: properties.material - enabled: base.editingEnabled - onEditingFinished: base.updateMaterialType(properties.material, text) - } - - Label { width: informationPage.columnWidth; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Color") } - Row - { - width: informationPage.columnWidth - height: parent.rowHeight - spacing: Math.round(UM.Theme.getSize("default_margin").width / 2) - - // color indicator square - Rectangle - { - id: colorSelector - color: properties.color_code - - width: Math.round(colorLabel.height * 0.75) - height: Math.round(colorLabel.height * 0.75) - border.width: UM.Theme.getSize("default_lining").height - - anchors.verticalCenter: parent.verticalCenter - - // open the color selection dialog on click - MouseArea - { - anchors.fill: parent - onClicked: colorDialog.open() - enabled: base.editingEnabled - } - } - - // pretty color name text field - Cura.TextField - { - id: colorLabel; - width: parent.width - colorSelector.width - parent.spacing - text: properties.color_name; - enabled: base.editingEnabled - onEditingFinished: base.setMetaDataEntry("color_name", properties.color_name, text) - } - - // popup dialog to select a new color - // if successful it sets the properties.color_code value to the new color - Cura.ColorDialog - { - id: colorDialog - title: catalog.i18nc("@title", "Material color picker") - color: properties.color_code - onAccepted: base.setMetaDataEntry("color_code", properties.color_code, color) - } - } - - Item { width: parent.width; height: UM.Theme.getSize("default_margin").height } - - Label { width: parent.width; height: parent.rowHeight; font.bold: true; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Properties") } - - Label { width: informationPage.columnWidth; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Density") } - - Cura.SpinBox - { - enabled: base.editingEnabled - id: densitySpinBox - width: informationPage.columnWidth - value: properties.density - decimals: 2 - suffix: " g/cm³" - stepSize: 0.01 - - onEditingFinished: base.setMetaDataEntry("properties/density", properties.density, value) - onValueChanged: updateCostPerMeter() - } - - Label { width: informationPage.columnWidth; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Diameter") } - Cura.SpinBox - { - enabled: base.editingEnabled - id: diameterSpinBox - width: informationPage.columnWidth - value: properties.diameter - decimals: 2 - suffix: " mm" - stepSize: 0.01 - - onEditingFinished: - { - // This does not use a SettingPropertyProvider, because we need to make the change to all containers - // which derive from the same base_file - var old_diameter = Cura.ContainerManager.getContainerMetaDataEntry(base.containerId, "properties/diameter"); - var old_approximate_diameter = Cura.ContainerManager.getContainerMetaDataEntry(base.containerId, "approximate_diameter"); - var new_approximate_diameter = getApproximateDiameter(value); - if (new_approximate_diameter != Cura.ExtruderManager.getActiveExtruderStack().approximateMaterialDiameter) - { - confirmDiameterChangeDialog.old_diameter_value = old_diameter; - confirmDiameterChangeDialog.new_diameter_value = value; - confirmDiameterChangeDialog.old_approximate_diameter_value = old_approximate_diameter; - - confirmDiameterChangeDialog.open() - } - else { - base.setMetaDataEntry("approximate_diameter", old_approximate_diameter, getApproximateDiameter(value).toString()); - base.setMetaDataEntry("properties/diameter", properties.diameter, value); - } - } - onValueChanged: updateCostPerMeter() - } - - Label { width: informationPage.columnWidth; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Filament Cost") } - - Cura.SpinBox - { - id: spoolCostSpinBox - width: informationPage.columnWidth - value: base.getMaterialPreferenceValue(properties.guid, "spool_cost") - to: 100000000 - editable: true - prefix: base.currency + " " - decimals: 2 - - onValueChanged: - { - base.setMaterialPreferenceValue(properties.guid, "spool_cost", parseFloat(value)) - updateCostPerMeter() - } - } - - Label { width: informationPage.columnWidth; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Filament weight") } - Cura.SpinBox - { - id: spoolWeightSpinBox - width: informationPage.columnWidth - value: base.getMaterialPreferenceValue(properties.guid, "spool_weight", Cura.ContainerManager.getContainerMetaDataEntry(properties.container_id, "properties/weight")) - stepSize: 100 - to: 10000 - editable: true - suffix: " g" - - onValueChanged: - { - base.setMaterialPreferenceValue(properties.guid, "spool_weight", parseFloat(value)) - updateCostPerMeter() - } - } - - Label { width: informationPage.columnWidth; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Filament length") } - Label - { - width: informationPage.columnWidth - text: "~ %1 m".arg(Math.round(base.spoolLength)) - verticalAlignment: Qt.AlignVCenter - height: parent.rowHeight - } - - Label { width: informationPage.columnWidth; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Cost per Meter") } - Label - { - width: informationPage.columnWidth - text: "~ %1 %2/m".arg(base.costPerMeter.toFixed(2)).arg(base.currency) - verticalAlignment: Qt.AlignVCenter - height: parent.rowHeight - } - - Item { width: parent.width; height: UM.Theme.getSize("default_margin").height; visible: unlinkMaterialButton.visible } - Label - { - width: 2 * informationPage.columnWidth - verticalAlignment: Qt.AlignVCenter - text: catalog.i18nc("@label", "This material is linked to %1 and shares some of its properties.").arg(base.linkedMaterialNames) - wrapMode: Text.WordWrap - visible: unlinkMaterialButton.visible - } - Button - { - id: unlinkMaterialButton - text: catalog.i18nc("@label", "Unlink Material") - visible: base.linkedMaterialNames != "" - onClicked: - { - Cura.ContainerManager.unlinkMaterial(base.currentMaterialNode) - base.reevaluateLinkedMaterials = true - } - } - - Item { width: parent.width; height: UM.Theme.getSize("default_margin").height } - - Label { width: parent.width; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Description") } - - ReadOnlyTextArea - { - text: properties.description; - width: informationPage.columnWidth * 2 - height: 0.75 * informationPage.columnWidth - wrapMode: Text.WordWrap - - readOnly: !base.editingEnabled - - onEditingFinished: base.setMetaDataEntry("description", properties.description, text) - } - - Label { width: parent.width; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Adhesion Information") } - - ReadOnlyTextArea - { - text: properties.adhesion_info - width: 2 * informationPage.columnWidth - wrapMode: Text.WordWrap - height: 0.75 * informationPage.columnWidth - readOnly: !base.editingEnabled - - onEditingFinished: base.setMetaDataEntry("adhesion_info", properties.adhesion_info, text) - } - - Item { width: parent.width; height: UM.Theme.getSize("default_margin").height } - } - } - - ListView - { - anchors - { - top: pageSelectorTabRow.bottom - left: parent.left - right: parent.right - bottom: parent.bottom - } - - model: UM.SettingDefinitionsModel - { - containerId: Cura.MachineManager.activeMachine != null ? Cura.MachineManager.activeMachine.definition.id: "" - visibilityHandler: Cura.MaterialSettingsVisibilityHandler { } - expanded: ["*"] - } - ScrollBar.vertical: UM.ScrollBar {} - clip: true - visible: pageSelectorTabRow.currentItem.activeView === "settings" - - delegate: UM.TooltipArea - { - width: childrenRect.width - height: childrenRect.height - text: model.description - Label - { - id: label - width: base.firstColumnWidth; - height: spinBox.height + UM.Theme.getSize("default_lining").height - text: model.label - elide: Text.ElideRight - verticalAlignment: Qt.AlignVCenter - } - Cura.SpinBox - { - id: spinBox - anchors.left: label.right - value: - { - // In case the setting is not in the material... - if (!isNaN(parseFloat(materialPropertyProvider.properties.value))) - { - return parseFloat(materialPropertyProvider.properties.value); - } - // ... we search in the variant, and if it is not there... - if (!isNaN(parseFloat(variantPropertyProvider.properties.value))) - { - return parseFloat(variantPropertyProvider.properties.value); - } - // ... then look in the definition container. - if (!isNaN(parseFloat(machinePropertyProvider.properties.value))) - { - return parseFloat(machinePropertyProvider.properties.value); - } - return 0; - } - width: base.secondColumnWidth - suffix: " " + model.unit - to: 99999 - decimals: model.unit == "mm" ? 2 : 0 - - onEditingFinished: materialPropertyProvider.setPropertyValue("value", value) - } - - UM.ContainerPropertyProvider - { - id: materialPropertyProvider - containerId: base.containerId - watchedProperties: [ "value" ] - key: model.key - } - UM.ContainerPropertyProvider - { - id: variantPropertyProvider - containerId: Cura.MachineManager.activeStack.variant.id - watchedProperties: [ "value" ] - key: model.key - } - UM.ContainerPropertyProvider - { - id: machinePropertyProvider containerId: Cura.MachineManager.activeMachine != null ? Cura.MachineManager.activeMachine.definition.id: "" - watchedProperties: [ "value" ] - key: model.key + visibilityHandler: Cura.MaterialSettingsVisibilityHandler { } + expanded: ["*"] + } + ScrollBar.vertical: UM.ScrollBar {} + clip: true + visible: pageSelectorTabRow.currentItem.activeView === "settings" + + delegate: UM.TooltipArea + { + width: childrenRect.width + height: childrenRect.height + text: model.description + UM.Label + { + id: label + width: base.firstColumnWidth; + height: spinBox.height + UM.Theme.getSize("default_lining").height + text: model.label + elide: Text.ElideRight + verticalAlignment: Qt.AlignVCenter + } + Cura.SpinBox + { + id: spinBox + anchors.left: label.right + value: + { + // In case the setting is not in the material... + if (!isNaN(parseFloat(materialPropertyProvider.properties.value))) + { + return parseFloat(materialPropertyProvider.properties.value); + } + // ... we search in the variant, and if it is not there... + if (!isNaN(parseFloat(variantPropertyProvider.properties.value))) + { + return parseFloat(variantPropertyProvider.properties.value); + } + // ... then look in the definition container. + if (!isNaN(parseFloat(machinePropertyProvider.properties.value))) + { + return parseFloat(machinePropertyProvider.properties.value); + } + return 0; + } + width: base.secondColumnWidth + suffix: " " + model.unit + to: 99999 + decimals: model.unit == "mm" ? 2 : 0 + + onEditingFinished: materialPropertyProvider.setPropertyValue("value", value) + } + + UM.ContainerPropertyProvider + { + id: materialPropertyProvider + containerId: base.containerId + watchedProperties: [ "value" ] + key: model.key + } + UM.ContainerPropertyProvider + { + id: variantPropertyProvider + containerId: Cura.MachineManager.activeStack.variant.id + watchedProperties: [ "value" ] + key: model.key + } + UM.ContainerPropertyProvider + { + id: machinePropertyProvider + containerId: Cura.MachineManager.activeMachine != null ? Cura.MachineManager.activeMachine.definition.id: "" + watchedProperties: [ "value" ] + key: model.key + } } } } From 418f88a4da2418ff898dd7162f4894bda35ae9c2 Mon Sep 17 00:00:00 2001 From: casper Date: Wed, 9 Mar 2022 15:59:21 +0100 Subject: [PATCH 02/24] boy scouting CURA-8975 --- .../Materials/MaterialsBrandSection.qml | 6 +- .../Materials/MaterialsDetailsPanel.qml | 132 ++++++++---------- .../Preferences/Materials/MaterialsList.qml | 3 +- .../Preferences/Materials/MaterialsSlot.qml | 15 +- .../Materials/MaterialsTypeSection.qml | 6 +- 5 files changed, 75 insertions(+), 87 deletions(-) diff --git a/resources/qml/Preferences/Materials/MaterialsBrandSection.qml b/resources/qml/Preferences/Materials/MaterialsBrandSection.qml index 7c853c8a05..197ddf45a6 100644 --- a/resources/qml/Preferences/Materials/MaterialsBrandSection.qml +++ b/resources/qml/Preferences/Materials/MaterialsBrandSection.qml @@ -1,4 +1,4 @@ -// Copyright (c) 2019 Ultimaker B.V. +// Copyright (c) 2022 Ultimaker B.V. // Cura is released under the terms of the LGPLv3 or higher. import QtQuick 2.7 @@ -26,7 +26,7 @@ Item id: brand_header_background color: { - if(!expanded && sectionName == materialList.currentBrand) + if (!expanded && sectionName == materialList.currentBrand) { return UM.Theme.getColor("favorites_row_selected") } @@ -47,7 +47,7 @@ Item text: sectionName height: UM.Theme.getSize("favorites_row").height width: parent.width - UM.Theme.getSize("favorites_button").width - leftPadding: (UM.Theme.getSize("default_margin").width / 2) | 0 + leftPadding: Math.round(UM.Theme.getSize("default_margin").width / 2) } Item { diff --git a/resources/qml/Preferences/Materials/MaterialsDetailsPanel.qml b/resources/qml/Preferences/Materials/MaterialsDetailsPanel.qml index 04c722cd40..987a1777c1 100644 --- a/resources/qml/Preferences/Materials/MaterialsDetailsPanel.qml +++ b/resources/qml/Preferences/Materials/MaterialsDetailsPanel.qml @@ -1,12 +1,11 @@ -// Copyright (c) 2018 Ultimaker B.V. +// Copyright (c) 2022 Ultimaker B.V. // Uranium is released under the terms of the LGPLv3 or higher. import QtQuick 2.7 -import QtQuick.Controls 1.4 -import QtQuick.Layouts 1.3 +import QtQuick.Controls 2.4 -import UM 1.2 as UM -import Cura 1.0 as Cura +import UM 1.5 as UM +import Cura 1.5 as Cura Item { @@ -51,71 +50,62 @@ Item materialProperties.approximate_diameter = currentItem.approximate_diameter || "0" } - Item - { - anchors.fill: parent + // Material title Label + UM.Label { + id: profileName - Item // Material title Label - { - id: profileName - - width: parent.width - height: childrenRect.height - - Label { - width: parent.width - text: materialProperties.name - font: UM.Theme.getFont("large_bold") - elide: Text.ElideRight - } - } - - MaterialsView // Material detailed information view below the title Label - { - id: materialDetailsView - anchors - { - left: parent.left - right: parent.right - top: profileName.bottom - topMargin: UM.Theme.getSize("default_margin").height - bottom: parent.bottom - } - - editingEnabled: currentItem != null && !currentItem.is_read_only - onResetSelectedMaterial: base.resetExpandedActiveMaterial() - - properties: materialProperties - containerId: currentItem != null ? currentItem.id : "" - currentMaterialNode: currentItem.container_node - } - - QtObject - { - id: materialProperties - - property string guid: "00000000-0000-0000-0000-000000000000" - property string container_id: "Unknown"; - property string name: "Unknown"; - property string profile_type: "Unknown"; - property string brand: "Unknown"; - property string material: "Unknown"; // This needs to be named as "material" to be consistent with - // the material container's metadata entry - - property string color_name: "Yellow"; - property color color_code: "yellow"; - - property real density: 0.0; - property real diameter: 0.0; - property string approximate_diameter: "0"; - - property real spool_cost: 0.0; - property real spool_weight: 0.0; - property real spool_length: 0.0; - property real cost_per_meter: 0.0; - - property string description: ""; - property string adhesion_info: ""; - } + width: parent.width + text: materialProperties.name + font: UM.Theme.getFont("large_bold") + elide: Text.ElideRight } -} \ No newline at end of file + + // Material detailed information view below the title Label + MaterialsView + { + id: materialDetailsView + anchors + { + left: parent.left + right: parent.right + top: profileName.bottom + topMargin: UM.Theme.getSize("default_margin").height + bottom: parent.bottom + } + + editingEnabled: currentItem != null && !currentItem.is_read_only + onResetSelectedMaterial: base.resetExpandedActiveMaterial() + + properties: materialProperties + containerId: currentItem != null ? currentItem.id : "" + currentMaterialNode: currentItem.container_node + } + + QtObject + { + id: materialProperties + + property string guid: "00000000-0000-0000-0000-000000000000" + property string container_id: "Unknown"; + property string name: "Unknown"; + property string profile_type: "Unknown"; + property string brand: "Unknown"; + property string material: "Unknown"; // This needs to be named as "material" to be consistent with + // the material container's metadata entry + + property string color_name: "Yellow"; + property color color_code: "yellow"; + + property real density: 0.0; + property real diameter: 0.0; + property string approximate_diameter: "0"; + + property real spool_cost: 0.0; + property real spool_weight: 0.0; + property real spool_length: 0.0; + property real cost_per_meter: 0.0; + + property string description: ""; + property string adhesion_info: ""; + } +} diff --git a/resources/qml/Preferences/Materials/MaterialsList.qml b/resources/qml/Preferences/Materials/MaterialsList.qml index 6cbb42ad15..bb40187825 100644 --- a/resources/qml/Preferences/Materials/MaterialsList.qml +++ b/resources/qml/Preferences/Materials/MaterialsList.qml @@ -1,4 +1,4 @@ -// Copyright (c) 2019 Ultimaker B.V. +// Copyright (c) 2022 Ultimaker B.V. // Uranium is released under the terms of the LGPLv3 or higher. import QtQuick 2.7 @@ -14,7 +14,6 @@ Item height: childrenRect.height // Children - UM.I18nCatalog { id: catalog; name: "cura"; } Cura.MaterialBrandsModel { id: materialsModel diff --git a/resources/qml/Preferences/Materials/MaterialsSlot.qml b/resources/qml/Preferences/Materials/MaterialsSlot.qml index 03c7d5dc9d..236ceafb0b 100644 --- a/resources/qml/Preferences/Materials/MaterialsSlot.qml +++ b/resources/qml/Preferences/Materials/MaterialsSlot.qml @@ -5,8 +5,8 @@ import QtQuick 2.7 import QtQuick.Controls 2.1 import QtQuick.Layouts 1.3 -import UM 1.2 as UM -import Cura 1.0 as Cura +import UM 1.5 as UM +import Cura 1.5 as Cura // A single material row, typically used in a MaterialsBrandSection @@ -19,17 +19,16 @@ Rectangle height: UM.Theme.getSize("favorites_row").height width: parent.width - //color: material != null ? (base.currentItem.root_material_id == material.root_material_id ? UM.Theme.getColor("favorites_row_selected") : "transparent") : "transparent" color: { - if(material !== null && base.currentItem !== null) + if (material !== null && base.currentItem !== null) { - if(base.currentItem.root_material_id === material.root_material_id) + if (base.currentItem.root_material_id === material.root_material_id) { - return UM.Theme.getColor("favorites_row_selected") + return UM.Theme.getColor("favorites_row_selected"); } } - return "transparent" + return "transparent"; } Rectangle { @@ -42,7 +41,7 @@ Rectangle anchors.left: materialSlot.left anchors.leftMargin: UM.Theme.getSize("default_margin").width } - Label + UM.Label { text: material != null ? material.brand + " " + material.name : "" verticalAlignment: Text.AlignVCenter diff --git a/resources/qml/Preferences/Materials/MaterialsTypeSection.qml b/resources/qml/Preferences/Materials/MaterialsTypeSection.qml index 0a5d0e89e7..78f6bd884c 100644 --- a/resources/qml/Preferences/Materials/MaterialsTypeSection.qml +++ b/resources/qml/Preferences/Materials/MaterialsTypeSection.qml @@ -1,4 +1,4 @@ -// Copyright (c) 2018 Ultimaker B.V. +// Copyright (c) 2022 Ultimaker B.V. // Uranium is released under the terms of the LGPLv3 or higher. import QtQuick 2.7 @@ -18,14 +18,14 @@ Item property var expanded: materialList.expandedTypes.indexOf(materialBrand + "_" + materialName) > -1 property var colorsModel: materialType != null ? materialType.colors: null height: childrenRect.height - width: parent ? parent.width :undefined + width: parent ? parent.width : undefined anchors.left: parent ? parent.left : undefined Rectangle { id: material_type_header_background color: { - if(!expanded && materialBrand + "_" + materialName == materialList.currentType) + if (!expanded && `${materialBrand}_${materialName}` == materialList.currentType) { return UM.Theme.getColor("favorites_row_selected") } From 9ba44f1d3097f3cccae8cd6dfabc36b220630cc8 Mon Sep 17 00:00:00 2001 From: casper Date: Thu, 10 Mar 2022 10:15:31 +0100 Subject: [PATCH 03/24] Move details plane caption to management page This way the caption can be correctly aligned with the hamburger menu button CURA-8979 --- resources/qml/Preferences/MachinesPage.qml | 72 +++--- .../Materials/MaterialsDetailsPanel.qml | 20 +- .../Preferences/Materials/MaterialsPage.qml | 24 +- resources/qml/Preferences/ProfilesPage.qml | 224 +++++++++--------- 4 files changed, 154 insertions(+), 186 deletions(-) diff --git a/resources/qml/Preferences/MachinesPage.qml b/resources/qml/Preferences/MachinesPage.qml index 28568d041b..4a5e0bec15 100644 --- a/resources/qml/Preferences/MachinesPage.qml +++ b/resources/qml/Preferences/MachinesPage.qml @@ -14,13 +14,21 @@ UM.ManagementPage id: base title: catalog.i18nc("@title:tab", "Printers") + detailsPlaneCation: base.currentItem && base.currentItem.name ? base.currentItem.name : "" + model: Cura.GlobalStacksModel { } sectionRole: "discoverySource" activeId: Cura.MachineManager.activeMachine !== null ? Cura.MachineManager.activeMachine.id: "" activeIndex: activeMachineIndex() - onHamburgeButtonClicked: menu.popup(content_item, content_item.width - menu.width, hamburger_button.height) + onHamburgeButtonClicked: { + const hamburerButtonHeight = hamburger_button.height; + menu.popup(hamburger_button, -menu.width + hamburger_button.width / 2, hamburger_button.height); + // for some reason the height of the hamburger changes when opening the popup + // reset height to initial heigt + hamburger_button.height = hamburerButtonHeight; + } hamburgerButtonVisible: Cura.MachineManager.activeMachine !== null function activeMachineIndex() @@ -43,60 +51,39 @@ UM.ManagementPage } ] - Item + Flow { - id: content_item - visible: base.currentItem != null + visible: base.currentItem != null && currentItem && currentItem.id == Cura.MachineManager.activeMachine.id anchors.fill: parent + spacing: UM.Theme.getSize("default_margin").height - - UM.Label + Repeater { - id: machineName - text: base.currentItem && base.currentItem.name ? base.currentItem.name : "" - font: UM.Theme.getFont("large_bold") - width: parent.width - elide: Text.ElideRight - } + id: machineActionRepeater + model: base.currentItem ? Cura.MachineActionManager.getSupportedActions(Cura.MachineManager.getDefinitionByMachineId(base.currentItem.id)) : null - Flow - { - id: machineActions - visible: currentItem && currentItem.id == Cura.MachineManager.activeMachine.id - anchors + Item { - left: parent.left - right: parent.right - top: machineName.bottom - topMargin: UM.Theme.getSize("default_margin").height - } - spacing: UM.Theme.getSize("default_margin").height - - Repeater - { - id: machineActionRepeater - model: base.currentItem ? Cura.MachineActionManager.getSupportedActions(Cura.MachineManager.getDefinitionByMachineId(base.currentItem.id)) : null - - Item + width: Math.round(childrenRect.width + 2 * screenScaleFactor) + height: childrenRect.height + Cura.SecondaryButton { - width: Math.round(childrenRect.width + 2 * screenScaleFactor) - height: childrenRect.height - Cura.SecondaryButton + text: machineActionRepeater.model[index].label + onClicked: { - text: machineActionRepeater.model[index].label - onClicked: - { - var currentItem = machineActionRepeater.model[index] - actionDialog.loader.manager = currentItem - actionDialog.loader.source = currentItem.qmlPath - actionDialog.title = currentItem.label - actionDialog.show() - } + var currentItem = machineActionRepeater.model[index] + actionDialog.loader.manager = currentItem + actionDialog.loader.source = currentItem.qmlPath + actionDialog.title = currentItem.label + actionDialog.show() } } } } + } + Item + { UM.Dialog { id: actionDialog @@ -139,6 +126,7 @@ UM.ManagementPage objectList.onCurrentIndexChanged() } } + Cura.Menu { id: menu diff --git a/resources/qml/Preferences/Materials/MaterialsDetailsPanel.qml b/resources/qml/Preferences/Materials/MaterialsDetailsPanel.qml index 987a1777c1..c96dadda67 100644 --- a/resources/qml/Preferences/Materials/MaterialsDetailsPanel.qml +++ b/resources/qml/Preferences/Materials/MaterialsDetailsPanel.qml @@ -50,29 +50,11 @@ Item materialProperties.approximate_diameter = currentItem.approximate_diameter || "0" } - // Material title Label - UM.Label { - id: profileName - - width: parent.width - text: materialProperties.name - font: UM.Theme.getFont("large_bold") - elide: Text.ElideRight - } - // Material detailed information view below the title Label MaterialsView { id: materialDetailsView - anchors - { - left: parent.left - right: parent.right - top: profileName.bottom - topMargin: UM.Theme.getSize("default_margin").height - bottom: parent.bottom - } - + anchors.fill: parent editingEnabled: currentItem != null && !currentItem.is_read_only onResetSelectedMaterial: base.resetExpandedActiveMaterial() diff --git a/resources/qml/Preferences/Materials/MaterialsPage.qml b/resources/qml/Preferences/Materials/MaterialsPage.qml index a9012e91b6..6c44033a63 100644 --- a/resources/qml/Preferences/Materials/MaterialsPage.qml +++ b/resources/qml/Preferences/Materials/MaterialsPage.qml @@ -68,6 +68,7 @@ UM.ManagementPage } title: catalog.i18nc("@title:tab", "Materials") + detailsPlaneCation: currentItem.name scrollviewCaption: catalog.i18nc("@label", "Materials compatible with active printer:") + `
${Cura.MachineManager.activeMachine.name}` buttons: [ @@ -107,8 +108,13 @@ UM.ManagementPage } ] - onHamburgeButtonClicked: menu.popup(content_item, content_item.width - menu.width, hamburger_button.height) - + onHamburgeButtonClicked: { + const hamburerButtonHeight = hamburger_button.height; + menu.popup(hamburger_button, -menu.width + hamburger_button.width / 2, hamburger_button.height); + // for some reason the height of the hamburger changes when opening the popup + // reset height to initial heigt + hamburger_button.height = hamburerButtonHeight; + } listContent: ScrollView { id: materialScrollView @@ -137,12 +143,14 @@ UM.ManagementPage } } + MaterialsDetailsPanel + { + id: materialDetailsPanel + anchors.fill: parent + } Item { - id: content_item - anchors.fill: parent - Cura.Menu { id: menu @@ -197,12 +205,6 @@ UM.ManagementPage } } - MaterialsDetailsPanel - { - id: materialDetailsPanel - anchors.fill: parent - } - // Dialogs Cura.MessageDialog { diff --git a/resources/qml/Preferences/ProfilesPage.qml b/resources/qml/Preferences/ProfilesPage.qml index e5848a86c7..1d29b691ed 100644 --- a/resources/qml/Preferences/ProfilesPage.qml +++ b/resources/qml/Preferences/ProfilesPage.qml @@ -46,8 +46,6 @@ UM.ManagementPage property string newQualityNameToSelect: "" property bool toActivateNewQuality: false - onHamburgeButtonClicked: menu.popup(content_item, content_item.width - menu.width, hamburger_button.height) - onCreateProfile: { createQualityDialog.object = Cura.ContainerManager.makeUniqueName(Cura.MachineManager.activeQualityOrQualityChangesName); @@ -56,10 +54,18 @@ UM.ManagementPage } title: catalog.i18nc("@title:tab", "Profiles") + detailsPlaneCation: base.currentItemDisplayName scrollviewCaption: catalog.i18nc("@label", "Profiles compatible with active printer:") + "
" + Cura.MachineManager.activeMachine.name + "" hamburgerButtonVisible: hasCurrentItem + onHamburgeButtonClicked: { + const hamburerButtonHeight = hamburger_button.height; + menu.popup(hamburger_button, -menu.width + hamburger_button.width / 2, hamburger_button.height); + // for some reason the height of the hamburger changes when opening the popup + // reset height to initial heigt + hamburger_button.height = hamburerButtonHeight; + } sectionRole: "section_name" model: qualityManagementModel @@ -86,10 +92,110 @@ UM.ManagementPage } ] + Column + { + id: detailsPanelHeaderColumn + anchors + { + left: parent.left + right: parent.right + top: parent.top + } + + spacing: UM.Theme.getSize("default_margin").height + visible: base.currentItem != null + + Flow + { + id: currentSettingsActions + width: parent.width + + visible: base.hasCurrentItem && base.currentItem.name == Cura.MachineManager.activeQualityOrQualityChangesName && base.currentItem.intent_category == Cura.MachineManager.activeIntentCategory + + Cura.SecondaryButton + { + text: catalog.i18nc("@action:button", "Update profile with current settings/overrides") + enabled: Cura.MachineManager.hasUserSettings && objectList.currentIndex && !objectList.currentIndex.is_read_only + onClicked: Cura.ContainerManager.updateQualityChanges() + } + + Cura.SecondaryButton + { + text: catalog.i18nc("@action:button", "Discard current changes") + enabled: Cura.MachineManager.hasUserSettings + onClicked: Cura.ContainerManager.clearUserContainers() + } + } + + UM.Label + { + id: defaultsMessage + visible: false + text: catalog.i18nc("@action:label", "This profile uses the defaults specified by the printer, so it has no settings/overrides in the list below.") + width: parent.width + } + UM.Label + { + id: noCurrentSettingsMessage + visible: base.isCurrentItemActivated && !Cura.MachineManager.hasUserSettings + text: catalog.i18nc("@action:label", "Your current settings match the selected profile.") + width: parent.width + } + + UM.TabRow + { + id: profileExtruderTabs + UM.TabRowButton // One extra tab for the global settings. + { + text: catalog.i18nc("@title:tab", "Global Settings") + } + + Repeater + { + model: base.extrudersModel + + UM.TabRowButton + { + text: model.name + } + } + } + } + + Rectangle + { + color: UM.Theme.getColor("main_background") + anchors + { + top: detailsPanelHeaderColumn.bottom + topMargin: -UM.Theme.getSize("default_lining").width + left: parent.left + right: parent.right + bottom: parent.bottom + } + border.width: UM.Theme.getSize("default_lining").width + border.color: UM.Theme.getColor("thick_lining") + visible: base.hasCurrentItem + } + + Cura.ProfileOverview + { + anchors + { + top: detailsPanelHeaderColumn.bottom + margins: UM.Theme.getSize("default_margin").height + left: parent.left + right: parent.right + bottom: parent.bottom + } + + visible: detailsPanelHeaderColumn.visible + qualityItem: base.currentItem + extruderPosition: profileExtruderTabs.currentIndex - 1 + } + Item { - id: content_item - anchors.fill: parent // This connection makes sure that we will switch to the correct quality after the model gets updated Connections { @@ -294,115 +400,5 @@ UM.ManagementPage CuraApplication.setDefaultPath("dialog_profile_path", folder); } } - - Column - { - id: detailsPanelHeaderColumn - anchors - { - left: parent.left - right: parent.right - top: parent.top - } - - spacing: UM.Theme.getSize("default_margin").height - visible: base.currentItem != null - UM.Label - { - anchors.left: parent.left - anchors.right: parent.right - text: base.currentItemDisplayName - font: UM.Theme.getFont("large_bold") - elide: Text.ElideRight - } - - Flow - { - id: currentSettingsActions - width: parent.width - - visible: base.hasCurrentItem && base.currentItem.name == Cura.MachineManager.activeQualityOrQualityChangesName && base.currentItem.intent_category == Cura.MachineManager.activeIntentCategory - - Cura.SecondaryButton - { - text: catalog.i18nc("@action:button", "Update profile with current settings/overrides") - enabled: Cura.MachineManager.hasUserSettings && objectList.currentIndex && !objectList.currentIndex.is_read_only - onClicked: Cura.ContainerManager.updateQualityChanges() - } - - Cura.SecondaryButton - { - text: catalog.i18nc("@action:button", "Discard current changes") - enabled: Cura.MachineManager.hasUserSettings - onClicked: Cura.ContainerManager.clearUserContainers() - } - } - - UM.Label - { - id: defaultsMessage - visible: false - text: catalog.i18nc("@action:label", "This profile uses the defaults specified by the printer, so it has no settings/overrides in the list below.") - width: parent.width - } - UM.Label - { - id: noCurrentSettingsMessage - visible: base.isCurrentItemActivated && !Cura.MachineManager.hasUserSettings - text: catalog.i18nc("@action:label", "Your current settings match the selected profile.") - width: parent.width - } - - UM.TabRow - { - id: profileExtruderTabs - UM.TabRowButton // One extra tab for the global settings. - { - text: catalog.i18nc("@title:tab", "Global Settings") - } - - Repeater - { - model: base.extrudersModel - - UM.TabRowButton - { - text: model.name - } - } - } - } - - Rectangle - { - color: UM.Theme.getColor("main_background") - anchors - { - top: detailsPanelHeaderColumn.bottom - topMargin: -UM.Theme.getSize("default_lining").width - left: parent.left - right: parent.right - bottom: parent.bottom - } - border.width: UM.Theme.getSize("default_lining").width - border.color: UM.Theme.getColor("thick_lining") - visible: base.hasCurrentItem - } - - Cura.ProfileOverview - { - anchors - { - top: detailsPanelHeaderColumn.bottom - margins: UM.Theme.getSize("default_margin").height - left: parent.left - right: parent.right - bottom: parent.bottom - } - - visible: detailsPanelHeaderColumn.visible - qualityItem: base.currentItem - extruderPosition: profileExtruderTabs.currentIndex - 1 - } } } From 2dd440cc0c2302f8547ae70251abf5caed5aea52 Mon Sep 17 00:00:00 2001 From: casper Date: Thu, 10 Mar 2022 22:13:32 +0100 Subject: [PATCH 04/24] Fix print settings tab in materials view CURA-8979 --- .../Preferences/Materials/MaterialsView.qml | 163 +++++++++--------- 1 file changed, 85 insertions(+), 78 deletions(-) diff --git a/resources/qml/Preferences/Materials/MaterialsView.qml b/resources/qml/Preferences/Materials/MaterialsView.qml index 56b71efe34..1997d1f739 100644 --- a/resources/qml/Preferences/Materials/MaterialsView.qml +++ b/resources/qml/Preferences/Materials/MaterialsView.qml @@ -511,91 +511,98 @@ Item } } - ListView + Column { - anchors - { - top: pageSelectorTabRow.bottom - left: parent.left - right: parent.right - bottom: parent.bottom - } - - model: UM.SettingDefinitionsModel - { - containerId: Cura.MachineManager.activeMachine != null ? Cura.MachineManager.activeMachine.definition.id: "" - visibilityHandler: Cura.MaterialSettingsVisibilityHandler { } - expanded: ["*"] - } + visible: pageSelectorTabRow.currentItem.activeView === "settings" + spacing: UM.Theme.getSize("narrow_margin").height + anchors.fill: parent + anchors.topMargin: UM.Theme.getSize("thin_margin").height + anchors.bottomMargin: UM.Theme.getSize("thin_margin").height + anchors.leftMargin: UM.Theme.getSize("thin_margin").width + anchors.rightMargin: UM.Theme.getSize("thin_margin").width ScrollBar.vertical: UM.ScrollBar {} clip: true - visible: pageSelectorTabRow.currentItem.activeView === "settings" - delegate: UM.TooltipArea + Repeater { - width: childrenRect.width - height: childrenRect.height - text: model.description - UM.Label + model: UM.SettingDefinitionsModel { - id: label - width: base.firstColumnWidth; - height: spinBox.height + UM.Theme.getSize("default_lining").height - text: model.label - elide: Text.ElideRight - verticalAlignment: Qt.AlignVCenter - } - Cura.SpinBox - { - id: spinBox - anchors.left: label.right - value: - { - // In case the setting is not in the material... - if (!isNaN(parseFloat(materialPropertyProvider.properties.value))) - { - return parseFloat(materialPropertyProvider.properties.value); - } - // ... we search in the variant, and if it is not there... - if (!isNaN(parseFloat(variantPropertyProvider.properties.value))) - { - return parseFloat(variantPropertyProvider.properties.value); - } - // ... then look in the definition container. - if (!isNaN(parseFloat(machinePropertyProvider.properties.value))) - { - return parseFloat(machinePropertyProvider.properties.value); - } - return 0; - } - width: base.secondColumnWidth - suffix: " " + model.unit - to: 99999 - decimals: model.unit == "mm" ? 2 : 0 - - onEditingFinished: materialPropertyProvider.setPropertyValue("value", value) - } - - UM.ContainerPropertyProvider - { - id: materialPropertyProvider - containerId: base.containerId - watchedProperties: [ "value" ] - key: model.key - } - UM.ContainerPropertyProvider - { - id: variantPropertyProvider - containerId: Cura.MachineManager.activeStack.variant.id - watchedProperties: [ "value" ] - key: model.key - } - UM.ContainerPropertyProvider - { - id: machinePropertyProvider containerId: Cura.MachineManager.activeMachine != null ? Cura.MachineManager.activeMachine.definition.id: "" - watchedProperties: [ "value" ] - key: model.key + visibilityHandler: Cura.MaterialSettingsVisibilityHandler { } + expanded: ["*"] + } + + delegate: UM.TooltipArea + { + width: childrenRect.width + height: childrenRect.height + + UM.TooltipArea + { + anchors.fill: parent + text: model.description + } + UM.Label + { + id: label + width: base.firstColumnWidth; + height: spinBox.height + UM.Theme.getSize("default_lining").height + text: model.label + elide: Text.ElideRight + verticalAlignment: Qt.AlignVCenter + } + Cura.SpinBox + { + id: spinBox + anchors.left: label.right + value: + { + // In case the setting is not in the material... + if (!isNaN(parseFloat(materialPropertyProvider.properties.value))) + { + return parseFloat(materialPropertyProvider.properties.value); + } + // ... we search in the variant, and if it is not there... + if (!isNaN(parseFloat(variantPropertyProvider.properties.value))) + { + return parseFloat(variantPropertyProvider.properties.value); + } + // ... then look in the definition container. + if (!isNaN(parseFloat(machinePropertyProvider.properties.value))) + { + return parseFloat(machinePropertyProvider.properties.value); + } + return 0; + } + width: base.secondColumnWidth + suffix: " " + model.unit + to: 99999 + decimals: model.unit == "mm" ? 2 : 0 + + onEditingFinished: materialPropertyProvider.setPropertyValue("value", value) + } + + UM.ContainerPropertyProvider + { + id: materialPropertyProvider + containerId: base.containerId + watchedProperties: [ "value" ] + key: model.key + } + UM.ContainerPropertyProvider + { + id: variantPropertyProvider + containerId: Cura.MachineManager.activeStack.variant.id + watchedProperties: [ "value" ] + key: model.key + } + UM.ContainerPropertyProvider + { + id: machinePropertyProvider + containerId: Cura.MachineManager.activeMachine != null ? Cura.MachineManager.activeMachine.definition.id: "" + watchedProperties: ["value"] + key: model.key + } } } } From c6b8abd53e0c402d22ffca3284d9b4160beaca43 Mon Sep 17 00:00:00 2001 From: casper Date: Fri, 11 Mar 2022 13:22:45 +0100 Subject: [PATCH 05/24] Update materials slot CURA-8979 --- .../Preferences/Materials/MaterialsSlot.qml | 119 ++++++++++-------- 1 file changed, 65 insertions(+), 54 deletions(-) diff --git a/resources/qml/Preferences/Materials/MaterialsSlot.qml b/resources/qml/Preferences/Materials/MaterialsSlot.qml index 236ceafb0b..46384262cd 100644 --- a/resources/qml/Preferences/Materials/MaterialsSlot.qml +++ b/resources/qml/Preferences/Materials/MaterialsSlot.qml @@ -13,23 +13,31 @@ import Cura 1.5 as Cura Rectangle { id: materialSlot + property var material: null - property var hovered: false - property var is_favorite: material != null && material.is_favorite + property bool hovered: false height: UM.Theme.getSize("favorites_row").height width: parent.width - color: - { - if (material !== null && base.currentItem !== null) + color: UM.Theme.getColor("main_background") + + states: + [ + State { - if (base.currentItem.root_material_id === material.root_material_id) - { - return UM.Theme.getColor("favorites_row_selected"); - } + name: "selected" + when: material !== null && base.currentItem !== null && base.currentItem.root_material_id === material.root_material_id + PropertyChanges { target: materialSlot; color: UM.Theme.getColor("background_3") } + PropertyChanges { target: materialLabel; font: UM.Theme.getFont("default_italic") } + }, + State + { + name: "hovered" + when: hovered + PropertyChanges { target: materialSlot; color: UM.Theme.getColor("background_3") } } - return "transparent"; - } + ] + Rectangle { id: swatch @@ -43,79 +51,82 @@ Rectangle } UM.Label { - text: material != null ? material.brand + " " + material.name : "" + id: materialLabel + text: material != null ? `${material.brand} ${material.name}` : "" verticalAlignment: Text.AlignVCenter - height: parent.height anchors.left: swatch.right anchors.verticalCenter: materialSlot.verticalCenter - anchors.leftMargin: UM.Theme.getSize("narrow_margin").width - font.italic: material != null && Cura.MachineManager.currentRootMaterialId[Cura.ExtruderManager.activeExtruderIndex] == material.root_material_id + anchors.leftMargin: UM.Theme.getSize("default_margin").width + font: UM.Theme.getFont("default") } + MouseArea { anchors.fill: parent onClicked: { - materialList.currentBrand = material.brand - materialList.currentType = material.brand + "_" + material.material - base.setExpandedActiveMaterial(material.root_material_id) + materialList.currentBrand = material.brand; + materialList.currentType = `${material.brand}_${material.material}`; + base.setExpandedActiveMaterial(material.root_material_id); } hoverEnabled: true onEntered: { materialSlot.hovered = true } onExited: { materialSlot.hovered = false } } - Button + + Item { - id: favorite_button - text: "" - implicitWidth: UM.Theme.getSize("favorites_button").width - implicitHeight: UM.Theme.getSize("favorites_button").height - visible: materialSlot.hovered || materialSlot.is_favorite || favorite_button.hovered - anchors - { - right: materialSlot.right - verticalCenter: materialSlot.verticalCenter - } - onClicked: - { - if (materialSlot.is_favorite) + id: favoriteButton + + states: + [ + State { - CuraApplication.getMaterialManagementModel().removeFavorite(material.root_material_id) - } - else + name: "favorite" + when: material !== null && material.is_favorite + PropertyChanges { target: favoriteIndicator; source: UM.Theme.getIcon("StarFilled"); color: UM.Theme.getColor("primary") } + PropertyChanges { target: favoriteButton; visible: true } + }, + State { - CuraApplication.getMaterialManagementModel().addFavorite(material.root_material_id) + name: "hovered" + when: hovered + PropertyChanges { target: favoriteButton; visible: true } } - } + ] + + implicitHeight: parent.height + implicitWidth: height + anchors.right: materialSlot.right + visible: false UM.RecolorImage { - anchors + id: favoriteIndicator + anchors.centerIn: parent + width: UM.Theme.getSize("small_button_icon").width + height: UM.Theme.getSize("small_button_icon").height + color: UM.Theme.getColor("text_inactive") + source: UM.Theme.getIcon("Star") + } + + MouseArea + { + anchors.fill: parent + onClicked: { - verticalCenter: favorite_button.verticalCenter - horizontalCenter: favorite_button.horizontalCenter - } - width: UM.Theme.getSize("favorites_button_icon").width - height: UM.Theme.getSize("favorites_button_icon").height - color: - { - if (favorite_button.hovered) + if (material !== null) { - return UM.Theme.getColor("primary_hover") - } - else - { - if (materialSlot.is_favorite) + if (material.is_favorite) { - return UM.Theme.getColor("primary") + CuraApplication.getMaterialManagementModel().removeFavorite(material.root_material_id) } else { - UM.Theme.getColor("text_inactive") + CuraApplication.getMaterialManagementModel().addFavorite(material.root_material_id) } } } - source: materialSlot.is_favorite ? UM.Theme.getIcon("StarFilled") : UM.Theme.getIcon("Star") } } } From e2c9e0a461eb6f04dfbc69dbf9834e5a54e7bf46 Mon Sep 17 00:00:00 2001 From: casper Date: Fri, 11 Mar 2022 16:29:37 +0100 Subject: [PATCH 06/24] Elide text in materials slot CURA-8979 --- resources/qml/Preferences/Materials/MaterialsSlot.qml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/resources/qml/Preferences/Materials/MaterialsSlot.qml b/resources/qml/Preferences/Materials/MaterialsSlot.qml index 46384262cd..f3416fc15e 100644 --- a/resources/qml/Preferences/Materials/MaterialsSlot.qml +++ b/resources/qml/Preferences/Materials/MaterialsSlot.qml @@ -53,11 +53,14 @@ Rectangle { id: materialLabel text: material != null ? `${material.brand} ${material.name}` : "" + elide: Text.ElideRight + wrapMode: Text.NoWrap verticalAlignment: Text.AlignVCenter anchors.left: swatch.right - anchors.verticalCenter: materialSlot.verticalCenter + anchors.right: parent.right anchors.leftMargin: UM.Theme.getSize("default_margin").width - font: UM.Theme.getFont("default") + anchors.rightMargin: UM.Theme.getSize("narrow_margin").width + anchors.verticalCenter: materialSlot.verticalCenter } MouseArea From b2f13cc6c9f8122b25d322e45e484d57d0b37160 Mon Sep 17 00:00:00 2001 From: casper Date: Fri, 11 Mar 2022 16:40:32 +0100 Subject: [PATCH 07/24] Update Category Button Put content of category button in a `RowLayout` so individual content Components can easily be removed by hiding said component while keeping margins and spacings work as intended. Additionaly make the icon property optional CURA-8979 --- resources/qml/CategoryButton.qml | 59 +++++++++++++++----------------- 1 file changed, 27 insertions(+), 32 deletions(-) diff --git a/resources/qml/CategoryButton.qml b/resources/qml/CategoryButton.qml index dfd9625f6f..13e19fe5ab 100644 --- a/resources/qml/CategoryButton.qml +++ b/resources/qml/CategoryButton.qml @@ -10,6 +10,7 @@ import QtQuick 2.2 import QtQuick.Controls 2.1 +import QtQuick.Layouts 1.1 import UM 1.5 as UM @@ -17,13 +18,14 @@ Button { id: base - height: enabled ? UM.Theme.getSize("section_header").height : 0 + height: UM.Theme.getSize("section_header").height property var expanded: false property alias arrow: categoryArrow property alias categoryIcon: icon.source property alias labelText: categoryLabel.text + property alias labelFont: categoryLabel.font states: [ @@ -56,14 +58,13 @@ Button background: Rectangle { id: backgroundRectangle - height: base.height color: UM.Theme.getColor("setting_category") Behavior on color { ColorAnimation { duration: 50 } } + // Lining on top Rectangle { - //Lining on top anchors.top: parent.top color: UM.Theme.getColor("border_main") height: UM.Theme.getSize("default_lining").height @@ -71,51 +72,45 @@ Button } } - contentItem: Item + contentItem: RowLayout { - anchors.fill: parent + id: content + spacing: UM.Theme.getSize("narrow_margin").width + + UM.RecolorImage + { + id: icon + source: "" + visible: icon.source != "" + Layout.alignment: Qt.AlignHCenter + color: UM.Theme.getColor("setting_category_text") + width: UM.Theme.getSize("section_icon").width + height: UM.Theme.getSize("section_icon").height + sourceSize.width: width + sourceSize.height: width + } UM.Label { id: categoryLabel - anchors - { - left: parent.left - leftMargin: UM.Theme.getSize("default_margin").width + UM.Theme.getSize("section_icon").width - right: parent.right - verticalCenter: parent.verticalCenter - } - textFormat: Text.PlainText + Layout.fillWidth: true + Layout.alignment: Qt.AlignHCenter + elide: Text.ElideRight + wrapMode: Text.NoWrap font: UM.Theme.getFont("medium_bold") color: UM.Theme.getColor("setting_category_text") - fontSizeMode: Text.HorizontalFit - minimumPointSize: 8 } UM.RecolorImage { id: categoryArrow - anchors.verticalCenter: parent.verticalCenter - anchors.right: parent.right - anchors.rightMargin: UM.Theme.getSize("narrow_margin").width + Layout.alignment: Qt.AlignHCenter width: UM.Theme.getSize("standard_arrow").width height: UM.Theme.getSize("standard_arrow").height - sourceSize.height: width + sourceSize.width: width + sourceSize.height: height color: UM.Theme.getColor("setting_control_button") source: expanded ? UM.Theme.getIcon("ChevronSingleDown") : UM.Theme.getIcon("ChevronSingleLeft") } } - - UM.RecolorImage - { - id: icon - anchors.verticalCenter: parent.verticalCenter - anchors.left: parent.left - anchors.leftMargin: UM.Theme.getSize("narrow_margin").width - color: UM.Theme.getColor("setting_category_text") - width: UM.Theme.getSize("section_icon").width - height: UM.Theme.getSize("section_icon").height - sourceSize.width: width - sourceSize.height: width - } } \ No newline at end of file From 5136838f5683a544ecf9a897fbf1b1a0597f4ef7 Mon Sep 17 00:00:00 2001 From: casper Date: Fri, 11 Mar 2022 16:42:11 +0100 Subject: [PATCH 08/24] Update materials list in materials preference page Main improvement of this commit is that the reusable category button component is used as the collapsable header component for the material brands/types. CURA-8979 --- .../Materials/MaterialsBrandSection.qml | 86 ++++---------- .../Materials/MaterialsTypeSection.qml | 107 ++++-------------- 2 files changed, 42 insertions(+), 151 deletions(-) diff --git a/resources/qml/Preferences/Materials/MaterialsBrandSection.qml b/resources/qml/Preferences/Materials/MaterialsBrandSection.qml index 197ddf45a6..65b8a7365a 100644 --- a/resources/qml/Preferences/Materials/MaterialsBrandSection.qml +++ b/resources/qml/Preferences/Materials/MaterialsBrandSection.qml @@ -10,100 +10,52 @@ import Cura 1.0 as Cura // An expandable list of materials. Includes both the header (this file) and the items (brandMaterialList) -Item +Column { id: brand_section - property var sectionName: "" + property string sectionName: "" property var elementsModel // This can be a MaterialTypesModel or GenericMaterialsModel or FavoriteMaterialsModel - property var hasMaterialTypes: true // It indicates whether it has material types or not - property var expanded: materialList.expandedBrands.indexOf(sectionName) > -1 + property bool hasMaterialTypes: true // It indicates whether it has material types or not + property bool expanded: materialList.expandedBrands.indexOf(sectionName) !== -1 - height: childrenRect.height width: parent.width - Rectangle + + Cura.CategoryButton { - id: brand_header_background - color: - { - if (!expanded && sectionName == materialList.currentBrand) - { - return UM.Theme.getColor("favorites_row_selected") - } - else - { - return UM.Theme.getColor("favorites_header_bar") - } - } - anchors.fill: brand_header - } - Row - { - id: brand_header width: parent.width - UM.Label + height: UM.Theme.getSize("favorites_row").height + labelText: sectionName + labelFont: UM.Theme.getFont("default_bold") + expanded: brand_section.expanded + onClicked: { - id: brand_name - text: sectionName - height: UM.Theme.getSize("favorites_row").height - width: parent.width - UM.Theme.getSize("favorites_button").width - leftPadding: Math.round(UM.Theme.getSize("default_margin").width / 2) - } - Item - { - implicitWidth: UM.Theme.getSize("favorites_button").width - implicitHeight: UM.Theme.getSize("favorites_button").height - UM.RecolorImage + const i = materialList.expandedBrands.indexOf(sectionName); + if (i !== -1) { - anchors - { - verticalCenter: parent.verticalCenter - horizontalCenter: parent.horizontalCenter - } - width: UM.Theme.getSize("standard_arrow").width - height: UM.Theme.getSize("standard_arrow").height - color: "black" - source: brand_section.expanded ? UM.Theme.getIcon("ChevronSingleDown") : UM.Theme.getIcon("ChevronSingleLeft") - } - } - } - MouseArea - { - anchors.fill: brand_header - onPressed: - { - const i = materialList.expandedBrands.indexOf(sectionName) - if (i > -1) - { - // Remove it - materialList.expandedBrands.splice(i, 1) - brand_section.expanded = false + materialList.expandedBrands.splice(i, 1); // remove } else { - // Add it - materialList.expandedBrands.push(sectionName) - brand_section.expanded = true + materialList.expandedBrands.push(sectionName); // add } UM.Preferences.setValue("cura/expanded_brands", materialList.expandedBrands.join(";")); } } + Column { id: brandMaterialList - anchors.top: brand_header.bottom width: parent.width - anchors.left: parent ? parent.left : undefined - height: brand_section.expanded ? childrenRect.height : 0 visible: brand_section.expanded Repeater { model: elementsModel + delegate: Loader { - id: loader - width: parent ? parent.width : 0 + width: parent.width property var element: model sourceComponent: hasMaterialTypes ? materialsTypeSection : materialSlot } @@ -138,7 +90,7 @@ Item return; } - expanded = materialList.expandedBrands.indexOf(sectionName) > -1 + brand_section.expanded = materialList.expandedBrands.indexOf(sectionName) !== -1; } } } diff --git a/resources/qml/Preferences/Materials/MaterialsTypeSection.qml b/resources/qml/Preferences/Materials/MaterialsTypeSection.qml index 78f6bd884c..a9a050478e 100644 --- a/resources/qml/Preferences/Materials/MaterialsTypeSection.qml +++ b/resources/qml/Preferences/Materials/MaterialsTypeSection.qml @@ -8,106 +8,45 @@ import QtQuick.Layouts 1.3 import UM 1.5 as UM import Cura 1.0 as Cura -Item +Column { id: material_type_section - property var materialType + property var materialType: null + property string materialBrand: materialType !== null ? materialType.brand : "" + property string materialName: materialType !== null ? materialType.name : "" + property bool expanded: materialList.expandedTypes.indexOf(`${materialBrand}_${materialName}`) !== -1 + property var colorsModel: materialType !== null ? materialType.colors : null - property string materialBrand: materialType != null ? materialType.brand : "" - property string materialName: materialType != null ? materialType.name : "" - property var expanded: materialList.expandedTypes.indexOf(materialBrand + "_" + materialName) > -1 - property var colorsModel: materialType != null ? materialType.colors: null - height: childrenRect.height - width: parent ? parent.width : undefined - anchors.left: parent ? parent.left : undefined - Rectangle + width: parent.width + + Cura.CategoryButton { - id: material_type_header_background - color: + width: parent.width + height: UM.Theme.getSize("favorites_row").height + labelText: materialName + labelFont: UM.Theme.getFont("default") + expanded: material_type_section.expanded + onClicked: { - if (!expanded && `${materialBrand}_${materialName}` == materialList.currentType) + const identifier = `${materialBrand}_${materialName}`; + const i = materialList.expandedTypes.indexOf(identifier); + if (i !== -1) { - return UM.Theme.getColor("favorites_row_selected") + materialList.expandedTypes.splice(i, 1); // remove } else { - return "transparent" - } - } - width: parent.width - height: material_type_header.height - } - Rectangle - { - id: material_type_header_border - color: UM.Theme.getColor("favorites_header_bar") - anchors.bottom: material_type_header.bottom - anchors.left: material_type_header.left - height: UM.Theme.getSize("default_lining").height - width: material_type_header.width - } - Row - { - id: material_type_header - width: parent.width - leftPadding: UM.Theme.getSize("default_margin").width - anchors - { - left: parent ? parent.left : undefined - } - UM.Label - { - text: materialName - height: UM.Theme.getSize("favorites_row").height - width: parent.width - parent.leftPadding - UM.Theme.getSize("favorites_button").width - id: material_type_name - } - Item // this one causes lots of warnings - { - implicitWidth: UM.Theme.getSize("favorites_button").width - implicitHeight: UM.Theme.getSize("favorites_button").height - UM.RecolorImage { - anchors - { - verticalCenter: parent ? parent.verticalCenter : undefined - horizontalCenter: parent ? parent.horizontalCenter : undefined - } - width: UM.Theme.getSize("standard_arrow").width - height: UM.Theme.getSize("standard_arrow").height - color: "black" - source: material_type_section.expanded ? UM.Theme.getIcon("ChevronSingleDown") : UM.Theme.getIcon("ChevronSingleLeft") - } - - } - } - MouseArea // causes lots of warnings - { - anchors.fill: material_type_header - onPressed: - { - const identifier = materialBrand + "_" + materialName; - const i = materialList.expandedTypes.indexOf(identifier) - if (i > -1) - { - // Remove it - materialList.expandedTypes.splice(i, 1) - material_type_section.expanded = false - } - else - { - // Add it - materialList.expandedTypes.push(identifier) - material_type_section.expanded = true + materialList.expandedTypes.push(identifier); // add } UM.Preferences.setValue("cura/expanded_types", materialList.expandedTypes.join(";")); } } + Column { - height: material_type_section.expanded ? childrenRect.height : 0 visible: material_type_section.expanded width: parent.width - anchors.top: material_type_header.bottom + Repeater { model: colorsModel @@ -128,7 +67,7 @@ Item return; } - expanded = materialList.expandedTypes.indexOf(materialBrand + "_" + materialName) > -1 + material_type_section.expanded = materialList.expandedTypes.indexOf(`${materialBrand}_${materialName}`) !== -1; } } } From 93405bdb933650f5f6c764d6418a077ca22b0a28 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Tue, 15 Mar 2022 10:16:49 +0100 Subject: [PATCH 09/24] Add identation for the materials preferences page CURA-8979 --- resources/qml/CategoryButton.qml | 22 ++++++++++++------- .../Materials/MaterialsBrandSection.qml | 2 +- .../Preferences/Materials/MaterialsSlot.qml | 2 +- .../Materials/MaterialsTypeSection.qml | 3 ++- 4 files changed, 18 insertions(+), 11 deletions(-) diff --git a/resources/qml/CategoryButton.qml b/resources/qml/CategoryButton.qml index 13e19fe5ab..b5d8bb2b2d 100644 --- a/resources/qml/CategoryButton.qml +++ b/resources/qml/CategoryButton.qml @@ -21,12 +21,13 @@ Button height: UM.Theme.getSize("section_header").height property var expanded: false - + property bool indented: false property alias arrow: categoryArrow property alias categoryIcon: icon.source property alias labelText: categoryLabel.text property alias labelFont: categoryLabel.font - + leftPadding: UM.Theme.getSize("narrow_margin").width + rightPadding: UM.Theme.getSize("narrow_margin").width states: [ State @@ -72,20 +73,21 @@ Button } } - contentItem: RowLayout + contentItem: Item { id: content - spacing: UM.Theme.getSize("narrow_margin").width + //spacing: UM.Theme.getSize("narrow_margin").width UM.RecolorImage { id: icon source: "" visible: icon.source != "" - Layout.alignment: Qt.AlignHCenter + anchors.verticalCenter: parent.verticalCenter color: UM.Theme.getColor("setting_category_text") - width: UM.Theme.getSize("section_icon").width + width: visible ? UM.Theme.getSize("section_icon").width: 0 height: UM.Theme.getSize("section_icon").height + anchors.leftMargin: base.indented ? UM.Theme.getSize("default_margin").width: 0 sourceSize.width: width sourceSize.height: width } @@ -94,7 +96,10 @@ Button { id: categoryLabel Layout.fillWidth: true - Layout.alignment: Qt.AlignHCenter + anchors.right: categoryArrow.left + anchors.left: icon.right + anchors.leftMargin: base.indented ? UM.Theme.getSize("default_margin").width + UM.Theme.getSize("narrow_margin").width: UM.Theme.getSize("narrow_margin").width + anchors.verticalCenter: parent.verticalCenter elide: Text.ElideRight wrapMode: Text.NoWrap font: UM.Theme.getFont("medium_bold") @@ -104,9 +109,10 @@ Button UM.RecolorImage { id: categoryArrow - Layout.alignment: Qt.AlignHCenter + anchors.right: parent.right width: UM.Theme.getSize("standard_arrow").width height: UM.Theme.getSize("standard_arrow").height + anchors.verticalCenter: parent.verticalCenter sourceSize.width: width sourceSize.height: height color: UM.Theme.getColor("setting_control_button") diff --git a/resources/qml/Preferences/Materials/MaterialsBrandSection.qml b/resources/qml/Preferences/Materials/MaterialsBrandSection.qml index 65b8a7365a..d9b0a66f15 100644 --- a/resources/qml/Preferences/Materials/MaterialsBrandSection.qml +++ b/resources/qml/Preferences/Materials/MaterialsBrandSection.qml @@ -18,7 +18,6 @@ Column property var elementsModel // This can be a MaterialTypesModel or GenericMaterialsModel or FavoriteMaterialsModel property bool hasMaterialTypes: true // It indicates whether it has material types or not property bool expanded: materialList.expandedBrands.indexOf(sectionName) !== -1 - width: parent.width Cura.CategoryButton @@ -68,6 +67,7 @@ Column MaterialsTypeSection { materialType: element + indented: true } } diff --git a/resources/qml/Preferences/Materials/MaterialsSlot.qml b/resources/qml/Preferences/Materials/MaterialsSlot.qml index f3416fc15e..232e8bbdf8 100644 --- a/resources/qml/Preferences/Materials/MaterialsSlot.qml +++ b/resources/qml/Preferences/Materials/MaterialsSlot.qml @@ -47,7 +47,7 @@ Rectangle radius: width / 2 anchors.verticalCenter: materialSlot.verticalCenter anchors.left: materialSlot.left - anchors.leftMargin: UM.Theme.getSize("default_margin").width + anchors.leftMargin: 2 * UM.Theme.getSize("default_margin").width } UM.Label { diff --git a/resources/qml/Preferences/Materials/MaterialsTypeSection.qml b/resources/qml/Preferences/Materials/MaterialsTypeSection.qml index a9a050478e..fa3130b801 100644 --- a/resources/qml/Preferences/Materials/MaterialsTypeSection.qml +++ b/resources/qml/Preferences/Materials/MaterialsTypeSection.qml @@ -16,11 +16,12 @@ Column property string materialName: materialType !== null ? materialType.name : "" property bool expanded: materialList.expandedTypes.indexOf(`${materialBrand}_${materialName}`) !== -1 property var colorsModel: materialType !== null ? materialType.colors : null - + property alias indented: categoryButton.indented width: parent.width Cura.CategoryButton { + id: categoryButton width: parent.width height: UM.Theme.getSize("favorites_row").height labelText: materialName From f760ca146d960c0a8704b7477d059e5606dda024 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Tue, 15 Mar 2022 10:25:56 +0100 Subject: [PATCH 10/24] Fix sizing of materialBrandSelection This also cleans up some stuff from the theme. Huzzah CURA-8979 --- .../qml/Preferences/Materials/MaterialsBrandSection.qml | 3 +-- resources/qml/Preferences/Materials/MaterialsSlot.qml | 2 +- .../qml/Preferences/Materials/MaterialsTypeSection.qml | 2 +- resources/themes/cura-light/theme.json | 8 +------- 4 files changed, 4 insertions(+), 11 deletions(-) diff --git a/resources/qml/Preferences/Materials/MaterialsBrandSection.qml b/resources/qml/Preferences/Materials/MaterialsBrandSection.qml index d9b0a66f15..5ffce9b750 100644 --- a/resources/qml/Preferences/Materials/MaterialsBrandSection.qml +++ b/resources/qml/Preferences/Materials/MaterialsBrandSection.qml @@ -23,9 +23,8 @@ Column Cura.CategoryButton { width: parent.width - height: UM.Theme.getSize("favorites_row").height labelText: sectionName - labelFont: UM.Theme.getFont("default_bold") + labelFont: UM.Theme.getFont("medium_bold") expanded: brand_section.expanded onClicked: { diff --git a/resources/qml/Preferences/Materials/MaterialsSlot.qml b/resources/qml/Preferences/Materials/MaterialsSlot.qml index 232e8bbdf8..0c50d6b2f3 100644 --- a/resources/qml/Preferences/Materials/MaterialsSlot.qml +++ b/resources/qml/Preferences/Materials/MaterialsSlot.qml @@ -17,7 +17,7 @@ Rectangle property var material: null property bool hovered: false - height: UM.Theme.getSize("favorites_row").height + height: UM.Theme.getSize("preferences_page_list_item").height width: parent.width color: UM.Theme.getColor("main_background") diff --git a/resources/qml/Preferences/Materials/MaterialsTypeSection.qml b/resources/qml/Preferences/Materials/MaterialsTypeSection.qml index fa3130b801..d781218027 100644 --- a/resources/qml/Preferences/Materials/MaterialsTypeSection.qml +++ b/resources/qml/Preferences/Materials/MaterialsTypeSection.qml @@ -23,7 +23,7 @@ Column { id: categoryButton width: parent.width - height: UM.Theme.getSize("favorites_row").height + height: UM.Theme.getSize("preferences_page_list_item").height labelText: materialName labelFont: UM.Theme.getFont("default") expanded: material_type_section.expanded diff --git a/resources/themes/cura-light/theme.json b/resources/themes/cura-light/theme.json index 5583053ea2..6895e382fa 100644 --- a/resources/themes/cura-light/theme.json +++ b/resources/themes/cura-light/theme.json @@ -431,8 +431,6 @@ "layerview_nozzle": [224, 192, 16, 64], "layerview_starts": [255, 255, 255, 255], - "favorites_header_bar": [245, 245, 245, 255], - "favorites_row_selected": [196, 239, 255, 255], "monitor_printer_family_tag": [228, 228, 242, 255], "monitor_text_disabled": [238, 238, 238, 255], @@ -561,11 +559,7 @@ "medium_button_icon": [2, 2], "context_menu": [20, 2], - - "favorites_row": [2, 2], - "favorites_button": [2, 2], - "favorites_button_icon": [1.2, 1.2], - + "icon_indicator": [1, 1], "printer_status_icon": [1.0, 1.0], From 97124bf5a9bbf58f825df2b6b1f64f6c21bd84e0 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Tue, 15 Mar 2022 10:32:44 +0100 Subject: [PATCH 11/24] Fix various QML warnings CURA-8979 --- .../qml/Preferences/Materials/MaterialsDetailsPanel.qml | 2 +- resources/qml/Preferences/Materials/MaterialsPage.qml | 2 +- resources/qml/Preferences/Materials/MaterialsView.qml | 6 +++--- resources/themes/cura-light/theme.json | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/resources/qml/Preferences/Materials/MaterialsDetailsPanel.qml b/resources/qml/Preferences/Materials/MaterialsDetailsPanel.qml index c96dadda67..bb9e732800 100644 --- a/resources/qml/Preferences/Materials/MaterialsDetailsPanel.qml +++ b/resources/qml/Preferences/Materials/MaterialsDetailsPanel.qml @@ -60,7 +60,7 @@ Item properties: materialProperties containerId: currentItem != null ? currentItem.id : "" - currentMaterialNode: currentItem.container_node + currentMaterialNode: currentItem != null ? currentItem.container_node: null } QtObject diff --git a/resources/qml/Preferences/Materials/MaterialsPage.qml b/resources/qml/Preferences/Materials/MaterialsPage.qml index 6c44033a63..a777701b21 100644 --- a/resources/qml/Preferences/Materials/MaterialsPage.qml +++ b/resources/qml/Preferences/Materials/MaterialsPage.qml @@ -68,7 +68,7 @@ UM.ManagementPage } title: catalog.i18nc("@title:tab", "Materials") - detailsPlaneCation: currentItem.name + detailsPlaneCation: currentItem ? currentItem.name: "" scrollviewCaption: catalog.i18nc("@label", "Materials compatible with active printer:") + `
${Cura.MachineManager.activeMachine.name}` buttons: [ diff --git a/resources/qml/Preferences/Materials/MaterialsView.qml b/resources/qml/Preferences/Materials/MaterialsView.qml index 1997d1f739..a860472f39 100644 --- a/resources/qml/Preferences/Materials/MaterialsView.qml +++ b/resources/qml/Preferences/Materials/MaterialsView.qml @@ -97,7 +97,6 @@ Item } border.width: UM.Theme.getSize("default_lining").width border.color: UM.Theme.getColor("thick_lining") - visible: base.hasCurrentItem ScrollView { @@ -240,11 +239,12 @@ Item anchors.verticalCenter: parent.verticalCenter - width: childrenRect.width + 2 * UM.Theme.getSize("narrow_margin").width - height: childrenRect.height + 2 * UM.Theme.getSize("narrow_margin").height + width: colorSelectorBackground.width + 2 * UM.Theme.getSize("narrow_margin").width + height: colorSelectorBackground.height + 2 * UM.Theme.getSize("narrow_margin").height Rectangle { + id: colorSelectorBackground color: properties.color_code width: UM.Theme.getSize("icon_indicator").width height: UM.Theme.getSize("icon_indicator").height diff --git a/resources/themes/cura-light/theme.json b/resources/themes/cura-light/theme.json index 6895e382fa..fce18d88bc 100644 --- a/resources/themes/cura-light/theme.json +++ b/resources/themes/cura-light/theme.json @@ -559,7 +559,7 @@ "medium_button_icon": [2, 2], "context_menu": [20, 2], - + "icon_indicator": [1, 1], "printer_status_icon": [1.0, 1.0], From 59b7d20f75ad76daa1113b3807c0cecbcb03f903 Mon Sep 17 00:00:00 2001 From: "j.delarago" Date: Tue, 15 Mar 2022 14:50:02 +0100 Subject: [PATCH 12/24] Update ReadOnlyTextArea import MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Update ReadOnlyTextArea style (It's not really read only 🤔) CURA-8979 --- resources/qml/Preferences/Materials/MaterialsView.qml | 6 ++---- resources/qml/Preferences/ReadOnlyTextArea.qml | 7 ++----- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/resources/qml/Preferences/Materials/MaterialsView.qml b/resources/qml/Preferences/Materials/MaterialsView.qml index a860472f39..4c15e04972 100644 --- a/resources/qml/Preferences/Materials/MaterialsView.qml +++ b/resources/qml/Preferences/Materials/MaterialsView.qml @@ -9,8 +9,6 @@ import QtQuick.Layouts 1.3 import UM 1.5 as UM import Cura 1.0 as Cura -import ".." // Access to ReadOnlyTextArea.qml - Item { id: base @@ -479,7 +477,7 @@ Item height: parent.rowHeight text: catalog.i18nc("@label", "Description") } - ReadOnlyTextArea + Cura.ReadOnlyTextArea { text: properties.description width: informationPage.width @@ -498,7 +496,7 @@ Item text: catalog.i18nc("@label", "Adhesion Information") } - ReadOnlyTextArea + Cura.ReadOnlyTextArea { text: properties.adhesion_info width: informationPage.width diff --git a/resources/qml/Preferences/ReadOnlyTextArea.qml b/resources/qml/Preferences/ReadOnlyTextArea.qml index c6f253f0ca..291e241718 100644 --- a/resources/qml/Preferences/ReadOnlyTextArea.qml +++ b/resources/qml/Preferences/ReadOnlyTextArea.qml @@ -23,13 +23,10 @@ ScrollView enabled: !base.readOnly selectByMouse: true - background: Rectangle - { - radius: UM.Theme.getSize("setting_control_radius").width - color: textArea.enabled ? UM.Theme.getColor("setting_control") : UM.Theme.getColor("setting_control_disabled") - } + background: UM.UnderlineBackground { id: backgroundRectangle } color: UM.Theme.getColor("text") + selectionColor: UM.Theme.getColor("text_selection") font: UM.Theme.getFont("default") Keys.onReturnPressed: base.editingFinished() From bf784dbba03ed5bdc932e4fa4446723e28a40017 Mon Sep 17 00:00:00 2001 From: "j.delarago" Date: Tue, 15 Mar 2022 15:03:49 +0100 Subject: [PATCH 13/24] show star on hover CURA-8979 --- resources/qml/Preferences/Materials/MaterialsSlot.qml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/qml/Preferences/Materials/MaterialsSlot.qml b/resources/qml/Preferences/Materials/MaterialsSlot.qml index 0c50d6b2f3..6e620fe44b 100644 --- a/resources/qml/Preferences/Materials/MaterialsSlot.qml +++ b/resources/qml/Preferences/Materials/MaterialsSlot.qml @@ -87,7 +87,7 @@ Rectangle { name: "favorite" when: material !== null && material.is_favorite - PropertyChanges { target: favoriteIndicator; source: UM.Theme.getIcon("StarFilled"); color: UM.Theme.getColor("primary") } + PropertyChanges { target: favoriteIndicator; source: UM.Theme.getIcon("StarFilled");} PropertyChanges { target: favoriteButton; visible: true } }, State @@ -109,7 +109,7 @@ Rectangle anchors.centerIn: parent width: UM.Theme.getSize("small_button_icon").width height: UM.Theme.getSize("small_button_icon").height - color: UM.Theme.getColor("text_inactive") + color: UM.Theme.getColor("primary") source: UM.Theme.getIcon("Star") } From 99f9918db506044e98b419d8d8d0fd0f4d49b3a1 Mon Sep 17 00:00:00 2001 From: "j.delarago" Date: Tue, 15 Mar 2022 15:05:26 +0100 Subject: [PATCH 14/24] Remove Italics CURA-8979 --- resources/qml/Preferences/Materials/MaterialsSlot.qml | 1 - 1 file changed, 1 deletion(-) diff --git a/resources/qml/Preferences/Materials/MaterialsSlot.qml b/resources/qml/Preferences/Materials/MaterialsSlot.qml index 6e620fe44b..6b66ee9777 100644 --- a/resources/qml/Preferences/Materials/MaterialsSlot.qml +++ b/resources/qml/Preferences/Materials/MaterialsSlot.qml @@ -28,7 +28,6 @@ Rectangle name: "selected" when: material !== null && base.currentItem !== null && base.currentItem.root_material_id === material.root_material_id PropertyChanges { target: materialSlot; color: UM.Theme.getColor("background_3") } - PropertyChanges { target: materialLabel; font: UM.Theme.getFont("default_italic") } }, State { From b33a5d7b8464a6a033e6a2894f156dba21371c2c Mon Sep 17 00:00:00 2001 From: "j.delarago" Date: Tue, 15 Mar 2022 15:54:50 +0100 Subject: [PATCH 15/24] Add space, so content isn't bellow scrollbar CURA-8979 --- .../qml/Preferences/Materials/MaterialsView.qml | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/resources/qml/Preferences/Materials/MaterialsView.qml b/resources/qml/Preferences/Materials/MaterialsView.qml index 4c15e04972..a579a36a8d 100644 --- a/resources/qml/Preferences/Materials/MaterialsView.qml +++ b/resources/qml/Preferences/Materials/MaterialsView.qml @@ -110,6 +110,7 @@ Item ScrollBar.vertical: UM.ScrollBar { + id: scrollBar parent: informationPage anchors { @@ -122,7 +123,7 @@ Item clip: true visible: pageSelectorTabRow.currentItem.activeView === "information" - property real columnWidth: Math.floor(width / 2 - UM.Theme.getSize("narrow_margin").width) + property real columnWidth: Math.floor((width - scrollBar.width - UM.Theme.getSize("narrow_margin").width) / 2) property real rowHeight: UM.Theme.getSize("setting_control").height Column @@ -169,10 +170,10 @@ Item } Cura.TextField { - id: displayNameTextField; - width: informationPage.columnWidth; - text: properties.name; - enabled: base.editingEnabled; + id: displayNameTextField + width: informationPage.columnWidth + text: properties.name + enabled: base.editingEnabled onEditingFinished: base.updateMaterialDisplayName(properties.name, text) } } @@ -480,7 +481,7 @@ Item Cura.ReadOnlyTextArea { text: properties.description - width: informationPage.width + width: informationPage.width - scrollBar.width height: 0.4 * informationPage.width wrapMode: Text.WordWrap @@ -499,7 +500,7 @@ Item Cura.ReadOnlyTextArea { text: properties.adhesion_info - width: informationPage.width + width: informationPage.width - scrollBar.width height: 0.4 * informationPage.width wrapMode: Text.WordWrap readOnly: !base.editingEnabled From 9dbc497fcbe68ab78ceef6023398fbbadf2baf34 Mon Sep 17 00:00:00 2001 From: "j.delarago" Date: Tue, 15 Mar 2022 16:19:33 +0100 Subject: [PATCH 16/24] Move TabRow below so it renders over the top lining of content rectangles. Update Tab styles to match designs CURA-8979 --- .../Preferences/Materials/MaterialsView.qml | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/resources/qml/Preferences/Materials/MaterialsView.qml b/resources/qml/Preferences/Materials/MaterialsView.qml index a579a36a8d..c1f8e93bc1 100644 --- a/resources/qml/Preferences/Materials/MaterialsView.qml +++ b/resources/qml/Preferences/Materials/MaterialsView.qml @@ -66,21 +66,6 @@ Item } } - UM.TabRow - { - id: pageSelectorTabRow - UM.TabRowButton - { - text: catalog.i18nc("@title", "Information") - property string activeView: "information" //To determine which page gets displayed. - } - UM.TabRowButton - { - text: catalog.i18nc("@label", "Print settings") - property string activeView: "settings" - } - } - Rectangle { color: UM.Theme.getColor("main_background") @@ -94,7 +79,7 @@ Item bottom: parent.bottom } border.width: UM.Theme.getSize("default_lining").width - border.color: UM.Theme.getColor("thick_lining") + border.color: UM.Theme.getColor("border_main") ScrollView { @@ -607,6 +592,21 @@ Item } } + UM.TabRow + { + id: pageSelectorTabRow + UM.TabRowButton + { + text: catalog.i18nc("@title", "Information") + property string activeView: "information" //To determine which page gets displayed. + } + UM.TabRowButton + { + text: catalog.i18nc("@label", "Print settings") + property string activeView: "settings" + } + } + function updateCostPerMeter() { base.spoolLength = calculateSpoolLength(diameterSpinBox.value, densitySpinBox.value, spoolWeightSpinBox.value); From 4b853b89bdc3c7cf5f643866ad3c400ef3c8ff34 Mon Sep 17 00:00:00 2001 From: "j.delarago" Date: Tue, 15 Mar 2022 16:23:18 +0100 Subject: [PATCH 17/24] Fix typo CURA-8979 --- resources/qml/Preferences/MachinesPage.qml | 2 +- resources/qml/Preferences/Materials/MaterialsPage.qml | 2 +- resources/qml/Preferences/ProfilesPage.qml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/resources/qml/Preferences/MachinesPage.qml b/resources/qml/Preferences/MachinesPage.qml index 4a5e0bec15..93a35ff9bb 100644 --- a/resources/qml/Preferences/MachinesPage.qml +++ b/resources/qml/Preferences/MachinesPage.qml @@ -14,7 +14,7 @@ UM.ManagementPage id: base title: catalog.i18nc("@title:tab", "Printers") - detailsPlaneCation: base.currentItem && base.currentItem.name ? base.currentItem.name : "" + detailsPlaneCaption: base.currentItem && base.currentItem.name ? base.currentItem.name : "" model: Cura.GlobalStacksModel { } diff --git a/resources/qml/Preferences/Materials/MaterialsPage.qml b/resources/qml/Preferences/Materials/MaterialsPage.qml index a777701b21..9c90ecef0d 100644 --- a/resources/qml/Preferences/Materials/MaterialsPage.qml +++ b/resources/qml/Preferences/Materials/MaterialsPage.qml @@ -68,7 +68,7 @@ UM.ManagementPage } title: catalog.i18nc("@title:tab", "Materials") - detailsPlaneCation: currentItem ? currentItem.name: "" + detailsPlaneCaption: currentItem ? currentItem.name: "" scrollviewCaption: catalog.i18nc("@label", "Materials compatible with active printer:") + `
${Cura.MachineManager.activeMachine.name}` buttons: [ diff --git a/resources/qml/Preferences/ProfilesPage.qml b/resources/qml/Preferences/ProfilesPage.qml index 185ca44eac..c8de3ccb5b 100644 --- a/resources/qml/Preferences/ProfilesPage.qml +++ b/resources/qml/Preferences/ProfilesPage.qml @@ -54,7 +54,7 @@ UM.ManagementPage } title: catalog.i18nc("@title:tab", "Profiles") - detailsPlaneCation: base.currentItemDisplayName + detailsPlaneCaption: base.currentItemDisplayName scrollviewCaption: catalog.i18nc("@label", "Profiles compatible with active printer:") + "
" + Cura.MachineManager.activeMachine.name + "" hamburgerButtonVisible: hasCurrentItem From 503f21090e8cb51fcf194f42bbe0ca386c5ab892 Mon Sep 17 00:00:00 2001 From: "j.delarago" Date: Fri, 18 Mar 2022 13:42:55 +0100 Subject: [PATCH 18/24] Swap materials page SpinBox for NumericTextFieldWithUnit This fixes, filament cost iterating backwards with spinbox ( who knows why it did this ) text not updating when different material selected value with decimals not saving Remove margin from NumericTextFieldWithUnit.qml. Not sure why this was present, it made the TextField slightly smaller than the rest. Remove some parsing str to float/int. Not needed since settings are stored as str CURA-8979 --- .../NumericTextFieldWithUnit.qml | 4 +- .../Preferences/Materials/MaterialsView.qml | 132 +++++++++++------- 2 files changed, 81 insertions(+), 55 deletions(-) diff --git a/resources/qml/MachineSettings/NumericTextFieldWithUnit.qml b/resources/qml/MachineSettings/NumericTextFieldWithUnit.qml index 67840d4f26..51c9730052 100644 --- a/resources/qml/MachineSettings/NumericTextFieldWithUnit.qml +++ b/resources/qml/MachineSettings/NumericTextFieldWithUnit.qml @@ -22,6 +22,7 @@ UM.TooltipArea property int controlWidth: UM.Theme.getSize("setting_control").width property int controlHeight: UM.Theme.getSize("setting_control").height + property real spacing: UM.Theme.getSize("default_margin").width text: tooltipText @@ -75,7 +76,7 @@ UM.TooltipArea { id: textFieldWithUnit anchors.left: fieldLabel.right - anchors.leftMargin: UM.Theme.getSize("default_margin").width + anchors.leftMargin: spacing verticalAlignment: Text.AlignVCenter selectionColor: UM.Theme.getColor("text_selection") selectedTextColor: UM.Theme.getColor("setting_control_text") @@ -88,7 +89,6 @@ UM.TooltipArea background: UM.UnderlineBackground { anchors.fill: parent - anchors.margins: Math.round(UM.Theme.getSize("default_lining").width) liningColor: { diff --git a/resources/qml/Preferences/Materials/MaterialsView.qml b/resources/qml/Preferences/Materials/MaterialsView.qml index c1f8e93bc1..29fd82eac7 100644 --- a/resources/qml/Preferences/Materials/MaterialsView.qml +++ b/resources/qml/Preferences/Materials/MaterialsView.qml @@ -140,7 +140,7 @@ Item onRejected: { base.properties.diameter = old_diameter_value; - diameterSpinBox.value = Qt.binding(function() { return base.properties.diameter }) + diameterTextField.valueText = Qt.binding(function() { return base.properties.diameter }) } } @@ -286,18 +286,26 @@ Item width: informationPage.columnWidth text: catalog.i18nc("@label", "Density") } - Cura.SpinBox - { - enabled: base.editingEnabled - id: densitySpinBox - width: informationPage.columnWidth - value: properties.density - decimals: 2 - suffix: " g/cm³" - stepSize: 0.01 - onEditingFinished: base.setMetaDataEntry("properties/density", properties.density, value) - onValueChanged: updateCostPerMeter() + Cura.NumericTextFieldWithUnit + { + id: densityTextField + enabled: base.editingEnabled + valueText: properties.density + controlWidth: informationPage.columnWidth + controlHeight: informationPage.rowHeight + spacing: 0 + unitText: "g/cm³" + decimals: 2 + maximum: 1000 + + editingFinishedFunction: function() + { + var modified_text = valueText.replace(",", "."); + base.setMetaDataEntry("properties/density", properties.density, modified_text) + } + + onValueTextChanged: updateCostPerMeter() } } @@ -311,37 +319,43 @@ Item width: informationPage.columnWidth text: catalog.i18nc("@label", "Diameter") } - Cura.SpinBox - { - enabled: base.editingEnabled - id: diameterSpinBox - width: informationPage.columnWidth - value: properties.diameter - decimals: 2 - suffix: " mm" - stepSize: 0.01 - onEditingFinished: + Cura.NumericTextFieldWithUnit + { + id: diameterTextField + enabled: base.editingEnabled + valueText: properties.diameter + controlWidth: informationPage.columnWidth + controlHeight: informationPage.rowHeight + spacing: 0 + unitText: "mm" + decimals: 2 + maximum: 1000 + + editingFinishedFunction: function() { // This does not use a SettingPropertyProvider, because we need to make the change to all containers // which derive from the same base_file var old_diameter = Cura.ContainerManager.getContainerMetaDataEntry(base.containerId, "properties/diameter"); var old_approximate_diameter = Cura.ContainerManager.getContainerMetaDataEntry(base.containerId, "approximate_diameter"); - var new_approximate_diameter = getApproximateDiameter(value); + var modified_value = valueText.replace(",", "."); + var new_approximate_diameter = getApproximateDiameter(modified_value); + if (new_approximate_diameter != Cura.ExtruderManager.getActiveExtruderStack().approximateMaterialDiameter) { confirmDiameterChangeDialog.old_diameter_value = old_diameter; - confirmDiameterChangeDialog.new_diameter_value = value; + confirmDiameterChangeDialog.new_diameter_value = modified_value; confirmDiameterChangeDialog.old_approximate_diameter_value = old_approximate_diameter; confirmDiameterChangeDialog.open() } else { - base.setMetaDataEntry("approximate_diameter", old_approximate_diameter, getApproximateDiameter(value).toString()); - base.setMetaDataEntry("properties/diameter", properties.diameter, value); + base.setMetaDataEntry("approximate_diameter", old_approximate_diameter, new_approximate_diameter); + base.setMetaDataEntry("properties/diameter", properties.diameter, modified_value); } } - onValueChanged: updateCostPerMeter() + + onValueTextChanged: updateCostPerMeter() } } @@ -355,21 +369,25 @@ Item width: informationPage.columnWidth text: catalog.i18nc("@label", "Filament Cost") } - Cura.SpinBox - { - id: spoolCostSpinBox - width: informationPage.columnWidth - value: base.getMaterialPreferenceValue(properties.guid, "spool_cost") - to: 100000000 - editable: true - prefix: base.currency + " " - decimals: 2 - onValueChanged: + Cura.NumericTextFieldWithUnit + { + id: spoolCostTextField + valueText: base.getMaterialPreferenceValue(properties.guid, "spool_cost") + controlWidth: informationPage.columnWidth + controlHeight: informationPage.rowHeight + spacing: 0 + unitText: base.currency + decimals: 2 + maximum: 100000000 + + editingFinishedFunction: function() { - base.setMaterialPreferenceValue(properties.guid, "spool_cost", parseFloat(value)) - updateCostPerMeter() + var modified_text = valueText.replace(",", "."); + base.setMaterialPreferenceValue(properties.guid, "spool_cost", modified_text); } + + onValueTextChanged: updateCostPerMeter() } } @@ -383,21 +401,25 @@ Item width: informationPage.columnWidth text: catalog.i18nc("@label", "Filament weight") } - Cura.SpinBox - { - id: spoolWeightSpinBox - width: informationPage.columnWidth - value: base.getMaterialPreferenceValue(properties.guid, "spool_weight", Cura.ContainerManager.getContainerMetaDataEntry(properties.container_id, "properties/weight")) - stepSize: 100 - to: 10000 - editable: true - suffix: " g" - onValueChanged: + Cura.NumericTextFieldWithUnit + { + id: spoolWeightTextField + valueText: base.getMaterialPreferenceValue(properties.guid, "spool_weight", Cura.ContainerManager.getContainerMetaDataEntry(properties.container_id, "properties/weight")) + controlWidth: informationPage.columnWidth + controlHeight: informationPage.rowHeight + spacing: 0 + unitText: " g" + decimals: 0 + maximum: 10000 + + editingFinishedFunction: function() { - base.setMaterialPreferenceValue(properties.guid, "spool_weight", parseFloat(value)) - updateCostPerMeter() + var modified_text = valueText.replace(",", ".") + base.setMaterialPreferenceValue(properties.guid, "spool_weight", modified_text) } + + onValueTextChanged: updateCostPerMeter() } } @@ -609,8 +631,12 @@ Item function updateCostPerMeter() { - base.spoolLength = calculateSpoolLength(diameterSpinBox.value, densitySpinBox.value, spoolWeightSpinBox.value); - base.costPerMeter = calculateCostPerMeter(spoolCostSpinBox.value); + var modified_weight = spoolWeightTextField.valueText.replace(",", ".") + var modified_cost = spoolCostTextField.valueText.replace(",", ".") + var modified_diameter = diameterTextField.valueText.replace(",", ".") + var modified_density = densityTextField.valueText.replace(",", ".") + base.spoolLength = calculateSpoolLength(modified_diameter, modified_density, parseInt(modified_weight)); + base.costPerMeter = calculateCostPerMeter(parseFloat(modified_cost)); } function calculateSpoolLength(diameter, density, spoolWeight) From c7bb97aa6c977f0d134bc34beca29704d4f0121b Mon Sep 17 00:00:00 2001 From: "j.delarago" Date: Fri, 18 Mar 2022 13:56:19 +0100 Subject: [PATCH 19/24] Add tooltip to materials list itmes. CURA-8979 --- resources/qml/Preferences/Materials/MaterialsSlot.qml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/resources/qml/Preferences/Materials/MaterialsSlot.qml b/resources/qml/Preferences/Materials/MaterialsSlot.qml index 6b66ee9777..0be5342361 100644 --- a/resources/qml/Preferences/Materials/MaterialsSlot.qml +++ b/resources/qml/Preferences/Materials/MaterialsSlot.qml @@ -62,9 +62,11 @@ Rectangle anchors.verticalCenter: materialSlot.verticalCenter } - MouseArea + UM.TooltipArea { anchors.fill: parent + text: material != null ? `${material.brand} ${material.name}` : "" + onClicked: { materialList.currentBrand = material.brand; From c6bd020dec3d6282f799214116999cece62f517f Mon Sep 17 00:00:00 2001 From: "j.delarago" Date: Fri, 18 Mar 2022 13:58:41 +0100 Subject: [PATCH 20/24] Anchor material name to star icon so text doesn't display under star icon. CURA-8979 --- resources/qml/Preferences/Materials/MaterialsSlot.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/qml/Preferences/Materials/MaterialsSlot.qml b/resources/qml/Preferences/Materials/MaterialsSlot.qml index 0be5342361..720c45800d 100644 --- a/resources/qml/Preferences/Materials/MaterialsSlot.qml +++ b/resources/qml/Preferences/Materials/MaterialsSlot.qml @@ -56,7 +56,7 @@ Rectangle wrapMode: Text.NoWrap verticalAlignment: Text.AlignVCenter anchors.left: swatch.right - anchors.right: parent.right + anchors.right: favoriteButton.left anchors.leftMargin: UM.Theme.getSize("default_margin").width anchors.rightMargin: UM.Theme.getSize("narrow_margin").width anchors.verticalCenter: materialSlot.verticalCenter From bd91078e6e4f73927de72ca1bf27a433dccef94f Mon Sep 17 00:00:00 2001 From: "j.delarago" Date: Fri, 18 Mar 2022 14:08:20 +0100 Subject: [PATCH 21/24] Accept click events on materials items in materials list CURA-8979 --- resources/qml/Preferences/Materials/MaterialsSlot.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/qml/Preferences/Materials/MaterialsSlot.qml b/resources/qml/Preferences/Materials/MaterialsSlot.qml index 720c45800d..1c68d074c2 100644 --- a/resources/qml/Preferences/Materials/MaterialsSlot.qml +++ b/resources/qml/Preferences/Materials/MaterialsSlot.qml @@ -66,7 +66,7 @@ Rectangle { anchors.fill: parent text: material != null ? `${material.brand} ${material.name}` : "" - + acceptedButtons: Qt.LeftButton onClicked: { materialList.currentBrand = material.brand; From c10865b179b32e1a6c03e7433906921880a7d7e1 Mon Sep 17 00:00:00 2001 From: "j.delarago" Date: Fri, 18 Mar 2022 14:45:03 +0100 Subject: [PATCH 22/24] Fixes this error QML Column: ScrollBar must be attached to a Flickable or ScrollView by wrapping the Column in a ScrollView the same way that is done for the information page. CURA-8979 --- .../Preferences/Materials/MaterialsView.qml | 185 ++++++++++-------- 1 file changed, 103 insertions(+), 82 deletions(-) diff --git a/resources/qml/Preferences/Materials/MaterialsView.qml b/resources/qml/Preferences/Materials/MaterialsView.qml index 29fd82eac7..2a3d5dc7fb 100644 --- a/resources/qml/Preferences/Materials/MaterialsView.qml +++ b/resources/qml/Preferences/Materials/MaterialsView.qml @@ -18,8 +18,6 @@ Item property bool editingEnabled: false property string currency: UM.Preferences.getValue("cura/currency") ? UM.Preferences.getValue("cura/currency") : "€" - property real firstColumnWidth: (width * 0.50) | 0 - property real secondColumnWidth: (width * 0.40) | 0 property string containerId: "" property var materialPreferenceValues: UM.Preferences.getValue("cura/material_settings") ? JSON.parse(UM.Preferences.getValue("cura/material_settings")) : {} property var materialManagementModel: CuraApplication.getMaterialManagementModel() @@ -517,97 +515,120 @@ Item } } - Column + ScrollView { + id: settingsPage visible: pageSelectorTabRow.currentItem.activeView === "settings" - spacing: UM.Theme.getSize("narrow_margin").height - anchors.fill: parent - anchors.topMargin: UM.Theme.getSize("thin_margin").height - anchors.bottomMargin: UM.Theme.getSize("thin_margin").height - anchors.leftMargin: UM.Theme.getSize("thin_margin").width - anchors.rightMargin: UM.Theme.getSize("thin_margin").width - ScrollBar.vertical: UM.ScrollBar {} clip: true - Repeater + anchors { - model: UM.SettingDefinitionsModel + fill: parent + topMargin: UM.Theme.getSize("thin_margin").height + bottomMargin: UM.Theme.getSize("thin_margin").height + leftMargin: UM.Theme.getSize("thin_margin").width + rightMargin: UM.Theme.getSize("thin_margin").width + } + + ScrollBar.horizontal.policy: ScrollBar.AlwaysOff + ScrollBar.vertical: UM.ScrollBar + { + id: settingScrollBar + parent: settingsPage + anchors { - containerId: Cura.MachineManager.activeMachine != null ? Cura.MachineManager.activeMachine.definition.id: "" - visibilityHandler: Cura.MaterialSettingsVisibilityHandler { } - expanded: ["*"] + top: parent.top + right: parent.right + bottom: parent.bottom } + } - delegate: UM.TooltipArea + property real columnWidth: Math.floor((width - settingScrollBar.width - UM.Theme.getSize("narrow_margin").width) / 2) + + Column + { + width: settingsPage.width + spacing: UM.Theme.getSize("narrow_margin").height + Repeater { - width: childrenRect.width - height: childrenRect.height - - UM.TooltipArea + model: UM.SettingDefinitionsModel { - anchors.fill: parent - text: model.description - } - UM.Label - { - id: label - width: base.firstColumnWidth; - height: spinBox.height + UM.Theme.getSize("default_lining").height - text: model.label - elide: Text.ElideRight - verticalAlignment: Qt.AlignVCenter - } - Cura.SpinBox - { - id: spinBox - anchors.left: label.right - value: - { - // In case the setting is not in the material... - if (!isNaN(parseFloat(materialPropertyProvider.properties.value))) - { - return parseFloat(materialPropertyProvider.properties.value); - } - // ... we search in the variant, and if it is not there... - if (!isNaN(parseFloat(variantPropertyProvider.properties.value))) - { - return parseFloat(variantPropertyProvider.properties.value); - } - // ... then look in the definition container. - if (!isNaN(parseFloat(machinePropertyProvider.properties.value))) - { - return parseFloat(machinePropertyProvider.properties.value); - } - return 0; - } - width: base.secondColumnWidth - suffix: " " + model.unit - to: 99999 - decimals: model.unit == "mm" ? 2 : 0 - - onEditingFinished: materialPropertyProvider.setPropertyValue("value", value) - } - - UM.ContainerPropertyProvider - { - id: materialPropertyProvider - containerId: base.containerId - watchedProperties: [ "value" ] - key: model.key - } - UM.ContainerPropertyProvider - { - id: variantPropertyProvider - containerId: Cura.MachineManager.activeStack.variant.id - watchedProperties: [ "value" ] - key: model.key - } - UM.ContainerPropertyProvider - { - id: machinePropertyProvider containerId: Cura.MachineManager.activeMachine != null ? Cura.MachineManager.activeMachine.definition.id: "" - watchedProperties: ["value"] - key: model.key + visibilityHandler: Cura.MaterialSettingsVisibilityHandler { } + expanded: ["*"] + } + + delegate: UM.TooltipArea + { + width: childrenRect.width + height: childrenRect.height + + UM.TooltipArea + { + anchors.fill: parent + text: model.description + } + UM.Label + { + id: label + width: settingsPage.columnWidth + height: spinBox.height + UM.Theme.getSize("default_lining").height + text: model.label + elide: Text.ElideRight + verticalAlignment: Qt.AlignVCenter + } + Cura.SpinBox + { + id: spinBox + anchors.left: label.right + value: + { + // In case the setting is not in the material... + if (!isNaN(parseFloat(materialPropertyProvider.properties.value))) + { + return parseFloat(materialPropertyProvider.properties.value); + } + // ... we search in the variant, and if it is not there... + if (!isNaN(parseFloat(variantPropertyProvider.properties.value))) + { + return parseFloat(variantPropertyProvider.properties.value); + } + // ... then look in the definition container. + if (!isNaN(parseFloat(machinePropertyProvider.properties.value))) + { + return parseFloat(machinePropertyProvider.properties.value); + } + return 0; + } + width: settingsPage.columnWidth + suffix: " " + model.unit + to: 99999 + decimals: model.unit == "mm" ? 2 : 0 + + onEditingFinished: materialPropertyProvider.setPropertyValue("value", value) + } + + UM.ContainerPropertyProvider + { + id: materialPropertyProvider + containerId: base.containerId + watchedProperties: [ "value" ] + key: model.key + } + UM.ContainerPropertyProvider + { + id: variantPropertyProvider + containerId: Cura.MachineManager.activeStack.variant.id + watchedProperties: [ "value" ] + key: model.key + } + UM.ContainerPropertyProvider + { + id: machinePropertyProvider + containerId: Cura.MachineManager.activeMachine != null ? Cura.MachineManager.activeMachine.definition.id: "" + watchedProperties: ["value"] + key: model.key + } } } } From 10339555f4a817f918606fc350032d940d2cace5 Mon Sep 17 00:00:00 2001 From: casper Date: Mon, 21 Mar 2022 13:20:41 +0100 Subject: [PATCH 23/24] Simplify materials preference page by wrapping scroll items in ListView CURA-8979 --- .../Preferences/Materials/MaterialsView.qml | 156 +++++++++--------- 1 file changed, 75 insertions(+), 81 deletions(-) diff --git a/resources/qml/Preferences/Materials/MaterialsView.qml b/resources/qml/Preferences/Materials/MaterialsView.qml index 2a3d5dc7fb..23cba249ad 100644 --- a/resources/qml/Preferences/Materials/MaterialsView.qml +++ b/resources/qml/Preferences/Materials/MaterialsView.qml @@ -515,7 +515,7 @@ Item } } - ScrollView + ListView { id: settingsPage visible: pageSelectorTabRow.currentItem.activeView === "settings" @@ -530,7 +530,9 @@ Item rightMargin: UM.Theme.getSize("thin_margin").width } - ScrollBar.horizontal.policy: ScrollBar.AlwaysOff + width: settingsPage.width + spacing: UM.Theme.getSize("narrow_margin").height + ScrollBar.vertical: UM.ScrollBar { id: settingScrollBar @@ -545,91 +547,83 @@ Item property real columnWidth: Math.floor((width - settingScrollBar.width - UM.Theme.getSize("narrow_margin").width) / 2) - Column + model: UM.SettingDefinitionsModel { - width: settingsPage.width - spacing: UM.Theme.getSize("narrow_margin").height - Repeater + containerId: Cura.MachineManager.activeMachine != null ? Cura.MachineManager.activeMachine.definition.id: "" + visibilityHandler: Cura.MaterialSettingsVisibilityHandler { } + expanded: ["*"] + } + + delegate: UM.TooltipArea + { + width: childrenRect.width + height: childrenRect.height + + UM.TooltipArea { - model: UM.SettingDefinitionsModel + anchors.fill: parent + text: model.description + } + UM.Label + { + id: label + width: settingsPage.columnWidth + height: spinBox.height + UM.Theme.getSize("default_lining").height + text: model.label + elide: Text.ElideRight + verticalAlignment: Qt.AlignVCenter + } + Cura.SpinBox + { + id: spinBox + anchors.left: label.right + value: { - containerId: Cura.MachineManager.activeMachine != null ? Cura.MachineManager.activeMachine.definition.id: "" - visibilityHandler: Cura.MaterialSettingsVisibilityHandler { } - expanded: ["*"] + // In case the setting is not in the material... + if (!isNaN(parseFloat(materialPropertyProvider.properties.value))) + { + return parseFloat(materialPropertyProvider.properties.value); + } + // ... we search in the variant, and if it is not there... + if (!isNaN(parseFloat(variantPropertyProvider.properties.value))) + { + return parseFloat(variantPropertyProvider.properties.value); + } + // ... then look in the definition container. + if (!isNaN(parseFloat(machinePropertyProvider.properties.value))) + { + return parseFloat(machinePropertyProvider.properties.value); + } + return 0; } + width: settingsPage.columnWidth + suffix: " " + model.unit + to: 99999 + decimals: model.unit == "mm" ? 2 : 0 - delegate: UM.TooltipArea - { - width: childrenRect.width - height: childrenRect.height + onEditingFinished: materialPropertyProvider.setPropertyValue("value", value) + } - UM.TooltipArea - { - anchors.fill: parent - text: model.description - } - UM.Label - { - id: label - width: settingsPage.columnWidth - height: spinBox.height + UM.Theme.getSize("default_lining").height - text: model.label - elide: Text.ElideRight - verticalAlignment: Qt.AlignVCenter - } - Cura.SpinBox - { - id: spinBox - anchors.left: label.right - value: - { - // In case the setting is not in the material... - if (!isNaN(parseFloat(materialPropertyProvider.properties.value))) - { - return parseFloat(materialPropertyProvider.properties.value); - } - // ... we search in the variant, and if it is not there... - if (!isNaN(parseFloat(variantPropertyProvider.properties.value))) - { - return parseFloat(variantPropertyProvider.properties.value); - } - // ... then look in the definition container. - if (!isNaN(parseFloat(machinePropertyProvider.properties.value))) - { - return parseFloat(machinePropertyProvider.properties.value); - } - return 0; - } - width: settingsPage.columnWidth - suffix: " " + model.unit - to: 99999 - decimals: model.unit == "mm" ? 2 : 0 - - onEditingFinished: materialPropertyProvider.setPropertyValue("value", value) - } - - UM.ContainerPropertyProvider - { - id: materialPropertyProvider - containerId: base.containerId - watchedProperties: [ "value" ] - key: model.key - } - UM.ContainerPropertyProvider - { - id: variantPropertyProvider - containerId: Cura.MachineManager.activeStack.variant.id - watchedProperties: [ "value" ] - key: model.key - } - UM.ContainerPropertyProvider - { - id: machinePropertyProvider - containerId: Cura.MachineManager.activeMachine != null ? Cura.MachineManager.activeMachine.definition.id: "" - watchedProperties: ["value"] - key: model.key - } - } + UM.ContainerPropertyProvider + { + id: materialPropertyProvider + containerId: base.containerId + watchedProperties: [ "value" ] + key: model.key + } + UM.ContainerPropertyProvider + { + id: variantPropertyProvider + containerId: Cura.MachineManager.activeStack.variant.id + watchedProperties: [ "value" ] + key: model.key + } + UM.ContainerPropertyProvider + { + id: machinePropertyProvider + containerId: Cura.MachineManager.activeMachine != null ? Cura.MachineManager.activeMachine.definition.id: "" + watchedProperties: ["value"] + key: model.key } } } From adccc5fd19a9ff6165d1b432bcf9a3adab3e10ec Mon Sep 17 00:00:00 2001 From: casper Date: Mon, 21 Mar 2022 13:50:10 +0100 Subject: [PATCH 24/24] Use correct font and line height for the category btn in materials list CURA-8979 --- resources/qml/Preferences/Materials/MaterialsBrandSection.qml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/resources/qml/Preferences/Materials/MaterialsBrandSection.qml b/resources/qml/Preferences/Materials/MaterialsBrandSection.qml index 5ffce9b750..9f7eeccc54 100644 --- a/resources/qml/Preferences/Materials/MaterialsBrandSection.qml +++ b/resources/qml/Preferences/Materials/MaterialsBrandSection.qml @@ -24,7 +24,8 @@ Column { width: parent.width labelText: sectionName - labelFont: UM.Theme.getFont("medium_bold") + height: UM.Theme.getSize("preferences_page_list_item").height + labelFont: UM.Theme.getFont("default_bold") expanded: brand_section.expanded onClicked: {