From 11c23b4fe9108fd5739b56e70e76091c47f9644b Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Thu, 25 Jul 2019 16:54:47 +0200 Subject: [PATCH 01/55] Add first draft of the radiocheckbar CURA-6598 --- resources/qml/RadioCheckbar.qml | 127 ++++++++++++++++++++++++++++++++ 1 file changed, 127 insertions(+) create mode 100644 resources/qml/RadioCheckbar.qml diff --git a/resources/qml/RadioCheckbar.qml b/resources/qml/RadioCheckbar.qml new file mode 100644 index 0000000000..2d863f7a66 --- /dev/null +++ b/resources/qml/RadioCheckbar.qml @@ -0,0 +1,127 @@ +import QtQuick 2.0 +import QtQuick.Controls 2.3 +import QtQuick.Layouts 1.3 +Item +{ + id: base + property ButtonGroup buttonGroup: null + + property color activeColor: "#3282ff" + property color inactiveColor: "#cccccc" + property color defaultItemColor: "#0a0850" + property int checkboxSize: 14 + property int inactiveMarkerSize: 4 + property int barSize: 2 + + implicitWidth: 200 + implicitHeight: buttonBar.height + + property var model: null + + // The horizontal inactive bar that sits behind the buttons + Rectangle + { + id: inactiveLine + color: inactiveColor + anchors.verticalCenter: buttonBar.verticalCenter + height: barSize + width: buttonBar.width + } + + RowLayout + { + id: buttonBar + height: childrenRect.height + width: parent.width + spacing: 0 + Repeater + { + id: repeater + model: base.model + + Item + { + Layout.fillWidth: true + // The last item of the repeater needs to be shorter, as we don't need another part to fit + // the horizontal bar. The others should essentially not be limited. + Layout.maximumWidth: index + 1 === repeater.count ? activeComponent.width: 200000000 + height: activeComponent.height + + property bool isEnabled: model.enabled + // The horizontal bar between the checkable options. + // Note that the horizontal bar points towards the previous item. + Rectangle + { + property Item previousItem: repeater.itemAt(index - 1) + + height: barSize + width: parent.width - activeComponent.width + color: defaultItemColor + + anchors + { + right: activeComponent.left + verticalCenter: activeComponent.verticalCenter + } + visible: previousItem !== null && previousItem.isEnabled && isEnabled + } + Loader + { + id: activeComponent + sourceComponent: isEnabled? checkboxComponent : disabledComponent + } + } + } + } + + Component + { + id: disabledComponent + Item + { + height: checkboxSize + width: inactiveMarkerSize + Rectangle + { + anchors.centerIn: parent + height: parent.width + width: parent.width + radius: width / 2 + color: inactiveColor + } + } + } + + Component + { + id: checkboxComponent + CheckBox + { + id: checkbox + ButtonGroup.group: buttonGroup + width: checkboxSize + height: checkboxSize + indicator: Rectangle + { + height: checkbox.height + width: checkbox.width + radius: width / 2 + + anchors.centerIn: checkbox + border.color: defaultItemColor + + Rectangle + { + anchors + { + margins: 3 + fill: parent + } + radius: width / 2 + color: activeColor + visible: checkbox.checked + } + } + } + } +} From abc6e5950b6b4ca0dab413c30300c5a6091254be Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Thu, 25 Jul 2019 17:02:34 +0200 Subject: [PATCH 02/55] Fix alignment of inactiveMarker CURA-6598 --- resources/qml/RadioCheckbar.qml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/resources/qml/RadioCheckbar.qml b/resources/qml/RadioCheckbar.qml index 2d863f7a66..645b24e560 100644 --- a/resources/qml/RadioCheckbar.qml +++ b/resources/qml/RadioCheckbar.qml @@ -69,6 +69,8 @@ Item { id: activeComponent sourceComponent: isEnabled? checkboxComponent : disabledComponent + // Ensure the inactive markers that are not the first / last one align with the center of the checkboxes + x: isEnabled && index !== 0 && index + 1 !== repeater.count ? -(checkboxSize - inactiveMarkerSize) / 2: 0 } } } From cc4dc6a27c53cb780bc152c70074b4c7f5543d53 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Thu, 25 Jul 2019 17:05:31 +0200 Subject: [PATCH 03/55] Fix overlap if first option is radioButton CURA-6598 --- resources/qml/RadioCheckbar.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/qml/RadioCheckbar.qml b/resources/qml/RadioCheckbar.qml index 645b24e560..5210fed9e6 100644 --- a/resources/qml/RadioCheckbar.qml +++ b/resources/qml/RadioCheckbar.qml @@ -70,7 +70,7 @@ Item id: activeComponent sourceComponent: isEnabled? checkboxComponent : disabledComponent // Ensure the inactive markers that are not the first / last one align with the center of the checkboxes - x: isEnabled && index !== 0 && index + 1 !== repeater.count ? -(checkboxSize - inactiveMarkerSize) / 2: 0 + x: !isEnabled && index !== 0 && index + 1 !== repeater.count ? (checkboxSize - inactiveMarkerSize) / 2: 0 } } } From e47514d6dd8ffa978b7547e41160d559a986fd13 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Thu, 25 Jul 2019 17:37:35 +0200 Subject: [PATCH 04/55] Fix horizontal bar not coloring correct if last item is checkbox CURA-6598 --- resources/qml/RadioCheckbar.qml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/resources/qml/RadioCheckbar.qml b/resources/qml/RadioCheckbar.qml index 5210fed9e6..6a07d49b99 100644 --- a/resources/qml/RadioCheckbar.qml +++ b/resources/qml/RadioCheckbar.qml @@ -31,6 +31,7 @@ Item RowLayout { id: buttonBar + anchors.centerIn: parent height: childrenRect.height width: parent.width spacing: 0 @@ -46,7 +47,6 @@ Item // the horizontal bar. The others should essentially not be limited. Layout.maximumWidth: index + 1 === repeater.count ? activeComponent.width: 200000000 height: activeComponent.height - property bool isEnabled: model.enabled // The horizontal bar between the checkable options. // Note that the horizontal bar points towards the previous item. @@ -55,7 +55,7 @@ Item property Item previousItem: repeater.itemAt(index - 1) height: barSize - width: parent.width - activeComponent.width + width: buttonBar.width / (repeater.count - 1) - activeComponent.width - 2 color: defaultItemColor anchors @@ -63,7 +63,7 @@ Item right: activeComponent.left verticalCenter: activeComponent.verticalCenter } - visible: previousItem !== null && previousItem.isEnabled && isEnabled + visible: previousItem !== null && previousItem.isEnabled && isEnabled } Loader { From a66c074e972c51a96a378f777bb3e2e583f230e8 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Fri, 26 Jul 2019 10:43:47 +0200 Subject: [PATCH 05/55] Simplify the alignment code CURA-6598 --- resources/qml/RadioCheckbar.qml | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/resources/qml/RadioCheckbar.qml b/resources/qml/RadioCheckbar.qml index 6a07d49b99..a50cb4a9fe 100644 --- a/resources/qml/RadioCheckbar.qml +++ b/resources/qml/RadioCheckbar.qml @@ -25,7 +25,13 @@ Item color: inactiveColor anchors.verticalCenter: buttonBar.verticalCenter height: barSize - width: buttonBar.width + anchors + { + left: buttonBar.left + right: buttonBar.right + leftMargin: (checkboxSize - inactiveMarkerSize) / 2 + rightMargin: (checkboxSize - inactiveMarkerSize) / 2 + } } RowLayout @@ -69,8 +75,6 @@ Item { id: activeComponent sourceComponent: isEnabled? checkboxComponent : disabledComponent - // Ensure the inactive markers that are not the first / last one align with the center of the checkboxes - x: !isEnabled && index !== 0 && index + 1 !== repeater.count ? (checkboxSize - inactiveMarkerSize) / 2: 0 } } } @@ -82,12 +86,12 @@ Item Item { height: checkboxSize - width: inactiveMarkerSize + width: checkboxSize Rectangle { anchors.centerIn: parent - height: parent.width - width: parent.width + height: inactiveMarkerSize + width: inactiveMarkerSize radius: width / 2 color: inactiveColor } From a275e3de2b964434b700bf632d665180fab3600a Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Fri, 26 Jul 2019 11:39:03 +0200 Subject: [PATCH 06/55] Add LabelBar component CURA-6598 --- resources/qml/LabelBar.qml | 50 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 resources/qml/LabelBar.qml diff --git a/resources/qml/LabelBar.qml b/resources/qml/LabelBar.qml new file mode 100644 index 0000000000..f8f77e2017 --- /dev/null +++ b/resources/qml/LabelBar.qml @@ -0,0 +1,50 @@ +import QtQuick 2.0 +import QtQuick.Controls 2.1 +import QtQuick.Layouts 1.3 + +// The labelBar shows a set of labels that are evenly spaced from oneother. +// The first item is aligned to the left, the last is aligned to the right. +// It's intended to be used together with RadioCheckBar. As such, it needs +// to know what the used itemSize is, so it can ensure the labels are aligned correctly. +Item +{ + id: base + property var model: null + property int itemSize: 14 + RowLayout + { + anchors.fill: parent + spacing: 0 + Repeater + { + id: repeater + model: base.model + + Item + { + Layout.fillWidth: true + Layout.fillHeight: true + Layout.maximumWidth: index + 1 === repeater.count ? itemSize: 200000000 + + Label + { + id: label + text: model.text + + anchors + { + // Some magic to ensure that the items are aligned properly. + // We want the following: + // First item should be aligned to the left, no margin. + // Last item should be aligned to the right, no margin. + // The middle item(s) should be aligned to the center of the "item" it's showing (hence half the itemsize as offset). + // We want the center of the label to align with the center of the item, so we negatively offset by half the contentWidth + right: index + 1 === repeater.count ? parent.right: undefined + left: index + 1 === repeater.count || index === 0 ? undefined: parent.left + leftMargin: (0.5 * itemSize) - 0.5 * contentWidth + } + } + } + } + } +} From ae406e2480f2f0209b7a43d281232dd7f7555a59 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Mon, 29 Jul 2019 16:01:23 +0200 Subject: [PATCH 07/55] Fix the RadioCheckbar to work in Cura --- resources/qml/RadioCheckbar.qml | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/resources/qml/RadioCheckbar.qml b/resources/qml/RadioCheckbar.qml index a50cb4a9fe..8c47efa05b 100644 --- a/resources/qml/RadioCheckbar.qml +++ b/resources/qml/RadioCheckbar.qml @@ -14,7 +14,7 @@ Item property int barSize: 2 implicitWidth: 200 - implicitHeight: buttonBar.height + implicitHeight: checkboxSize property var model: null @@ -23,8 +23,12 @@ Item { id: inactiveLine color: inactiveColor - anchors.verticalCenter: buttonBar.verticalCenter + height: barSize + + // This can (and should) be done wiht a verticalCenter. For some reason it does work in QtCreator + // but not when using the exact same QML in Cura. + y: 0.5 * checkboxSize anchors { left: buttonBar.left @@ -37,15 +41,16 @@ Item RowLayout { id: buttonBar - anchors.centerIn: parent - height: childrenRect.height + anchors.top: parent.top + height: checkboxSize width: parent.width spacing: 0 + Repeater { id: repeater model: base.model - + height: checkboxSize Item { Layout.fillWidth: true @@ -53,7 +58,7 @@ Item // the horizontal bar. The others should essentially not be limited. Layout.maximumWidth: index + 1 === repeater.count ? activeComponent.width: 200000000 height: activeComponent.height - property bool isEnabled: model.enabled + property bool isEnabled: model.available // The horizontal bar between the checkable options. // Note that the horizontal bar points towards the previous item. Rectangle @@ -67,7 +72,6 @@ Item anchors { right: activeComponent.left - verticalCenter: activeComponent.verticalCenter } visible: previousItem !== null && previousItem.isEnabled && isEnabled } @@ -75,6 +79,10 @@ Item { id: activeComponent sourceComponent: isEnabled? checkboxComponent : disabledComponent + width: checkboxSize + // This can (and should) be done wiht a verticalCenter. For some reason it does work in QtCreator + // but not when using the exact same QML in Cura. + y: -0.5 * checkboxSize } } } @@ -87,9 +95,13 @@ Item { height: checkboxSize width: checkboxSize + Rectangle { - anchors.centerIn: parent + // This can (and should) be done wiht a verticalCenter. For some reason it does work in QtCreator + // but not when using the exact same QML in Cura. + y: 0.5 * checkboxSize - 1 + anchors.horizontalCenter: parent.horizontalCenter height: inactiveMarkerSize width: inactiveMarkerSize radius: width / 2 @@ -109,11 +121,10 @@ Item height: checkboxSize indicator: Rectangle { - height: checkbox.height - width: checkbox.width + height: checkboxSize + width: checkboxSize radius: width / 2 - anchors.centerIn: checkbox border.color: defaultItemColor Rectangle From 3b93a1914a7f40b4fd17f8c1bbd90f7caf76e1ab Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Mon, 29 Jul 2019 16:12:39 +0200 Subject: [PATCH 08/55] Ensure the Label bar uses the theme CURA-6598 --- resources/qml/LabelBar.qml | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/resources/qml/LabelBar.qml b/resources/qml/LabelBar.qml index f8f77e2017..ea29df0e06 100644 --- a/resources/qml/LabelBar.qml +++ b/resources/qml/LabelBar.qml @@ -1,7 +1,7 @@ import QtQuick 2.0 import QtQuick.Controls 2.1 import QtQuick.Layouts 1.3 - +import UM 1.2 as UM // The labelBar shows a set of labels that are evenly spaced from oneother. // The first item is aligned to the left, the last is aligned to the right. // It's intended to be used together with RadioCheckBar. As such, it needs @@ -10,10 +10,14 @@ Item { id: base property var model: null + property string modelKey: "" property int itemSize: 14 + height: childrenRect.height RowLayout { - anchors.fill: parent + anchors.left: parent.left + anchors.right: parent.right + height: childrenRect.height spacing: 0 Repeater { @@ -25,12 +29,14 @@ Item Layout.fillWidth: true Layout.fillHeight: true Layout.maximumWidth: index + 1 === repeater.count ? itemSize: 200000000 - + height: childrenRect.height Label { id: label - text: model.text - + text: model[modelKey] + color: UM.Theme.getColor("text") + font: UM.Theme.getFont("default") + height: contentHeight anchors { // Some magic to ensure that the items are aligned properly. From 6b90975391792773e01e1e11d3ff10607707e4e4 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Mon, 29 Jul 2019 16:53:42 +0200 Subject: [PATCH 09/55] Replace the old settingSlider with the RadioButtonbar CURA-6598 --- .../RecommendedQualityProfileSelector.qml | 379 ++---------------- resources/qml/RadioCheckbar.qml | 10 + 2 files changed, 33 insertions(+), 356 deletions(-) diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedQualityProfileSelector.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedQualityProfileSelector.qml index 0486f5d2d7..343be60e73 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedQualityProfileSelector.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedQualityProfileSelector.qml @@ -3,6 +3,7 @@ import QtQuick 2.7 import QtQuick.Controls 1.4 +import QtQuick.Controls 2.3 as Controls2 import QtQuick.Controls.Styles 1.4 import UM 1.2 as UM @@ -33,133 +34,6 @@ Item } } - Component.onCompleted: qualityModel.update() - - Connections - { - target: Cura.QualityProfilesDropDownMenuModel - onItemsChanged: qualityModel.update() - } - - Connections { - target: base - onVisibleChanged: - { - // update needs to be called when the widgets are visible, otherwise the step width calculation - // will fail because the width of an invisible item is 0. - if (visible) - { - qualityModel.update(); - } - } - } - - ListModel - { - id: qualityModel - - property var totalTicks: 0 - property var availableTotalTicks: 0 - property var existingQualityProfile: 0 - - property var qualitySliderActiveIndex: 0 - property var qualitySliderStepWidth: 0 - property var qualitySliderAvailableMin: 0 - property var qualitySliderAvailableMax: 0 - property var qualitySliderMarginRight: 0 - - function update () - { - reset() - - var availableMin = -1 - var availableMax = -1 - - for (var i = 0; i < Cura.QualityProfilesDropDownMenuModel.rowCount(); i++) - { - var qualityItem = Cura.QualityProfilesDropDownMenuModel.getItem(i) - - // Add each quality item to the UI quality model - qualityModel.append(qualityItem) - - // Set selected value - if (Cura.MachineManager.activeQualityType == qualityItem.quality_type) - { - // set to -1 when switching to user created profile so all ticks are clickable - if (Cura.MachineManager.hasCustomQuality) - { - qualityModel.qualitySliderActiveIndex = -1 - } - else - { - qualityModel.qualitySliderActiveIndex = i - } - - qualityModel.existingQualityProfile = 1 - } - - // Set min available - if (qualityItem.available && availableMin == -1) - { - availableMin = i - } - - // Set max available - if (qualityItem.available) - { - availableMax = i - } - } - - // Set total available ticks for active slider part - if (availableMin != -1) - { - qualityModel.availableTotalTicks = availableMax - availableMin + 1 - } - - // Calculate slider values - calculateSliderStepWidth(qualityModel.totalTicks) - calculateSliderMargins(availableMin, availableMax, qualityModel.totalTicks) - - qualityModel.qualitySliderAvailableMin = availableMin - qualityModel.qualitySliderAvailableMax = availableMax - } - - function calculateSliderStepWidth (totalTicks) - { - // Do not use Math.round otherwise the tickmarks won't be aligned - qualityModel.qualitySliderStepWidth = totalTicks != 0 ? - ((settingsColumnWidth - UM.Theme.getSize("print_setup_slider_handle").width) / (totalTicks)) : 0 - } - - function calculateSliderMargins (availableMin, availableMax, totalTicks) - { - if (availableMin == -1 || (availableMin == 0 && availableMax == 0)) - { - // Do not use Math.round otherwise the tickmarks won't be aligned - qualityModel.qualitySliderMarginRight = settingsColumnWidth / 2 - } - else if (availableMin == availableMax) - { - // Do not use Math.round otherwise the tickmarks won't be aligned - qualityModel.qualitySliderMarginRight = (totalTicks - availableMin) * qualitySliderStepWidth - } - else - { - // Do not use Math.round otherwise the tickmarks won't be aligned - qualityModel.qualitySliderMarginRight = (totalTicks - availableMax) * qualitySliderStepWidth - } - } - - function reset () { - qualityModel.clear() - qualityModel.availableTotalTicks = 0 - qualityModel.existingQualityProfile = 0 - - // check, the ticks count cannot be less than zero - qualityModel.totalTicks = Math.max(0, Cura.QualityProfilesDropDownMenuModel.rowCount() - 1) - } - } // Here are the elements that are shown in the left column Item @@ -210,246 +84,39 @@ Item } } - // Show titles for the each quality slider ticks Item { - anchors.left: speedSlider.left - anchors.top: speedSlider.bottom - height: childrenRect.height - - Repeater + anchors.left: titleRow.right + anchors.right: parent.right + Controls2.ButtonGroup { - model: qualityModel - - Label - { - anchors.verticalCenter: parent.verticalCenter - anchors.top: parent.top - // The height has to be set manually, otherwise it's not automatically calculated in the repeater - height: UM.Theme.getSize("default_margin").height - color: (Cura.MachineManager.activeMachine != null && Cura.QualityProfilesDropDownMenuModel.getItem(index).available) ? UM.Theme.getColor("quality_slider_available") : UM.Theme.getColor("quality_slider_unavailable") - text: - { - var result = "" - if(Cura.MachineManager.activeMachine != null) - { - result = Cura.QualityProfilesDropDownMenuModel.getItem(index).layer_height - - if(result == undefined) - { - result = ""; - } - else - { - result = Number(Math.round(result + "e+2") + "e-2"); //Round to 2 decimals. Javascript makes this difficult... - if (result == undefined || result != result) //Parse failure. - { - result = ""; - } - } - } - return result - } - - x: - { - // Make sure the text aligns correctly with each tick - if (qualityModel.totalTicks == 0) - { - // If there is only one tick, align it centrally - return Math.round(((settingsColumnWidth) - width) / 2) - } - else if (index == 0) - { - return Math.round(settingsColumnWidth / qualityModel.totalTicks) * index - } - else if (index == qualityModel.totalTicks) - { - return Math.round(settingsColumnWidth / qualityModel.totalTicks) * index - width - } - else - { - return Math.round((settingsColumnWidth / qualityModel.totalTicks) * index - (width / 2)) - } - } - font: UM.Theme.getFont("default") - } + id: activeProfileButtonGroup + exclusive: true + onClicked: Cura.MachineManager.activeQualityGroup = button.identifier } - } - - // Print speed slider - // Two sliders are created, one at the bottom with the unavailable qualities - // and the other at the top with the available quality profiles and so the handle to select them. - Item - { - id: speedSlider - height: childrenRect.height - - anchors + Cura.LabelBar { - left: titleRow.right - right: parent.right - verticalCenter: titleRow.verticalCenter + id: labelbar + anchors.left: parent.left + anchors.right: parent.right + model: Cura.QualityProfilesDropDownMenuModel + modelKey: "layer_height" } - - // Draw unavailable slider - Slider + Cura.RadioCheckbar { - id: unavailableSlider + anchors.left: parent.left + anchors.right: parent.right + anchors.top: labelbar.bottom + model: Cura.QualityProfilesDropDownMenuModel + buttonGroup: activeProfileButtonGroup + modelKey: "quality_group" - width: parent.width - height: qualitySlider.height // Same height as the slider that is on top - updateValueWhileDragging : false - tickmarksEnabled: true - - minimumValue: 0 - // maximumValue must be greater than minimumValue to be able to see the handle. While the value is strictly - // speaking not always correct, it seems to have the correct behavior (switching from 0 available to 1 available) - maximumValue: qualityModel.totalTicks - stepSize: 1 - - style: SliderStyle + function checkedFunction(modelItem) { - //Draw Unvailable line - groove: Item - { - Rectangle - { - height: UM.Theme.getSize("print_setup_slider_groove").height - width: control.width - UM.Theme.getSize("print_setup_slider_handle").width - anchors.horizontalCenter: parent.horizontalCenter - anchors.verticalCenter: parent.verticalCenter - color: UM.Theme.getColor("quality_slider_unavailable") - } - } - - handle: Item {} - - tickmarks: Repeater - { - id: qualityRepeater - model: qualityModel.totalTicks > 0 ? qualityModel : 0 - - Rectangle - { - color: Cura.QualityProfilesDropDownMenuModel.getItem(index).available ? UM.Theme.getColor("quality_slider_available") : UM.Theme.getColor("quality_slider_unavailable") - implicitWidth: UM.Theme.getSize("print_setup_slider_tickmarks").width - implicitHeight: UM.Theme.getSize("print_setup_slider_tickmarks").height - anchors.verticalCenter: parent.verticalCenter - - // Do not use Math.round otherwise the tickmarks won't be aligned - x: ((UM.Theme.getSize("print_setup_slider_handle").width / 2) - (implicitWidth / 2) + (qualityModel.qualitySliderStepWidth * index)) - radius: Math.round(implicitWidth / 2) - } - } + return Cura.MachineManager.activeQualityType == modelItem.quality_type } - // Create a mouse area on top of the unavailable profiles to show a specific tooltip - MouseArea - { - anchors.fill: parent - hoverEnabled: true - enabled: !Cura.MachineManager.hasCustomQuality - onEntered: - { - var tooltipContent = catalog.i18nc("@tooltip", "This quality profile is not available for your current material and nozzle configuration. Please change these to enable this quality profile.") - base.showTooltip(qualityRow, Qt.point(-UM.Theme.getSize("thick_margin").width, customisedSettings.height), tooltipContent) - } - onExited: base.hideTooltip() - } - } - - // Draw available slider - Slider - { - id: qualitySlider - - width: qualityModel.qualitySliderStepWidth * (qualityModel.availableTotalTicks - 1) + UM.Theme.getSize("print_setup_slider_handle").width - height: UM.Theme.getSize("print_setup_slider_handle").height // The handle is the widest element of the slider - enabled: qualityModel.totalTicks > 0 && !Cura.SimpleModeSettingsManager.isProfileCustomized - visible: qualityModel.availableTotalTicks > 0 - updateValueWhileDragging : false - - anchors - { - right: parent.right - rightMargin: qualityModel.qualitySliderMarginRight - } - - minimumValue: qualityModel.qualitySliderAvailableMin >= 0 ? qualityModel.qualitySliderAvailableMin : 0 - // maximumValue must be greater than minimumValue to be able to see the handle. While the value is strictly - // speaking not always correct, it seems to have the correct behavior (switching from 0 available to 1 available) - maximumValue: qualityModel.qualitySliderAvailableMax >= 1 ? qualityModel.qualitySliderAvailableMax : 1 - stepSize: 1 - - value: qualityModel.qualitySliderActiveIndex - - style: SliderStyle - { - // Draw Available line - groove: Item - { - Rectangle - { - height: UM.Theme.getSize("print_setup_slider_groove").height - width: control.width - UM.Theme.getSize("print_setup_slider_handle").width - anchors.verticalCenter: parent.verticalCenter - - // Do not use Math.round otherwise the tickmarks won't be aligned - x: UM.Theme.getSize("print_setup_slider_handle").width / 2 - color: UM.Theme.getColor("quality_slider_available") - } - } - - handle: Rectangle - { - id: qualityhandleButton - color: UM.Theme.getColor("primary") - implicitWidth: UM.Theme.getSize("print_setup_slider_handle").width - implicitHeight: implicitWidth - radius: Math.round(implicitWidth / 2) - visible: !Cura.SimpleModeSettingsManager.isProfileCustomized && !Cura.MachineManager.hasCustomQuality && qualityModel.existingQualityProfile - } - } - - onValueChanged: - { - // only change if an active machine is set and the slider is visible at all. - if (Cura.MachineManager.activeMachine != null && visible) - { - // prevent updating during view initializing. Trigger only if the value changed by user - if (qualitySlider.value != qualityModel.qualitySliderActiveIndex && qualityModel.qualitySliderActiveIndex != -1) - { - // start updating with short delay - qualitySliderChangeTimer.start() - } - } - } - - // This mouse area is only used to capture the onHover state and don't propagate it to the unavailable mouse area - MouseArea - { - anchors.fill: parent - hoverEnabled: true - acceptedButtons: Qt.NoButton - enabled: !Cura.MachineManager.hasCustomQuality - } - } - - // This mouse area will only take the mouse events and show a tooltip when the profile in use is - // a user created profile - MouseArea - { - anchors.fill: parent - hoverEnabled: true - visible: Cura.MachineManager.hasCustomQuality - - onEntered: - { - var tooltipContent = catalog.i18nc("@tooltip", "A custom profile is currently active. To enable the quality slider, choose a default quality profile in Custom tab") - base.showTooltip(qualityRow, Qt.point(-UM.Theme.getSize("thick_margin").width, customisedSettings.height), tooltipContent) - } - onExited: base.hideTooltip() + isCheckedFunction: checkedFunction } } } \ No newline at end of file diff --git a/resources/qml/RadioCheckbar.qml b/resources/qml/RadioCheckbar.qml index 8c47efa05b..3044fedb86 100644 --- a/resources/qml/RadioCheckbar.qml +++ b/resources/qml/RadioCheckbar.qml @@ -1,6 +1,7 @@ import QtQuick 2.0 import QtQuick.Controls 2.3 import QtQuick.Layouts 1.3 + Item { id: base @@ -12,12 +13,18 @@ Item property int checkboxSize: 14 property int inactiveMarkerSize: 4 property int barSize: 2 + property var isCheckedFunction // Function that accepts the modelItem and returns if the item should be active. implicitWidth: 200 implicitHeight: checkboxSize property var model: null + // What key of the model should be used to set the identifier of the checkbox. + // This is used to figure out what checkbox just got toggled. Set a buttonGroup and listen to it's clicked signal. + // You can use button.identifier to figure out which button was clicked. + property string modelKey: "name" + // The horizontal inactive bar that sits behind the buttons Rectangle { @@ -83,6 +90,7 @@ Item // This can (and should) be done wiht a verticalCenter. For some reason it does work in QtCreator // but not when using the exact same QML in Cura. y: -0.5 * checkboxSize + property var modelItem: model } } } @@ -119,6 +127,8 @@ Item ButtonGroup.group: buttonGroup width: checkboxSize height: checkboxSize + property var identifier: modelItem[base.modelKey] + checked: isCheckedFunction(modelItem) indicator: Rectangle { height: checkboxSize From 9e5082a42f5251e743028017b5dce015b50923c3 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Mon, 29 Jul 2019 17:00:02 +0200 Subject: [PATCH 10/55] Cleanup the qml a bit CURA-6598 --- .../RecommendedQualityProfileSelector.qml | 31 ++++++++++++++----- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedQualityProfileSelector.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedQualityProfileSelector.qml index 343be60e73..0666853726 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedQualityProfileSelector.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedQualityProfileSelector.qml @@ -84,29 +84,44 @@ Item } } - Item + Column { - anchors.left: titleRow.right - anchors.right: parent.right + anchors + { + left: titleRow.right + right: parent.right + } + + spacing: UM.Theme.getSize("default_margin").height + Controls2.ButtonGroup { id: activeProfileButtonGroup exclusive: true onClicked: Cura.MachineManager.activeQualityGroup = button.identifier } + Cura.LabelBar { id: labelbar - anchors.left: parent.left - anchors.right: parent.right + anchors + { + left: parent.left + right: parent.right + } + model: Cura.QualityProfilesDropDownMenuModel modelKey: "layer_height" } + Cura.RadioCheckbar { - anchors.left: parent.left - anchors.right: parent.right - anchors.top: labelbar.bottom + anchors + { + left: parent.left + right: parent.right + } + model: Cura.QualityProfilesDropDownMenuModel buttonGroup: activeProfileButtonGroup modelKey: "quality_group" From 8d53ee90b4e2741fd349d0a1ac57cb6418f638ba Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Mon, 29 Jul 2019 17:03:25 +0200 Subject: [PATCH 11/55] Ensure that profile bar has no options selected if a quality_changes is active CURA-6598 --- .../Recommended/RecommendedQualityProfileSelector.qml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedQualityProfileSelector.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedQualityProfileSelector.qml index 0666853726..7ad3493dca 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedQualityProfileSelector.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedQualityProfileSelector.qml @@ -128,6 +128,11 @@ Item function checkedFunction(modelItem) { + if(Cura.MachineManager.hasCustomQuality) + { + // When user created profile is active, no quality tickbox should be active. + return false + } return Cura.MachineManager.activeQualityType == modelItem.quality_type } From 24d6d5b102d1a31121035a6e248b13947f397937 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Tue, 30 Jul 2019 14:20:58 +0200 Subject: [PATCH 12/55] Update intent models to also house nested qualities CURA-6598 --- cura/Machines/Models/IntentCategoryModel.py | 15 ++++++- cura/Machines/Models/IntentModel.py | 50 ++++++++++++++++++--- 2 files changed, 56 insertions(+), 9 deletions(-) diff --git a/cura/Machines/Models/IntentCategoryModel.py b/cura/Machines/Models/IntentCategoryModel.py index 9a520a2d31..5211889801 100644 --- a/cura/Machines/Models/IntentCategoryModel.py +++ b/cura/Machines/Models/IntentCategoryModel.py @@ -5,9 +5,11 @@ from PyQt5.QtCore import Qt import collections from typing import TYPE_CHECKING +from cura.Machines.Models.IntentModel import IntentModel from cura.Settings.IntentManager import IntentManager from UM.Qt.ListModel import ListModel from UM.Settings.ContainerRegistry import ContainerRegistry #To update the list if anything changes. +from PyQt5.QtCore import pyqtProperty, pyqtSignal if TYPE_CHECKING: from UM.Settings.ContainerRegistry import ContainerInterface @@ -15,12 +17,14 @@ if TYPE_CHECKING: from UM.i18n import i18nCatalog catalog = i18nCatalog("cura") + ## Lists the intent categories that are available for the current printer # configuration. class IntentCategoryModel(ListModel): NameRole = Qt.UserRole + 1 IntentCategoryRole = Qt.UserRole + 2 WeightRole = Qt.UserRole + 3 + QualitiesRole = Qt.UserRole + 4 #Translations to user-visible string. Ordered by weight. #TODO: Create a solution for this name and weight to be used dynamically. @@ -29,6 +33,8 @@ class IntentCategoryModel(ListModel): name_translation["engineering"] = catalog.i18nc("@label", "Engineering") name_translation["smooth"] = catalog.i18nc("@label", "Smooth") + modelUpdated = pyqtSignal() + ## Creates a new model for a certain intent category. # \param The category to list the intent profiles for. def __init__(self, intent_category: str) -> None: @@ -38,6 +44,7 @@ class IntentCategoryModel(ListModel): self.addRoleName(self.NameRole, "name") self.addRoleName(self.IntentCategoryRole, "intent_category") self.addRoleName(self.WeightRole, "weight") + self.addRoleName(self.QualitiesRole, "qualities") ContainerRegistry.getInstance().containerAdded.connect(self._onContainerChange) ContainerRegistry.getInstance().containerRemoved.connect(self._onContainerChange) @@ -55,9 +62,13 @@ class IntentCategoryModel(ListModel): available_categories = IntentManager.getInstance().currentAvailableIntentCategories() result = [] for category in available_categories: + qualities = IntentModel() + qualities.setIntentCategory(category) result.append({ "name": self.name_translation.get(category, catalog.i18nc("@label", "Unknown")), "intent_category": category, - "weight": list(self.name_translation.keys()).index(category) + "weight": list(self.name_translation.keys()).index(category), + "qualities": qualities }) - self.setItems(result) \ No newline at end of file + result.sort(key = lambda k: k["weight"]) + self.setItems(result) diff --git a/cura/Machines/Models/IntentModel.py b/cura/Machines/Models/IntentModel.py index 5a44883b76..b310ec47a6 100644 --- a/cura/Machines/Models/IntentModel.py +++ b/cura/Machines/Models/IntentModel.py @@ -7,6 +7,7 @@ from PyQt5.QtCore import Qt, QObject, pyqtProperty, pyqtSignal from UM.Qt.ListModel import ListModel from UM.Settings.ContainerRegistry import ContainerRegistry +from UM.Settings.SettingFunction import SettingFunction from cura.Machines.ContainerTree import ContainerTree from cura.Settings.IntentManager import IntentManager @@ -16,18 +17,22 @@ import cura.CuraApplication class IntentModel(ListModel): NameRole = Qt.UserRole + 1 QualityTypeRole = Qt.UserRole + 2 + LayerHeightRole = Qt.UserRole + 3 + AvailableRole = Qt.UserRole + 4 def __init__(self, parent: Optional[QObject] = None) -> None: super().__init__(parent) self.addRoleName(self.NameRole, "name") self.addRoleName(self.QualityTypeRole, "quality_type") + self.addRoleName(self.LayerHeightRole, "layer_height") + self.addRoleName(self.AvailableRole, "available") self._intent_category = "engineering" ContainerRegistry.getInstance().containerAdded.connect(self._onChanged) ContainerRegistry.getInstance().containerRemoved.connect(self._onChanged) - + self._layer_height_unit = "" # This is cached self._update() intentCategoryChanged = pyqtSignal() @@ -54,11 +59,42 @@ class IntentModel(ListModel): return quality_groups = ContainerTree.getInstance().getCurrentQualityGroups() - for intent_category, quality_type in IntentManager.getInstance().getCurrentAvailableIntents(): - if intent_category == self._intent_category: - new_items.append({"name": quality_groups[quality_type].name, "quality_type": quality_type}) - if self._intent_category == "default": #For Default we always list all quality types. We can't filter on available profiles since the empty intent is not a specific quality type. - for quality_type in quality_groups.keys(): - new_items.append({"name": quality_groups[quality_type].name, "quality_type": quality_type}) + for quality_tuple, quality_group in quality_groups.items(): + new_items.append({"name": quality_group.name, + "quality_type": quality_tuple[1], + "layer_height": self._fetchLayerHeight(quality_group), + "available": True + }) + new_items = sorted(new_items, key=lambda x: x["layer_height"]) self.setItems(new_items) + + #TODO: Copied this from QualityProfilesDropdownMenuModel for the moment. This code duplication should be fixed. + def _fetchLayerHeight(self, quality_group) -> float: + global_stack = cura.CuraApplication.CuraApplication.getInstance().getMachineManager().activeMachine + if not self._layer_height_unit: + unit = global_stack.definition.getProperty("layer_height", "unit") + if not unit: + unit = "" + self._layer_height_unit = unit + + default_layer_height = global_stack.definition.getProperty("layer_height", "value") + + # Get layer_height from the quality profile for the GlobalStack + if quality_group.node_for_global is None: + return float(default_layer_height) + container = quality_group.node_for_global.getContainer() + + layer_height = default_layer_height + if container and container.hasProperty("layer_height", "value"): + layer_height = container.getProperty("layer_height", "value") + else: + # Look for layer_height in the GlobalStack from material -> definition + container = global_stack.definition + if container and container.hasProperty("layer_height", "value"): + layer_height = container.getProperty("layer_height", "value") + + if isinstance(layer_height, SettingFunction): + layer_height = layer_height(global_stack) + + return float(layer_height) From 5401a4db15f61ce72b0b5ed716ac4421d92e8519 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Tue, 30 Jul 2019 15:28:22 +0200 Subject: [PATCH 13/55] Ensure that each intent gets it's own bar in recommended CURA-6598 --- cura/Machines/Models/IntentModel.py | 31 ++++++++++++-- .../RecommendedQualityProfileSelector.qml | 42 ++++++++++--------- resources/qml/RadioCheckbar.qml | 21 ++++------ 3 files changed, 60 insertions(+), 34 deletions(-) diff --git a/cura/Machines/Models/IntentModel.py b/cura/Machines/Models/IntentModel.py index b310ec47a6..666786e26a 100644 --- a/cura/Machines/Models/IntentModel.py +++ b/cura/Machines/Models/IntentModel.py @@ -19,6 +19,7 @@ class IntentModel(ListModel): QualityTypeRole = Qt.UserRole + 2 LayerHeightRole = Qt.UserRole + 3 AvailableRole = Qt.UserRole + 4 + IntentRole = Qt.UserRole + 5 def __init__(self, parent: Optional[QObject] = None) -> None: super().__init__(parent) @@ -27,6 +28,7 @@ class IntentModel(ListModel): self.addRoleName(self.QualityTypeRole, "quality_type") self.addRoleName(self.LayerHeightRole, "layer_height") self.addRoleName(self.AvailableRole, "available") + self.addRoleName(self.IntentRole, "intent_category") self._intent_category = "engineering" @@ -59,12 +61,32 @@ class IntentModel(ListModel): return quality_groups = ContainerTree.getInstance().getCurrentQualityGroups() + layer_heights_added = [] for quality_tuple, quality_group in quality_groups.items(): - new_items.append({"name": quality_group.name, + # Add the intents that are of the correct category + if quality_tuple[0] == self._intent_category: + layer_height = self._fetchLayerHeight(quality_group) + new_items.append({"name": quality_group.name, "quality_type": quality_tuple[1], - "layer_height": self._fetchLayerHeight(quality_group), - "available": True + "layer_height": layer_height, + "available": quality_group.is_available, + "intent_category": self._intent_category }) + layer_heights_added.append(layer_height) + + # Now that we added all intents that we found something for, ensure that we set add ticks (and layer_heights) + # for all groups that we don't have anything for (and set it to not available) + for quality_tuple, quality_group in quality_groups.items(): + # Add the intents that are of the correct category + if quality_tuple[0] != self._intent_category: + layer_height = self._fetchLayerHeight(quality_group) + if layer_height not in layer_heights_added: + new_items.append({"name": "Unavailable", + "quality_type": "", + "layer_height": layer_height, + "intent_category": self._intent_category, + "available": False}) + layer_heights_added.append(layer_height) new_items = sorted(new_items, key=lambda x: x["layer_height"]) self.setItems(new_items) @@ -98,3 +120,6 @@ class IntentModel(ListModel): layer_height = layer_height(global_stack) return float(layer_height) + + def __repr__(self): + return str(self.items) diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedQualityProfileSelector.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedQualityProfileSelector.qml index 7ad3493dca..2c8843122d 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedQualityProfileSelector.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedQualityProfileSelector.qml @@ -7,7 +7,7 @@ import QtQuick.Controls 2.3 as Controls2 import QtQuick.Controls.Styles 1.4 import UM 1.2 as UM -import Cura 1.0 as Cura +import Cura 1.6 as Cura // @@ -98,7 +98,8 @@ Item { id: activeProfileButtonGroup exclusive: true - onClicked: Cura.MachineManager.activeQualityGroup = button.identifier + onClicked: Cura.IntentManager.selectIntent(button.modelData.intent_category, button.modelData.quality_type) + } Cura.LabelBar @@ -114,29 +115,32 @@ Item modelKey: "layer_height" } - Cura.RadioCheckbar + Repeater { - anchors + model: Cura.IntentCategoryModel{} + Cura.RadioCheckbar { - left: parent.left - right: parent.right - } - - model: Cura.QualityProfilesDropDownMenuModel - buttonGroup: activeProfileButtonGroup - modelKey: "quality_group" - - function checkedFunction(modelItem) - { - if(Cura.MachineManager.hasCustomQuality) + anchors { - // When user created profile is active, no quality tickbox should be active. - return false + left: parent.left + right: parent.right } - return Cura.MachineManager.activeQualityType == modelItem.quality_type + dataModel: model["qualities"] + buttonGroup: activeProfileButtonGroup + + function checkedFunction(modelItem) + { + if(Cura.MachineManager.hasCustomQuality) + { + // When user created profile is active, no quality tickbox should be active. + return false + } + return Cura.MachineManager.activeQualityType == modelItem.quality_type && Cura.MachineManager.activeIntentCategory == modelItem.intent_category + } + + isCheckedFunction: checkedFunction } - isCheckedFunction: checkedFunction } } } \ No newline at end of file diff --git a/resources/qml/RadioCheckbar.qml b/resources/qml/RadioCheckbar.qml index 3044fedb86..1bc1c135f6 100644 --- a/resources/qml/RadioCheckbar.qml +++ b/resources/qml/RadioCheckbar.qml @@ -18,12 +18,7 @@ Item implicitWidth: 200 implicitHeight: checkboxSize - property var model: null - - // What key of the model should be used to set the identifier of the checkbox. - // This is used to figure out what checkbox just got toggled. Set a buttonGroup and listen to it's clicked signal. - // You can use button.identifier to figure out which button was clicked. - property string modelKey: "name" + property var dataModel: null // The horizontal inactive bar that sits behind the buttons Rectangle @@ -45,6 +40,7 @@ Item } } + RowLayout { id: buttonBar @@ -56,7 +52,7 @@ Item Repeater { id: repeater - model: base.model + model: base.dataModel height: checkboxSize Item { @@ -75,7 +71,9 @@ Item height: barSize width: buttonBar.width / (repeater.count - 1) - activeComponent.width - 2 color: defaultItemColor - + // This can (and should) be done wiht a verticalCenter. For some reason it does work in QtCreator + // but not when using the exact same QML in Cura. + y: 0.5 * checkboxSize anchors { right: activeComponent.left @@ -87,9 +85,7 @@ Item id: activeComponent sourceComponent: isEnabled? checkboxComponent : disabledComponent width: checkboxSize - // This can (and should) be done wiht a verticalCenter. For some reason it does work in QtCreator - // but not when using the exact same QML in Cura. - y: -0.5 * checkboxSize + property var modelItem: model } } @@ -127,7 +123,8 @@ Item ButtonGroup.group: buttonGroup width: checkboxSize height: checkboxSize - property var identifier: modelItem[base.modelKey] + property var modelData: modelItem + checked: isCheckedFunction(modelItem) indicator: Rectangle { From a9e09c6f54272a325691e86271afd774553f067d Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Thu, 1 Aug 2019 14:22:33 +0200 Subject: [PATCH 14/55] Removed unused timer CURA-6598 --- .../RecommendedQualityProfileSelector.qml | 22 ++----------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedQualityProfileSelector.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedQualityProfileSelector.qml index 2c8843122d..c465a2e2be 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedQualityProfileSelector.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedQualityProfileSelector.qml @@ -9,10 +9,6 @@ import QtQuick.Controls.Styles 1.4 import UM 1.2 as UM import Cura 1.6 as Cura - -// -// Quality profile -// Item { id: qualityRow @@ -21,20 +17,6 @@ Item property real labelColumnWidth: Math.round(width / 3) property real settingsColumnWidth: width - labelColumnWidth - Timer - { - id: qualitySliderChangeTimer - interval: 50 - running: false - repeat: false - onTriggered: - { - var item = Cura.QualityProfilesDropDownMenuModel.getItem(qualitySlider.value); - Cura.MachineManager.activeQualityGroup = item.quality_group; - } - } - - // Here are the elements that are shown in the left column Item { @@ -46,7 +28,7 @@ Item { id: qualityRowTitle source: UM.Theme.getIcon("category_layer_height") - text: catalog.i18nc("@label", "Layer Height") + text: catalog.i18nc("@label", "Profiles") font: UM.Theme.getFont("medium") anchors.left: parent.left anchors.right: customisedSettings.left @@ -72,7 +54,7 @@ Item onClicked: { - // if the current profile is user-created, switch to a built-in quality + // If the current profile is user-created, switch to a built-in quality Cura.MachineManager.resetToUseDefaultQuality() } onEntered: From 94c2211e7fcf5d5d123bd92b2d6e5621a9d49053 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Thu, 1 Aug 2019 14:30:30 +0200 Subject: [PATCH 15/55] Further simplify the recommended print setup CURA-6598 --- .../Recommended/RecommendedPrintSetup.qml | 1 - .../RecommendedQualityProfileSelector.qml | 31 ------------------- 2 files changed, 32 deletions(-) diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedPrintSetup.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedPrintSetup.qml index 6885f8c041..d9364681d2 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedPrintSetup.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedPrintSetup.qml @@ -27,7 +27,6 @@ Item Column { - width: parent.width - 2 * parent.padding spacing: UM.Theme.getSize("wide_margin").height anchors diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedQualityProfileSelector.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedQualityProfileSelector.qml index c465a2e2be..4b9d158483 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedQualityProfileSelector.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedQualityProfileSelector.qml @@ -33,37 +33,6 @@ Item anchors.left: parent.left anchors.right: customisedSettings.left } - - UM.SimpleButton - { - id: customisedSettings - - visible: Cura.SimpleModeSettingsManager.isProfileCustomized || Cura.MachineManager.hasCustomQuality - height: visible ? UM.Theme.getSize("print_setup_icon").height : 0 - width: height - anchors - { - right: parent.right - rightMargin: UM.Theme.getSize("default_margin").width - leftMargin: UM.Theme.getSize("default_margin").width - verticalCenter: parent.verticalCenter - } - - color: hovered ? UM.Theme.getColor("setting_control_button_hover") : UM.Theme.getColor("setting_control_button") - iconSource: UM.Theme.getIcon("reset") - - onClicked: - { - // If the current profile is user-created, switch to a built-in quality - Cura.MachineManager.resetToUseDefaultQuality() - } - onEntered: - { - var tooltipContent = catalog.i18nc("@tooltip","You have modified some profile settings. If you want to change these go to custom mode.") - base.showTooltip(qualityRow, Qt.point(-UM.Theme.getSize("thick_margin").width, 0), tooltipContent) - } - onExited: base.hideTooltip() - } } Column From c51dfec29fd3a6c3ca828a5b3a8ed298a548f4d1 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Thu, 1 Aug 2019 14:50:33 +0200 Subject: [PATCH 16/55] Ensure that the intent category names are displayed coorectly in recommended CURA-6598 --- .../RecommendedQualityProfileSelector.qml | 92 ++++++++++++------- 1 file changed, 59 insertions(+), 33 deletions(-) diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedQualityProfileSelector.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedQualityProfileSelector.qml index 4b9d158483..ad26ac7ef4 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedQualityProfileSelector.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedQualityProfileSelector.qml @@ -18,28 +18,12 @@ Item property real settingsColumnWidth: width - labelColumnWidth // Here are the elements that are shown in the left column - Item - { - id: titleRow - width: labelColumnWidth - height: childrenRect.height - - Cura.IconWithText - { - id: qualityRowTitle - source: UM.Theme.getIcon("category_layer_height") - text: catalog.i18nc("@label", "Profiles") - font: UM.Theme.getFont("medium") - anchors.left: parent.left - anchors.right: customisedSettings.left - } - } Column { anchors { - left: titleRow.right + left: parent.left right: parent.right } @@ -53,43 +37,85 @@ Item } - Cura.LabelBar + Item { - id: labelbar + height: childrenRect.height anchors { left: parent.left right: parent.right } + Cura.IconWithText + { + id: profileLabel + source: UM.Theme.getIcon("category_layer_height") + text: catalog.i18nc("@label", "Profiles") + font: UM.Theme.getFont("medium") + width: labelColumnWidth + } - model: Cura.QualityProfilesDropDownMenuModel - modelKey: "layer_height" + Cura.LabelBar + { + id: labelbar + anchors + { + left: profileLabel.right + right: parent.right + } + + model: Cura.QualityProfilesDropDownMenuModel + modelKey: "layer_height" + } } + Repeater { - model: Cura.IntentCategoryModel{} - Cura.RadioCheckbar + model: Cura.IntentCategoryModel {} + Item { anchors { left: parent.left right: parent.right } - dataModel: model["qualities"] - buttonGroup: activeProfileButtonGroup + height: childrenRect.height - function checkedFunction(modelItem) + Label { - if(Cura.MachineManager.hasCustomQuality) - { - // When user created profile is active, no quality tickbox should be active. - return false - } - return Cura.MachineManager.activeQualityType == modelItem.quality_type && Cura.MachineManager.activeIntentCategory == modelItem.intent_category + id: intentCategoryLabel + text: model.name + width: labelColumnWidth - UM.Theme.getSize("section_icon").width + anchors.left: parent.left + anchors.leftMargin: UM.Theme.getSize("section_icon").width + UM.Theme.getSize("narrow_margin").width + font: UM.Theme.getFont("medium") + color: UM.Theme.getColor("text") + renderType: Text.NativeRendering + elide: Text.ElideRight } - isCheckedFunction: checkedFunction + Cura.RadioCheckbar + { + anchors + { + left: intentCategoryLabel.right + right: parent.right + } + dataModel: model["qualities"] + buttonGroup: activeProfileButtonGroup + + function checkedFunction(modelItem) + { + if(Cura.MachineManager.hasCustomQuality) + { + // When user created profile is active, no quality tickbox should be active. + return false + } + return Cura.MachineManager.activeQualityType == modelItem.quality_type && Cura.MachineManager.activeIntentCategory == modelItem.intent_category + } + + isCheckedFunction: checkedFunction + } } } From 7d65951f437f3e532eea573b59b2b7a5d37cd5c1 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Mon, 5 Aug 2019 16:25:38 +0200 Subject: [PATCH 17/55] Refactor ComboBox to use states CURA-6598 --- resources/qml/Widgets/ComboBox.qml | 53 ++++++++++++++---------------- 1 file changed, 24 insertions(+), 29 deletions(-) diff --git a/resources/qml/Widgets/ComboBox.qml b/resources/qml/Widgets/ComboBox.qml index d1edcca69c..5a1ff16b95 100644 --- a/resources/qml/Widgets/ComboBox.qml +++ b/resources/qml/Widgets/ComboBox.qml @@ -14,40 +14,34 @@ import Cura 1.1 as Cura ComboBox { id: control - property bool highlighted: False + + states: [ + State + { + name: "disabled" + when: !control.enabled + PropertyChanges { target: backgroundRectangle.border; color: UM.Theme.getColor("setting_control_disabled_border")} + PropertyChanges { target: backgroundRectangle; color: UM.Theme.getColor("setting_control_disabled")} + PropertyChanges { target: contentLabel; color: UM.Theme.getColor("setting_control_disabled_text")} + }, + State + { + name: "highlighted" + when: control.hovered || control.activeFocus + PropertyChanges { target: backgroundRectangle.border; color: UM.Theme.getColor("setting_control_border_highlight") } + PropertyChanges { target: backgroundRectangle; color: UM.Theme.getColor("setting_control_highlight")} + } + ] + background: Rectangle { - color: - { - if (!enabled) - { - return UM.Theme.getColor("setting_control_disabled") - } - - if (control.hovered || control.activeFocus || control.highlighted) - { - return UM.Theme.getColor("setting_control_highlight") - } - - return UM.Theme.getColor("setting_control") - } + id: backgroundRectangle + color: UM.Theme.getColor("setting_control") radius: UM.Theme.getSize("setting_control_radius").width border.width: UM.Theme.getSize("default_lining").width - border.color: - { - if (!enabled) - { - return UM.Theme.getColor("setting_control_disabled_border") - } + border.color: UM.Theme.getColor("setting_control_border") - if (control.hovered || control.activeFocus || control.highlighted) - { - return UM.Theme.getColor("setting_control_border_highlight") - } - - return UM.Theme.getColor("setting_control_border") - } } indicator: UM.RecolorImage @@ -67,6 +61,7 @@ ComboBox contentItem: Label { + id: contentLabel anchors.left: parent.left anchors.leftMargin: UM.Theme.getSize("setting_unit_margin").width anchors.verticalCenter: parent.verticalCenter @@ -76,7 +71,7 @@ ComboBox textFormat: Text.PlainText renderType: Text.NativeRendering font: UM.Theme.getFont("default") - color: !enabled ? UM.Theme.getColor("setting_control_disabled_text") : UM.Theme.getColor("setting_control_text") + color: UM.Theme.getColor("setting_control_text") elide: Text.ElideRight verticalAlignment: Text.AlignVCenter } From 92be2611783a8d391e216711e6b0c3892da1bd24 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Tue, 6 Aug 2019 10:49:42 +0200 Subject: [PATCH 18/55] Update the profile selector to new style for the intents CURA-6598 --- .../Custom/CustomPrintSetup.qml | 107 ++++++-- .../Custom/QualitiesWithIntentMenu.qml | 242 ++++++++++++++++++ .../RecommendedQualityProfileSelector.qml | 1 - 3 files changed, 326 insertions(+), 24 deletions(-) create mode 100644 resources/qml/PrintSetupSelector/Custom/QualitiesWithIntentMenu.qml diff --git a/resources/qml/PrintSetupSelector/Custom/CustomPrintSetup.qml b/resources/qml/PrintSetupSelector/Custom/CustomPrintSetup.qml index e6a35455f2..1af3444e67 100644 --- a/resources/qml/PrintSetupSelector/Custom/CustomPrintSetup.qml +++ b/resources/qml/PrintSetupSelector/Custom/CustomPrintSetup.qml @@ -6,7 +6,7 @@ import QtQuick.Controls 2.0 import QtQuick.Controls 1.1 as OldControls import UM 1.3 as UM -import Cura 1.0 as Cura +import Cura 1.6 as Cura Item @@ -18,18 +18,6 @@ Item property var extrudersModel: CuraApplication.getExtrudersModel() - // Profile selector row - GlobalProfileSelector - { - id: globalProfileRow - anchors - { - top: parent.top - left: parent.left - right: parent.right - margins: parent.padding - } - } Item { id: intent @@ -37,7 +25,7 @@ Item anchors { - top: globalProfileRow.bottom + top: parent.top topMargin: UM.Theme.getSize("default_margin").height left: parent.left leftMargin: parent.padding @@ -60,20 +48,93 @@ Item color: UM.Theme.getColor("text") verticalAlignment: Text.AlignVCenter } - OldControls.ToolButton + + Button { id: intentSelection - text: Cura.MachineManager.activeStack != null ? Cura.MachineManager.activeStack.intent.name : "" - tooltip: text - height: UM.Theme.getSize("print_setup_big_item").height - width: UM.Theme.getSize("print_setup_big_item").width - anchors.right: parent.right - style: UM.Theme.styles.print_setup_header_button - activeFocusOnPress: true + onClicked: menu.opened ? menu.close() : menu.open() + text: generateActiveQualityText() - menu: Cura.IntentMenu { extruderIndex: Cura.ExtruderManager.activeExtruderIndex } + anchors.right: parent.right + width: UM.Theme.getSize("print_setup_big_item").width + height: textLabel.contentHeight + 2 * UM.Theme.getSize("narrow_margin").height + + contentItem: Label + { + id: textLabel + text: intentSelection.text + anchors.left: parent.left + anchors.leftMargin: UM.Theme.getSize("default_margin").width + anchors.verticalCenter: intentSelection.verticalCenter + height: contentHeight + verticalAlignment: Text.AlignVCenter + } + + background: Rectangle + { + border.color: UM.Theme.getColor("lining") + border.width: UM.Theme.getSize("default_lining").width + radius: UM.Theme.getSize("default_radius").width + } + + function generateActiveQualityText() + { + var result = Cura.MachineManager.activeQualityOrQualityChangesName + if (Cura.MachineManager.isActiveQualityExperimental) + { + result += " (Experimental)" + } + + if (Cura.MachineManager.isActiveQualitySupported) + { + if (Cura.MachineManager.activeQualityLayerHeight > 0) + { + result += " " + result += " - " + result += Cura.MachineManager.activeQualityLayerHeight + "mm" + result += "" + } + } + + return result + } + + UM.SimpleButton + { + id: customisedSettings + + visible: Cura.MachineManager.hasUserSettings + width: UM.Theme.getSize("print_setup_icon").width + height: UM.Theme.getSize("print_setup_icon").height + + anchors.verticalCenter: parent.verticalCenter + anchors.right: parent.right + anchors.rightMargin: UM.Theme.getSize("thick_margin").width + + color: hovered ? UM.Theme.getColor("setting_control_button_hover") : UM.Theme.getColor("setting_control_button"); + iconSource: UM.Theme.getIcon("star") + + onClicked: + { + forceActiveFocus(); + Cura.Actions.manageProfiles.trigger() + } + onEntered: + { + var content = catalog.i18nc("@tooltip", "Some setting/override values are different from the values stored in the profile.\n\nClick to open the profile manager.") + base.showTooltip(intent, Qt.point(-UM.Theme.getSize("default_margin").width, 0), content) + } + onExited: base.hideTooltip() + } } + QualitiesWithIntentMenu + { + id: menu + y: intentSelection.y + intentSelection.height + x: intentSelection.x + width: intentSelection.width + } } UM.TabRow diff --git a/resources/qml/PrintSetupSelector/Custom/QualitiesWithIntentMenu.qml b/resources/qml/PrintSetupSelector/Custom/QualitiesWithIntentMenu.qml new file mode 100644 index 0000000000..1ba73bb029 --- /dev/null +++ b/resources/qml/PrintSetupSelector/Custom/QualitiesWithIntentMenu.qml @@ -0,0 +1,242 @@ +import QtQuick 2.0 +import QtQuick.Controls 2.3 +import Cura 1.6 as Cura + +import UM 1.2 as UM +Popup +{ + id: popup + implicitWidth: 400 + property var dataModel: Cura.IntentCategoryModel {} + + property int defaultMargin: 5 + property int checkmarkSize: 12 + property int buttonHeight: 25 + property color backgroundColor: "#f2f2f2" + property color borderColor: "#cccccc" + padding: 0 + + background: Rectangle + { + color: backgroundColor + border.width: 1 + border.color: borderColor + } + + ButtonGroup + { + id: buttonGroup + exclusive: true + onClicked: popup.visible = false + } + + contentItem: Column + { + anchors.left: parent.left + anchors.right: parent.right + anchors.top: parent.top + + height: childrenRect.height + + // This repeater adds the intent labels + Repeater + { + model: dataModel + delegate: Item + { + // We need to set it like that, otherwise we'd have to set the sub model with model: model.qualities + // Which obviously won't work due to naming conflicts. + property variant subItemModel: model.qualities + + height: childrenRect.height + anchors + { + left: parent.left + leftMargin: defaultMargin + right: parent.right + rightMargin: defaultMargin + } + + Label + { + id: headerLabel + text: model.name + height: visible ? contentHeight: 0 + enabled: false + visible: qualitiesList.visibleChildren.length > 0 + } + + Column + { + id: qualitiesList + anchors.top: headerLabel.bottom + anchors.left: parent.left + anchors.right: parent.right + + // We set it by means of a binding, since then we can use the when condition, which we need to + // prevent a binding loop. + Binding + { + target: parent + property: "height" + value: parent.childrenRect.height + when: parent.visibleChildren.lengt > 0 + } + + // Add the qualities that belong to the intent + Repeater + { + visible: false + model: subItemModel + Button + { + id: button + + onClicked: Cura.IntentManager.selectIntent(model.intent_category, model.quality_type) + + width: parent.width + height: buttonHeight + checkable: true + visible: model.available + checked: + { + if(Cura.MachineManager.hasCustomQuality) + { + // When user created profile is active, no quality tickbox should be active. + return false + } + return Cura.MachineManager.activeQualityType == model.quality_type && Cura.MachineManager.activeIntentCategory == model.intent_category + } + ButtonGroup.group: buttonGroup + background: Item {} + contentItem: Item + { + Rectangle + { + id: checkmark + width: checkmarkSize + height: checkmarkSize + anchors.verticalCenter: parent.verticalCenter + color: "black" + visible: button.checked + } + + Label + { + id: label + text: model.name + " - " + model.layer_height + " mm" + verticalAlignment: Text.AlignVCenter + anchors + { + left: checkmark.right + leftMargin: defaultMargin + top: parent.top + bottom: parent.bottom + right: parent.right + } + } + } + } + } + } + } + } + + Rectangle + { + height: 1 + anchors.left: parent.left + anchors.right: parent.right + color: borderColor + } + Button + { + text: Cura.Actions.addProfile.text + + anchors.left: parent.left + anchors.leftMargin: defaultMargin + + enabled: Cura.Actions.addProfile.enabled + background: Item {} + onClicked: + { + Cura.Actions.addProfile.trigger() + popup.visible = false + } + + } + Button + { + text: Cura.Actions.updateProfile.text + + anchors.left: parent.left + anchors.leftMargin: defaultMargin + + enabled: Cura.Actions.updateProfile.enabled + background: Item {} + onClicked: + { + popup.visible = false + Cura.Actions.updateProfile.trigger() + } + } + Button + { + text: catalog.i18nc("@action:button", "Discard current changes") + + anchors.left: parent.left + anchors.leftMargin: defaultMargin + + enabled: Cura.MachineManager.hasUserSettings + background: Item {} + onClicked: + { + popup.visible = false + Cura.ContainerManager.clearUserContainers() + } + } + Rectangle + { + height: 1 + anchors.left: parent.left + anchors.right: parent.right + color: borderColor + } + Button + { + id: manageProfilesButton + text: Cura.Actions.manageProfiles.text + anchors + { + left: parent.left + leftMargin: defaultMargin + right: parent.right + rightMargin: defaultMargin + } + + height: textLabel.contentHeight + 2 * UM.Theme.getSize("narrow_margin").height + background: Item {} + contentItem: Item + { + width: manageProfilesButton.width + Label + { + id: textLabel + text: manageProfilesButton.text + height: contentHeight + } + Label + { + id: shortcutLabel + text: Cura.Actions.manageProfiles.shortcut + anchors.right: parent.right + } + } + onClicked: + { + popup.visible = false + Cura.Actions.manageProfiles.trigger() + } + } + } +} diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedQualityProfileSelector.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedQualityProfileSelector.qml index ad26ac7ef4..9194f3c85c 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedQualityProfileSelector.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedQualityProfileSelector.qml @@ -34,7 +34,6 @@ Item id: activeProfileButtonGroup exclusive: true onClicked: Cura.IntentManager.selectIntent(button.modelData.intent_category, button.modelData.quality_type) - } Item From 6751dc4fc850c4d5d518e10a5c97b9af271d55f8 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Tue, 6 Aug 2019 12:41:37 +0200 Subject: [PATCH 19/55] Remove unused QML component CURA-6598 --- .../Custom/GlobalProfileSelector.qml | 100 ------------------ 1 file changed, 100 deletions(-) delete mode 100644 resources/qml/PrintSetupSelector/Custom/GlobalProfileSelector.qml diff --git a/resources/qml/PrintSetupSelector/Custom/GlobalProfileSelector.qml b/resources/qml/PrintSetupSelector/Custom/GlobalProfileSelector.qml deleted file mode 100644 index 32c07a52a6..0000000000 --- a/resources/qml/PrintSetupSelector/Custom/GlobalProfileSelector.qml +++ /dev/null @@ -1,100 +0,0 @@ -// Copyright (c) 2018 Ultimaker B.V. -// Cura is released under the terms of the LGPLv3 or higher. - -import QtQuick 2.7 -import QtQuick.Controls 1.1 -import QtQuick.Controls.Styles 1.1 -import QtQuick.Layouts 1.2 - -import UM 1.2 as UM -import Cura 1.0 as Cura - -Item -{ - id: globalProfileRow - height: childrenRect.height - - Label - { - id: globalProfileLabel - anchors - { - top: parent.top - bottom: parent.bottom - left: parent.left - right: globalProfileSelection.left - } - text: catalog.i18nc("@label", "Profile") - font: UM.Theme.getFont("medium") - color: UM.Theme.getColor("text") - verticalAlignment: Text.AlignVCenter - } - - ToolButton - { - id: globalProfileSelection - - text: generateActiveQualityText() - width: UM.Theme.getSize("print_setup_big_item").width - height: UM.Theme.getSize("print_setup_big_item").height - anchors - { - top: parent.top - right: parent.right - } - tooltip: Cura.MachineManager.activeQualityOrQualityChangesName - style: UM.Theme.styles.print_setup_header_button - activeFocusOnPress: true - menu: Cura.ProfileMenu { } - - function generateActiveQualityText() - { - var result = Cura.MachineManager.activeQualityOrQualityChangesName - if (Cura.MachineManager.isActiveQualityExperimental) - { - result += " (Experimental)" - } - - if (Cura.MachineManager.isActiveQualitySupported) - { - if (Cura.MachineManager.activeQualityLayerHeight > 0) - { - result += " " - result += " - " - result += Cura.MachineManager.activeQualityLayerHeight + "mm" - result += "" - } - } - - return result - } - - UM.SimpleButton - { - id: customisedSettings - - visible: Cura.MachineManager.hasUserSettings - width: UM.Theme.getSize("print_setup_icon").width - height: UM.Theme.getSize("print_setup_icon").height - - anchors.verticalCenter: parent.verticalCenter - anchors.right: parent.right - anchors.rightMargin: Math.round(UM.Theme.getSize("setting_preferences_button_margin").width - UM.Theme.getSize("thick_margin").width) - - color: hovered ? UM.Theme.getColor("setting_control_button_hover") : UM.Theme.getColor("setting_control_button"); - iconSource: UM.Theme.getIcon("star") - - onClicked: - { - forceActiveFocus(); - Cura.Actions.manageProfiles.trigger() - } - onEntered: - { - var content = catalog.i18nc("@tooltip","Some setting/override values are different from the values stored in the profile.\n\nClick to open the profile manager.") - base.showTooltip(globalProfileRow, Qt.point(-UM.Theme.getSize("default_margin").width, 0), content) - } - onExited: base.hideTooltip() - } - } -} \ No newline at end of file From 5acc3111e00d152609fdd0101cf7b761f8261bcb Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Tue, 6 Aug 2019 12:58:53 +0200 Subject: [PATCH 20/55] Some minor UI fixes CURA-6598 --- resources/qml/PrintSetupSelector/Custom/CustomPrintSetup.qml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/resources/qml/PrintSetupSelector/Custom/CustomPrintSetup.qml b/resources/qml/PrintSetupSelector/Custom/CustomPrintSetup.qml index 1af3444e67..4c3e2d395b 100644 --- a/resources/qml/PrintSetupSelector/Custom/CustomPrintSetup.qml +++ b/resources/qml/PrintSetupSelector/Custom/CustomPrintSetup.qml @@ -35,7 +35,7 @@ Item Label { - id: intentLabel + id: profileLabel anchors { top: parent.top @@ -43,7 +43,7 @@ Item left: parent.left right: intentSelection.left } - text: catalog.i18nc("@label", "Intent") + text: catalog.i18nc("@label", "Profile") font: UM.Theme.getFont("medium") color: UM.Theme.getColor("text") verticalAlignment: Text.AlignVCenter @@ -75,6 +75,7 @@ Item border.color: UM.Theme.getColor("lining") border.width: UM.Theme.getSize("default_lining").width radius: UM.Theme.getSize("default_radius").width + color: UM.Theme.getColor("main_background") } function generateActiveQualityText() From 87fedc26207ab9e1f20637a0e051523c825d210b Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Tue, 6 Aug 2019 13:08:55 +0200 Subject: [PATCH 21/55] Fix elide for the variant in configuration menu --- resources/qml/Menus/ConfigurationMenu/ConfigurationMenu.qml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/resources/qml/Menus/ConfigurationMenu/ConfigurationMenu.qml b/resources/qml/Menus/ConfigurationMenu/ConfigurationMenu.qml index 77164429b3..fb074e948c 100644 --- a/resources/qml/Menus/ConfigurationMenu/ConfigurationMenu.qml +++ b/resources/qml/Menus/ConfigurationMenu/ConfigurationMenu.qml @@ -99,12 +99,14 @@ Cura.ExpandablePopup left: extruderIcon.right leftMargin: UM.Theme.getSize("default_margin").width top: typeAndBrandNameLabel.bottom + right: parent.right + rightMargin: UM.Theme.getSize("default_margin").width } } } } - //Placeholder text if there is a configuration to select but no materials (so we can't show the materials per extruder). + // Placeholder text if there is a configuration to select but no materials (so we can't show the materials per extruder). Label { text: catalog.i18nc("@label", "Select configuration") From 8445ebe8cfaf0ad3fd46e36047514b88b32eb94e Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Tue, 6 Aug 2019 13:13:54 +0200 Subject: [PATCH 22/55] Remove menu that is no longer used CURA-6598 --- resources/qml/Menus/IntentMenu.qml | 64 ------------------------------ 1 file changed, 64 deletions(-) delete mode 100644 resources/qml/Menus/IntentMenu.qml diff --git a/resources/qml/Menus/IntentMenu.qml b/resources/qml/Menus/IntentMenu.qml deleted file mode 100644 index 8aba7cbde6..0000000000 --- a/resources/qml/Menus/IntentMenu.qml +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright (c) 2019 Ultimaker B.V. -// Cura is released under the terms of the LGPLv3 or higher. - -import QtQuick 2.7 -import QtQuick.Controls 1.4 - -import UM 1.2 as UM -import Cura 1.6 as Cura - -Menu -{ - id: menu - title: "Intent" - - property int extruderIndex: 0 - - Cura.IntentCategoryModel - { - id: intentCategoryModel - } - - Instantiator - { - model: intentCategoryModel - - MenuItem //Section header. - { - text: model.name - enabled: false - checked: false - - property var per_category_intents: Cura.IntentModel - { - id: intentModel - intentCategory: model.intent_category - } - - property var intent_instantiator: Instantiator - { - model: intentModel - MenuItem - { - text: model.name - checkable: true - checked: false - Binding on checked - { - when: Cura.MachineManager.activeStack != null - value: Cura.MachineManager.activeStack.intent.metaData["intent_category"] == intentModel.intentCategory && Cura.MachineManager.activeStack.quality.metaData["quality_type"] == model.quality_type - } - exclusiveGroup: group - onTriggered: Cura.IntentManager.selectIntent(intentModel.intentCategory, model.quality_type) - } - - onObjectAdded: menu.insertItem(index, object) - onObjectRemoved: menu.removeItem(object) - } - } - - onObjectAdded: menu.insertItem(index, object) - onObjectRemoved: menu.removeItem(object) - } - ExclusiveGroup { id: group } -} From f7e6f22e6c73e1af5a5fa9e0ecae820500d01b66 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Tue, 6 Aug 2019 13:33:17 +0200 Subject: [PATCH 23/55] Fix typo CURA-6598 --- .../qml/PrintSetupSelector/Custom/QualitiesWithIntentMenu.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/qml/PrintSetupSelector/Custom/QualitiesWithIntentMenu.qml b/resources/qml/PrintSetupSelector/Custom/QualitiesWithIntentMenu.qml index 1ba73bb029..d52f890a4d 100644 --- a/resources/qml/PrintSetupSelector/Custom/QualitiesWithIntentMenu.qml +++ b/resources/qml/PrintSetupSelector/Custom/QualitiesWithIntentMenu.qml @@ -80,7 +80,7 @@ Popup target: parent property: "height" value: parent.childrenRect.height - when: parent.visibleChildren.lengt > 0 + when: parent.visibleChildren.length > 0 } // Add the qualities that belong to the intent From d5bbc3f205433e37eb76e1891c77b4b5390acce9 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Tue, 6 Aug 2019 13:34:35 +0200 Subject: [PATCH 24/55] Remove reference to unknown component CURA-6598 --- resources/qml/PrintSetupSelector/Custom/CustomPrintSetup.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/qml/PrintSetupSelector/Custom/CustomPrintSetup.qml b/resources/qml/PrintSetupSelector/Custom/CustomPrintSetup.qml index 4c3e2d395b..400b148896 100644 --- a/resources/qml/PrintSetupSelector/Custom/CustomPrintSetup.qml +++ b/resources/qml/PrintSetupSelector/Custom/CustomPrintSetup.qml @@ -205,7 +205,7 @@ Item { anchors { - top: tabBar.visible ? tabBar.bottom : globalProfileRow.bottom + top: tabBar.visible ? tabBar.bottom : intent.bottom topMargin: -UM.Theme.getSize("default_lining").width left: parent.left leftMargin: parent.padding From 210a2aa6bb506eb341f06c9c24751ac314cc1703 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Tue, 6 Aug 2019 15:13:06 +0200 Subject: [PATCH 25/55] Add arrow indicator to the custom print setup CURA-6598 --- .../Custom/CustomPrintSetup.qml | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/resources/qml/PrintSetupSelector/Custom/CustomPrintSetup.qml b/resources/qml/PrintSetupSelector/Custom/CustomPrintSetup.qml index 400b148896..0941c98cfb 100644 --- a/resources/qml/PrintSetupSelector/Custom/CustomPrintSetup.qml +++ b/resources/qml/PrintSetupSelector/Custom/CustomPrintSetup.qml @@ -109,8 +109,8 @@ Item height: UM.Theme.getSize("print_setup_icon").height anchors.verticalCenter: parent.verticalCenter - anchors.right: parent.right - anchors.rightMargin: UM.Theme.getSize("thick_margin").width + anchors.right: downArrow.left + anchors.rightMargin: UM.Theme.getSize("default_margin").width color: hovered ? UM.Theme.getColor("setting_control_button_hover") : UM.Theme.getColor("setting_control_button"); iconSource: UM.Theme.getIcon("star") @@ -127,6 +127,24 @@ Item } onExited: base.hideTooltip() } + UM.RecolorImage + { + id: downArrow + + + source: UM.Theme.getIcon("arrow_bottom") + width: UM.Theme.getSize("standard_arrow").width + height: UM.Theme.getSize("standard_arrow").height + + anchors + { + right: parent.right + verticalCenter: parent.verticalCenter + rightMargin: UM.Theme.getSize("default_margin").width + } + + color: UM.Theme.getColor("setting_control_button") + } } QualitiesWithIntentMenu From 5ab31df73800f791ce01a8060a868045a3fc894a Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Tue, 6 Aug 2019 15:19:01 +0200 Subject: [PATCH 26/55] Add hover effect to quality/intent selector CURA-6598 --- resources/qml/PrintSetupSelector/Custom/CustomPrintSetup.qml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/resources/qml/PrintSetupSelector/Custom/CustomPrintSetup.qml b/resources/qml/PrintSetupSelector/Custom/CustomPrintSetup.qml index 0941c98cfb..13df330fb8 100644 --- a/resources/qml/PrintSetupSelector/Custom/CustomPrintSetup.qml +++ b/resources/qml/PrintSetupSelector/Custom/CustomPrintSetup.qml @@ -58,6 +58,7 @@ Item anchors.right: parent.right width: UM.Theme.getSize("print_setup_big_item").width height: textLabel.contentHeight + 2 * UM.Theme.getSize("narrow_margin").height + hoverEnabled: true contentItem: Label { @@ -72,7 +73,8 @@ Item background: Rectangle { - border.color: UM.Theme.getColor("lining") + id: backgroundItem + border.color: intentSelection.hovered ? UM.Theme.getColor("setting_control_border_highlight") : UM.Theme.getColor("setting_control_border") border.width: UM.Theme.getSize("default_lining").width radius: UM.Theme.getSize("default_radius").width color: UM.Theme.getColor("main_background") From 0891abf8afdf1516f128a38a987b0b3df0e566d6 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Tue, 6 Aug 2019 17:08:23 +0200 Subject: [PATCH 27/55] Fix hover & highlighting for the qualities& intent menu CURA-6598 --- .../PrintSetupSelector/Custom/MenuButton.qml | 47 +++++++++++++ .../Custom/QualitiesWithIntentMenu.qml | 67 ++++++------------- 2 files changed, 66 insertions(+), 48 deletions(-) create mode 100644 resources/qml/PrintSetupSelector/Custom/MenuButton.qml diff --git a/resources/qml/PrintSetupSelector/Custom/MenuButton.qml b/resources/qml/PrintSetupSelector/Custom/MenuButton.qml new file mode 100644 index 0000000000..ee1be80075 --- /dev/null +++ b/resources/qml/PrintSetupSelector/Custom/MenuButton.qml @@ -0,0 +1,47 @@ +import QtQuick 2.0 +import QtQuick.Controls 2.3 +import Cura 1.6 as Cura + +import UM 1.2 as UM + +Button +{ + // This is a work around for a qml issue. Since the default button uses a private implementation for contentItem + // (the so called IconText), which handles the mnemonic conversion (aka; ensuring that &Button) text property + // is rendered with the B underlined. Since we're also forced to mix controls 1.0 and 2.0 actions together, + // we need a special property for the text of the label if we do want it to be rendered correclty, but don't want + // another shortcut to be added (which will cause for "QQuickAction::event: Ambiguous shortcut overload: " to + // happen. + property string labelText: "" + id: button + hoverEnabled: true + + background: Rectangle + { + id: backgroundRectangle + border.width: 1 + border.color: button.checked ? UM.Theme.getColor("setting_control_border_highlight") : "transparent" + color: button.hovered ? UM.Theme.getColor("action_button_hovered") : "transparent" + } + + // Workarround to ensure that the mnemonic highlighting happens correctly + function replaceText(txt) + { + var index = txt.indexOf("&") + if(index >= 0) + { + txt = txt.replace(txt.substr(index, 2), ("" + txt.substr(index + 1, 1) + "")) + } + return txt + } + + contentItem: Label + { + id: textLabel + text: button.text != "" ? replaceText(button.text) : replaceText(button.labelText) + height: contentHeight + verticalAlignment: Text.AlignVCenter + anchors.left: button.left + anchors.leftMargin: UM.Theme.getSize("default_margin").width + } +} \ No newline at end of file diff --git a/resources/qml/PrintSetupSelector/Custom/QualitiesWithIntentMenu.qml b/resources/qml/PrintSetupSelector/Custom/QualitiesWithIntentMenu.qml index d52f890a4d..314a2bd095 100644 --- a/resources/qml/PrintSetupSelector/Custom/QualitiesWithIntentMenu.qml +++ b/resources/qml/PrintSetupSelector/Custom/QualitiesWithIntentMenu.qml @@ -52,9 +52,7 @@ Popup anchors { left: parent.left - leftMargin: defaultMargin right: parent.right - rightMargin: defaultMargin } Label @@ -64,6 +62,8 @@ Popup height: visible ? contentHeight: 0 enabled: false visible: qualitiesList.visibleChildren.length > 0 + anchors.left: parent.left + anchors.leftMargin: UM.Theme.getSize("narrow_margin").width } Column @@ -88,16 +88,16 @@ Popup { visible: false model: subItemModel - Button + MenuButton { id: button onClicked: Cura.IntentManager.selectIntent(model.intent_category, model.quality_type) width: parent.width - height: buttonHeight checkable: true visible: model.available + text: model.name + " - " + model.layer_height + " mm" checked: { if(Cura.MachineManager.hasCustomQuality) @@ -108,34 +108,7 @@ Popup return Cura.MachineManager.activeQualityType == model.quality_type && Cura.MachineManager.activeIntentCategory == model.intent_category } ButtonGroup.group: buttonGroup - background: Item {} - contentItem: Item - { - Rectangle - { - id: checkmark - width: checkmarkSize - height: checkmarkSize - anchors.verticalCenter: parent.verticalCenter - color: "black" - visible: button.checked - } - Label - { - id: label - text: model.name + " - " + model.layer_height + " mm" - verticalAlignment: Text.AlignVCenter - anchors - { - left: checkmark.right - leftMargin: defaultMargin - top: parent.top - bottom: parent.bottom - right: parent.right - } - } - } } } } @@ -149,46 +122,43 @@ Popup anchors.right: parent.right color: borderColor } - Button + MenuButton { - text: Cura.Actions.addProfile.text + labelText: Cura.Actions.addProfile.text anchors.left: parent.left - anchors.leftMargin: defaultMargin + anchors.right: parent.right enabled: Cura.Actions.addProfile.enabled - background: Item {} onClicked: { Cura.Actions.addProfile.trigger() popup.visible = false } - } - Button + MenuButton { - text: Cura.Actions.updateProfile.text - + labelText: Cura.Actions.updateProfile.text anchors.left: parent.left - anchors.leftMargin: defaultMargin + anchors.right: parent.right enabled: Cura.Actions.updateProfile.enabled - background: Item {} + onClicked: { popup.visible = false Cura.Actions.updateProfile.trigger() } } - Button + MenuButton { text: catalog.i18nc("@action:button", "Discard current changes") anchors.left: parent.left - anchors.leftMargin: defaultMargin + anchors.right: parent.right enabled: Cura.MachineManager.hasUserSettings - background: Item {} + onClicked: { popup.visible = false @@ -202,20 +172,19 @@ Popup anchors.right: parent.right color: borderColor } - Button + + MenuButton { id: manageProfilesButton text: Cura.Actions.manageProfiles.text anchors { left: parent.left - leftMargin: defaultMargin right: parent.right - rightMargin: defaultMargin } height: textLabel.contentHeight + 2 * UM.Theme.getSize("narrow_margin").height - background: Item {} + contentItem: Item { width: manageProfilesButton.width @@ -224,6 +193,8 @@ Popup id: textLabel text: manageProfilesButton.text height: contentHeight + anchors.left: button.left + anchors.leftMargin: UM.Theme.getSize("default_margin").width } Label { From 4520ee7e1c6663608ad108c2d21f6344cb5fedd2 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Wed, 7 Aug 2019 09:58:14 +0200 Subject: [PATCH 28/55] Added rounded corners to the intent menu CURA-6598 --- .../Custom/QualitiesWithIntentMenu.qml | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/resources/qml/PrintSetupSelector/Custom/QualitiesWithIntentMenu.qml b/resources/qml/PrintSetupSelector/Custom/QualitiesWithIntentMenu.qml index 314a2bd095..a7caba3d95 100644 --- a/resources/qml/PrintSetupSelector/Custom/QualitiesWithIntentMenu.qml +++ b/resources/qml/PrintSetupSelector/Custom/QualitiesWithIntentMenu.qml @@ -12,15 +12,17 @@ Popup property int defaultMargin: 5 property int checkmarkSize: 12 property int buttonHeight: 25 - property color backgroundColor: "#f2f2f2" - property color borderColor: "#cccccc" + property color backgroundColor: UM.Theme.getColor("main_background") + property color borderColor: UM.Theme.getColor("lining") + padding: 0 - background: Rectangle + background: Cura.RoundedRectangle { color: backgroundColor - border.width: 1 + border.width: UM.Theme.getSize("default_lining").width border.color: borderColor + cornerSide: Cura.RoundedRectangle.Direction.Down } ButtonGroup @@ -33,11 +35,11 @@ Popup contentItem: Column { anchors.left: parent.left + anchors.leftMargin: UM.Theme.getSize("default_lining").width + anchors.rightMargin: UM.Theme.getSize("default_lining").width anchors.right: parent.right anchors.top: parent.top - height: childrenRect.height - // This repeater adds the intent labels Repeater { @@ -209,5 +211,11 @@ Popup Cura.Actions.manageProfiles.trigger() } } + // spacer + Item + { + width: 2 + height: UM.Theme.getSize("default_radius").width + } } } From 7c832e7ea367ac408ecd68a4a6ab691163199fba Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Wed, 7 Aug 2019 10:58:50 +0200 Subject: [PATCH 29/55] Intents are now also displayed in active profile labels CURA-6598 --- .../qml/PrintSetupSelector/Custom/CustomPrintSetup.qml | 9 ++++++++- .../PrintSetupSelector/PrintSetupSelectorHeader.qml | 10 ++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/resources/qml/PrintSetupSelector/Custom/CustomPrintSetup.qml b/resources/qml/PrintSetupSelector/Custom/CustomPrintSetup.qml index 13df330fb8..656f58ac28 100644 --- a/resources/qml/PrintSetupSelector/Custom/CustomPrintSetup.qml +++ b/resources/qml/PrintSetupSelector/Custom/CustomPrintSetup.qml @@ -82,7 +82,14 @@ Item function generateActiveQualityText() { - var result = Cura.MachineManager.activeQualityOrQualityChangesName + + var result = "" + if(Cura.MachineManager.activeIntentCategory != "default") + { + result += Cura.MachineManager.activeIntentCategory + " - " + } + + result += Cura.MachineManager.activeQualityOrQualityChangesName if (Cura.MachineManager.isActiveQualityExperimental) { result += " (Experimental)" diff --git a/resources/qml/PrintSetupSelector/PrintSetupSelectorHeader.qml b/resources/qml/PrintSetupSelector/PrintSetupSelectorHeader.qml index 96b244d803..30691d32b9 100644 --- a/resources/qml/PrintSetupSelector/PrintSetupSelectorHeader.qml +++ b/resources/qml/PrintSetupSelector/PrintSetupSelectorHeader.qml @@ -20,10 +20,16 @@ RowLayout { if (Cura.MachineManager.activeStack) { - var text = Cura.MachineManager.activeQualityOrQualityChangesName + var text = "" + if(Cura.MachineManager.activeIntentCategory != "default") + { + text += Cura.MachineManager.activeIntentCategory + " - " + } + + text += Cura.MachineManager.activeQualityOrQualityChangesName if (!Cura.MachineManager.hasNotSupportedQuality) { - text += " " + layerHeight.properties.value + "mm" + text += " - " + layerHeight.properties.value + "mm" text += Cura.MachineManager.isActiveQualityExperimental ? " - " + catalog.i18nc("@label", "Experimental") : "" } return text From 6220dfd15354ce62ea5b01fd242eaa7113369f9e Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Wed, 7 Aug 2019 11:02:17 +0200 Subject: [PATCH 30/55] Remove profile menu CURA-6598 --- resources/qml/Menus/ProfileMenu.qml | 84 ---------------------------- resources/qml/Menus/SettingsMenu.qml | 1 - 2 files changed, 85 deletions(-) delete mode 100644 resources/qml/Menus/ProfileMenu.qml diff --git a/resources/qml/Menus/ProfileMenu.qml b/resources/qml/Menus/ProfileMenu.qml deleted file mode 100644 index 68260f2502..0000000000 --- a/resources/qml/Menus/ProfileMenu.qml +++ /dev/null @@ -1,84 +0,0 @@ -// Copyright (c) 2018 Ultimaker B.V. -// Cura is released under the terms of the LGPLv3 or higher. - -import QtQuick 2.7 -import QtQuick.Controls 1.4 - -import UM 1.2 as UM -import Cura 1.0 as Cura - -Menu -{ - id: menu - - Instantiator - { - model: Cura.QualityProfilesDropDownMenuModel - - MenuItem - { - text: - { - var full_text = (model.layer_height != "") ? model.name + " - " + model.layer_height + model.layer_height_unit : model.name - full_text += model.is_experimental ? " - " + catalog.i18nc("@label", "Experimental") : "" - return full_text - } - checkable: true - checked: Cura.MachineManager.activeQualityOrQualityChangesName == model.name - exclusiveGroup: group - onTriggered: Cura.MachineManager.setQualityGroup(model.quality_group) - visible: model.available - } - - onObjectAdded: menu.insertItem(index, object) - onObjectRemoved: menu.removeItem(object) - } - - MenuSeparator - { - id: customSeparator - visible: Cura.CustomQualityProfilesDropDownMenuModel.count > 0 - } - - Instantiator - { - id: customProfileInstantiator - model: Cura.CustomQualityProfilesDropDownMenuModel - - Connections - { - target: Cura.CustomQualityProfilesDropDownMenuModel - onModelReset: customSeparator.visible = Cura.CustomQualityProfilesDropDownMenuModel.count > 0 - } - - MenuItem - { - text: model.name - checkable: true - checked: Cura.MachineManager.activeQualityOrQualityChangesName == model.name - exclusiveGroup: group - onTriggered: Cura.MachineManager.setQualityChangesGroup(model.quality_changes_group) - } - - onObjectAdded: - { - customSeparator.visible = model.count > 0; - menu.insertItem(index, object); - } - onObjectRemoved: - { - customSeparator.visible = model.count > 0; - menu.removeItem(object); - } - } - - ExclusiveGroup { id: group; } - - MenuSeparator { id: profileMenuSeparator } - - MenuItem { action: Cura.Actions.addProfile } - MenuItem { action: Cura.Actions.updateProfile } - MenuItem { action: Cura.Actions.resetProfile } - MenuSeparator { } - MenuItem { action: Cura.Actions.manageProfiles } -} diff --git a/resources/qml/Menus/SettingsMenu.qml b/resources/qml/Menus/SettingsMenu.qml index 2845101dbf..f885120220 100644 --- a/resources/qml/Menus/SettingsMenu.qml +++ b/resources/qml/Menus/SettingsMenu.qml @@ -63,7 +63,6 @@ Menu title: catalog.i18nc("@title:menu", "&Build plate") visible: CuraSDKVersion == "dev" && Cura.MachineManager.hasVariantBuildplates } - ProfileMenu { title: catalog.i18nc("@title:settings", "&Profile") } MenuSeparator { } From a3d3580e2af3bdf0b5bc8eba05cde082a7b89187 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Wed, 7 Aug 2019 11:04:54 +0200 Subject: [PATCH 31/55] Remove buildplate menu The menu wasn't used anymore and leaving it in just makes things more complicated --- resources/qml/Menus/BuildplateMenu.qml | 36 -------------------------- resources/qml/Menus/SettingsMenu.qml | 7 ----- 2 files changed, 43 deletions(-) delete mode 100644 resources/qml/Menus/BuildplateMenu.qml diff --git a/resources/qml/Menus/BuildplateMenu.qml b/resources/qml/Menus/BuildplateMenu.qml deleted file mode 100644 index b924aa0879..0000000000 --- a/resources/qml/Menus/BuildplateMenu.qml +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (c) 2018 Ultimaker B.V. -// Cura is released under the terms of the LGPLv3 or higher. - -import QtQuick 2.7 -import QtQuick.Controls 1.4 - -import UM 1.2 as UM -import Cura 1.0 as Cura - -Menu -{ - id: menu - title: "Build plate" - - property var buildPlateModel: CuraApplication.getBuildPlateModel() - - Instantiator - { - model: menu.buildPlateModel - - MenuItem { - text: model.name - checkable: true - checked: model.name == Cura.MachineManager.globalVariantName - exclusiveGroup: group - onTriggered: { - Cura.MachineManager.setGlobalVariant(model.container_node); - } - } - - onObjectAdded: menu.insertItem(index, object) - onObjectRemoved: menu.removeItem(object) - } - - ExclusiveGroup { id: group } -} diff --git a/resources/qml/Menus/SettingsMenu.qml b/resources/qml/Menus/SettingsMenu.qml index f885120220..17a4f6734a 100644 --- a/resources/qml/Menus/SettingsMenu.qml +++ b/resources/qml/Menus/SettingsMenu.qml @@ -57,13 +57,6 @@ Menu onObjectRemoved: base.removeItem(object) } - // TODO Only show in dev mode. Remove check when feature ready - BuildplateMenu - { - title: catalog.i18nc("@title:menu", "&Build plate") - visible: CuraSDKVersion == "dev" && Cura.MachineManager.hasVariantBuildplates - } - MenuSeparator { } MenuItem { action: Cura.Actions.configureSettingVisibility } From c7b6133e3dd4c0cd53ecb0c5f754f1f818535025 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Wed, 7 Aug 2019 11:27:02 +0200 Subject: [PATCH 32/55] Some UI polishing CURA-6598 --- resources/qml/PrintSetupSelector/Custom/MenuButton.qml | 3 ++- .../Custom/QualitiesWithIntentMenu.qml | 10 +++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/resources/qml/PrintSetupSelector/Custom/MenuButton.qml b/resources/qml/PrintSetupSelector/Custom/MenuButton.qml index ee1be80075..1652b71213 100644 --- a/resources/qml/PrintSetupSelector/Custom/MenuButton.qml +++ b/resources/qml/PrintSetupSelector/Custom/MenuButton.qml @@ -22,6 +22,7 @@ Button border.width: 1 border.color: button.checked ? UM.Theme.getColor("setting_control_border_highlight") : "transparent" color: button.hovered ? UM.Theme.getColor("action_button_hovered") : "transparent" + radius: UM.Theme.getSize("action_button_radius").width } // Workarround to ensure that the mnemonic highlighting happens correctly @@ -42,6 +43,6 @@ Button height: contentHeight verticalAlignment: Text.AlignVCenter anchors.left: button.left - anchors.leftMargin: UM.Theme.getSize("default_margin").width + anchors.leftMargin: UM.Theme.getSize("wide_margin").width } } \ No newline at end of file diff --git a/resources/qml/PrintSetupSelector/Custom/QualitiesWithIntentMenu.qml b/resources/qml/PrintSetupSelector/Custom/QualitiesWithIntentMenu.qml index a7caba3d95..6d51b9005b 100644 --- a/resources/qml/PrintSetupSelector/Custom/QualitiesWithIntentMenu.qml +++ b/resources/qml/PrintSetupSelector/Custom/QualitiesWithIntentMenu.qml @@ -65,7 +65,7 @@ Popup enabled: false visible: qualitiesList.visibleChildren.length > 0 anchors.left: parent.left - anchors.leftMargin: UM.Theme.getSize("narrow_margin").width + anchors.leftMargin: UM.Theme.getSize("default_margin").width } Column @@ -195,14 +195,18 @@ Popup id: textLabel text: manageProfilesButton.text height: contentHeight - anchors.left: button.left - anchors.leftMargin: UM.Theme.getSize("default_margin").width + anchors.left: parent.left + anchors.leftMargin: UM.Theme.getSize("default_margin").width + UM.Theme.getSize("narrow_margin").width + verticalAlignment: Text.AlignVCenter } Label { id: shortcutLabel text: Cura.Actions.manageProfiles.shortcut + height: contentHeight anchors.right: parent.right + anchors.rightMargin: UM.Theme.getSize("default_margin").width + verticalAlignment: Text.AlignVCenter } } onClicked: From b56c09bcf43345e4953a5f44642c2eb709382745 Mon Sep 17 00:00:00 2001 From: Remco Burema Date: Wed, 7 Aug 2019 15:50:00 +0200 Subject: [PATCH 33/55] Fix recommended-menu layer-height-label for Qt-5.10.0 part of CURA-6598 --- resources/qml/LabelBar.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/qml/LabelBar.qml b/resources/qml/LabelBar.qml index ea29df0e06..6edfb3866c 100644 --- a/resources/qml/LabelBar.qml +++ b/resources/qml/LabelBar.qml @@ -28,7 +28,7 @@ Item { Layout.fillWidth: true Layout.fillHeight: true - Layout.maximumWidth: index + 1 === repeater.count ? itemSize: 200000000 + Layout.maximumWidth: index + 1 === repeater.count || repeater.count <= 1 ? itemSize : base.width / (repeater.count - 1) height: childrenRect.height Label { From f4dc93fc39a27402deea1f5bfbfbb54b42a558ca Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Thu, 29 Aug 2019 11:57:03 +0200 Subject: [PATCH 34/55] Prevent crash in model if no extruder is set CURA-6598 --- cura/Machines/Models/BaseMaterialsModel.py | 2 ++ resources/qml/Settings/SettingComboBox.qml | 3 +-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/cura/Machines/Models/BaseMaterialsModel.py b/cura/Machines/Models/BaseMaterialsModel.py index 3ab11b7e9d..8d7e8bda95 100644 --- a/cura/Machines/Models/BaseMaterialsModel.py +++ b/cura/Machines/Models/BaseMaterialsModel.py @@ -103,6 +103,8 @@ class BaseMaterialsModel(ListModel): # tree. This change may trigger an _update() call when the materials # changed for the configuration that this model is looking for. def _materialsListChanged(self, material: MaterialNode) -> None: + if self._extruder_stack is None: + return if material.variant.container_id != self._extruder_stack.variant.getId(): return if material.variant.machine.container_id != cura.CuraApplication.CuraApplication.getInstance().getGlobalContainerStack().definition.getId(): diff --git a/resources/qml/Settings/SettingComboBox.qml b/resources/qml/Settings/SettingComboBox.qml index 0b7f494a7d..1814d997b3 100644 --- a/resources/qml/Settings/SettingComboBox.qml +++ b/resources/qml/Settings/SettingComboBox.qml @@ -20,8 +20,7 @@ SettingItem textRole: "value" anchors.fill: parent - highlighted: base.hovered - + onActivated: { forceActiveFocus() From d59d7e5b8dc73b149eae6892f12243b6095e73b1 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Thu, 29 Aug 2019 13:09:42 +0200 Subject: [PATCH 35/55] Bump version nr --- resources/intent/smooth.inst.cfg | 2 +- resources/intent/strong.inst.cfg | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/intent/smooth.inst.cfg b/resources/intent/smooth.inst.cfg index cfaa18c2bf..2ec33da504 100644 --- a/resources/intent/smooth.inst.cfg +++ b/resources/intent/smooth.inst.cfg @@ -4,7 +4,7 @@ name = Smooth (TEST INTENT) definition = ultimaker3 [metadata] -setting_version = 8 +setting_version = 9 type = intent intent_category = smooth quality_type = draft diff --git a/resources/intent/strong.inst.cfg b/resources/intent/strong.inst.cfg index e90b73d7d8..d0354070a0 100644 --- a/resources/intent/strong.inst.cfg +++ b/resources/intent/strong.inst.cfg @@ -4,7 +4,7 @@ name = Strong (TEST INTENT) definition = ultimaker3 [metadata] -setting_version = 8 +setting_version = 9 type = intent intent_category = engineering quality_type = draft From a8b818fbdc14d8205e8d91f6236f1361746f37ee Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Thu, 29 Aug 2019 13:52:01 +0200 Subject: [PATCH 36/55] Ensure that right intents are added to the tree CURA-6598 --- cura/Machines/IntentNode.py | 5 ++++- cura/Machines/QualityNode.py | 6 +++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/cura/Machines/IntentNode.py b/cura/Machines/IntentNode.py index 232498536c..521e7f2e38 100644 --- a/cura/Machines/IntentNode.py +++ b/cura/Machines/IntentNode.py @@ -3,6 +3,7 @@ from typing import TYPE_CHECKING +from UM.Settings.ContainerRegistry import ContainerRegistry from cura.Machines.ContainerNode import ContainerNode if TYPE_CHECKING: @@ -14,4 +15,6 @@ if TYPE_CHECKING: class IntentNode(ContainerNode): def __init__(self, container_id: str, quality: "QualityNode") -> None: super().__init__(container_id) - self.quality = quality \ No newline at end of file + self.quality = quality + my_metadata = ContainerRegistry.getInstance().findContainersMetadata(id=container_id)[0] + self.intent_category = my_metadata.get("intent_category", "default") \ No newline at end of file diff --git a/cura/Machines/QualityNode.py b/cura/Machines/QualityNode.py index 451c8babfb..7980f4ed63 100644 --- a/cura/Machines/QualityNode.py +++ b/cura/Machines/QualityNode.py @@ -31,8 +31,8 @@ class QualityNode(ContainerNode): # Find all intent profiles that fit the current configuration. from cura.Machines.MachineNode import MachineNode if not isinstance(self.parent, MachineNode): # Not a global profile. - for intent in container_registry.findInstanceContainersMetadata(type = "intent", definition = self.parent.variant.machine.quality_definition, variant = self.parent.variant.variant_name, material = self.parent.base_file): + for intent in container_registry.findInstanceContainersMetadata(type = "intent", definition = self.parent.variant.machine.quality_definition, variant = self.parent.variant.variant_name, material = self.parent.base_file, quality_type = self.quality_type): self.intents[intent["id"]] = IntentNode(intent["id"], quality = self) - if not self.intents: - self.intents["empty_intent"] = IntentNode("empty_intent", quality = self) + + self.intents["empty_intent"] = IntentNode("empty_intent", quality = self) # Otherwise, there are no intents for global profiles. \ No newline at end of file From ba0c16d96851580f556a4bf2ee030c56626af3c4 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Thu, 29 Aug 2019 13:53:23 +0200 Subject: [PATCH 37/55] Update intents model to use container tree CURA-6598 --- cura/Machines/Models/IntentModel.py | 30 ++++++++++++++-------- resources/qml/Settings/SettingComboBox.qml | 2 +- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/cura/Machines/Models/IntentModel.py b/cura/Machines/Models/IntentModel.py index 666786e26a..5b4ce10878 100644 --- a/cura/Machines/Models/IntentModel.py +++ b/cura/Machines/Models/IntentModel.py @@ -10,6 +10,7 @@ from UM.Settings.ContainerRegistry import ContainerRegistry from UM.Settings.SettingFunction import SettingFunction from cura.Machines.ContainerTree import ContainerTree +from cura.Settings.ExtruderManager import ExtruderManager from cura.Settings.IntentManager import IntentManager import cura.CuraApplication @@ -61,18 +62,27 @@ class IntentModel(ListModel): return quality_groups = ContainerTree.getInstance().getCurrentQualityGroups() + container_tree = ContainerTree.getInstance() + machine_node = container_tree.machines[global_stack.definition.getId()] + active_extruder = ExtruderManager.getInstance().getActiveExtruderStack() + active_variant_name = active_extruder.variant.getMetaDataEntry("name") + active_variant_node = machine_node.variants[active_variant_name] + active_material_node = active_variant_node.materials[active_extruder.material.getMetaDataEntry("base_file")] layer_heights_added = [] - for quality_tuple, quality_group in quality_groups.items(): - # Add the intents that are of the correct category - if quality_tuple[0] == self._intent_category: - layer_height = self._fetchLayerHeight(quality_group) - new_items.append({"name": quality_group.name, - "quality_type": quality_tuple[1], - "layer_height": layer_height, - "available": quality_group.is_available, - "intent_category": self._intent_category - }) + for quality_id, quality_node in active_material_node.qualities.items(): + quality_group = quality_groups[quality_node.quality_type] + layer_height = self._fetchLayerHeight(quality_group) + + for intent_id, intent_node in quality_node.intents.items(): + if intent_node.intent_category != self._intent_category: + continue layer_heights_added.append(layer_height) + new_items.append({"name": quality_group.name, + "quality_type": quality_group.quality_type, + "layer_height": layer_height, + "available": quality_group.is_available, + "intent_category": self._intent_category + }) # Now that we added all intents that we found something for, ensure that we set add ticks (and layer_heights) # for all groups that we don't have anything for (and set it to not available) diff --git a/resources/qml/Settings/SettingComboBox.qml b/resources/qml/Settings/SettingComboBox.qml index 1814d997b3..cbabb3ffd4 100644 --- a/resources/qml/Settings/SettingComboBox.qml +++ b/resources/qml/Settings/SettingComboBox.qml @@ -20,7 +20,7 @@ SettingItem textRole: "value" anchors.fill: parent - + onActivated: { forceActiveFocus() From de1065f0a3a732004b0a0441d1ddd32a50087688 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Thu, 29 Aug 2019 14:04:05 +0200 Subject: [PATCH 38/55] Prevent crash if extruder is not yet set CURA-6598 --- cura/Machines/Models/IntentModel.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cura/Machines/Models/IntentModel.py b/cura/Machines/Models/IntentModel.py index 5b4ce10878..e76c73cde1 100644 --- a/cura/Machines/Models/IntentModel.py +++ b/cura/Machines/Models/IntentModel.py @@ -65,6 +65,8 @@ class IntentModel(ListModel): container_tree = ContainerTree.getInstance() machine_node = container_tree.machines[global_stack.definition.getId()] active_extruder = ExtruderManager.getInstance().getActiveExtruderStack() + if not active_extruder: + return active_variant_name = active_extruder.variant.getMetaDataEntry("name") active_variant_node = machine_node.variants[active_variant_name] active_material_node = active_variant_node.materials[active_extruder.material.getMetaDataEntry("base_file")] From 68d3cf841296be622deb4e7ac87a6d888fff9c92 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Thu, 29 Aug 2019 14:12:17 +0200 Subject: [PATCH 39/55] Fix binding loop in LabelBar CURA-6598 --- resources/qml/LabelBar.qml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/resources/qml/LabelBar.qml b/resources/qml/LabelBar.qml index 6edfb3866c..f6e655de79 100644 --- a/resources/qml/LabelBar.qml +++ b/resources/qml/LabelBar.qml @@ -17,7 +17,7 @@ Item { anchors.left: parent.left anchors.right: parent.right - height: childrenRect.height + height: label.height spacing: 0 Repeater { @@ -27,9 +27,8 @@ Item Item { Layout.fillWidth: true - Layout.fillHeight: true Layout.maximumWidth: index + 1 === repeater.count || repeater.count <= 1 ? itemSize : base.width / (repeater.count - 1) - height: childrenRect.height + height: label.height Label { id: label From c80cd9679ff8ad6680d7f6387aa0072ec37527d2 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Thu, 29 Aug 2019 15:15:35 +0200 Subject: [PATCH 40/55] Fix RadioCheckbars layout getting out of wack sometimes CURA-6598 --- .../Recommended/RecommendedQualityProfileSelector.qml | 7 ++++++- resources/qml/RadioCheckbar.qml | 3 ++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedQualityProfileSelector.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedQualityProfileSelector.qml index 9194f3c85c..2742605399 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedQualityProfileSelector.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedQualityProfileSelector.qml @@ -78,7 +78,7 @@ Item left: parent.left right: parent.right } - height: childrenRect.height + height: intentCategoryLabel.height Label { @@ -110,6 +110,11 @@ Item // When user created profile is active, no quality tickbox should be active. return false } + + if(modelItem === null) + { + return false + } return Cura.MachineManager.activeQualityType == modelItem.quality_type && Cura.MachineManager.activeIntentCategory == modelItem.intent_category } diff --git a/resources/qml/RadioCheckbar.qml b/resources/qml/RadioCheckbar.qml index 1bc1c135f6..4f959fc8fd 100644 --- a/resources/qml/RadioCheckbar.qml +++ b/resources/qml/RadioCheckbar.qml @@ -57,10 +57,11 @@ Item Item { Layout.fillWidth: true + Layout.fillHeight: true // The last item of the repeater needs to be shorter, as we don't need another part to fit // the horizontal bar. The others should essentially not be limited. Layout.maximumWidth: index + 1 === repeater.count ? activeComponent.width: 200000000 - height: activeComponent.height + property bool isEnabled: model.available // The horizontal bar between the checkable options. // Note that the horizontal bar points towards the previous item. From 04997fca7fc2eafc22f9646f96351df0f5d919de Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Thu, 29 Aug 2019 15:52:02 +0200 Subject: [PATCH 41/55] Add property for active intent category CURA-6598 --- cura/Settings/MachineManager.py | 10 ++++++++++ cura/Settings/cura_empty_instance_containers.py | 1 + 2 files changed, 11 insertions(+) diff --git a/cura/Settings/MachineManager.py b/cura/Settings/MachineManager.py index e0293c200f..7e25cd5d57 100755 --- a/cura/Settings/MachineManager.py +++ b/cura/Settings/MachineManager.py @@ -132,6 +132,7 @@ class MachineManager(QObject): activeMaterialChanged = pyqtSignal() activeVariantChanged = pyqtSignal() activeQualityChanged = pyqtSignal() + activeIntentChanged = pyqtSignal() activeStackChanged = pyqtSignal() # Emitted whenever the active stack is changed (ie: when changing between extruders, changing a profile, but not when changing a value) extruderChanged = pyqtSignal() @@ -270,6 +271,7 @@ class MachineManager(QObject): self.activeQualityChanged.emit() self.activeVariantChanged.emit() self.activeMaterialChanged.emit() + self.activeIntentChanged.emit() self.rootMaterialChanged.emit() self.numberExtrudersEnabledChanged.emit() @@ -607,6 +609,14 @@ class MachineManager(QObject): return False return Util.parseBool(global_container_stack.quality.getMetaDataEntry("is_experimental", False)) + @pyqtProperty(str, notify=activeIntentChanged) + def activeIntentCategory(self): + + if not self._active_container_stack: + return "" + intent_category = self._active_container_stack.intent.getMetaDataEntry("intent_category") + return intent_category + ## Returns whether there is anything unsupported in the current set-up. # # The current set-up signifies the global stack and all extruder stacks, diff --git a/cura/Settings/cura_empty_instance_containers.py b/cura/Settings/cura_empty_instance_containers.py index e8a6df8ff1..0ab37c5435 100644 --- a/cura/Settings/cura_empty_instance_containers.py +++ b/cura/Settings/cura_empty_instance_containers.py @@ -47,6 +47,7 @@ EMPTY_INTENT_CONTAINER_ID = "empty_intent" empty_intent_container = copy.deepcopy(empty_container) empty_intent_container.setMetaDataEntry("id", EMPTY_INTENT_CONTAINER_ID) empty_intent_container.setMetaDataEntry("type", "intent") +empty_intent_container.setMetaDataEntry("intent_category", "default") empty_intent_container.setName(catalog.i18nc("@info:No intent profile selected", "Default")) From 001c2ec753bf0840de9422c15a4455ac71143f9a Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Thu, 29 Aug 2019 17:09:31 +0200 Subject: [PATCH 42/55] Fix test --- tests/Machines/TestQualityNode.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/Machines/TestQualityNode.py b/tests/Machines/TestQualityNode.py index 64685689c2..54266cb6ad 100644 --- a/tests/Machines/TestQualityNode.py +++ b/tests/Machines/TestQualityNode.py @@ -44,6 +44,7 @@ def test_qualityNode_machine_1(container_registry): with patch("UM.Settings.ContainerRegistry.ContainerRegistry.getInstance", MagicMock(return_value=container_registry)): node = QualityNode("quality_1", material_node) - assert len(node.intents) == 2 + assert len(node.intents) == 3 assert "intent_3" in node.intents - assert "intent_4" in node.intents \ No newline at end of file + assert "intent_4" in node.intents + assert "empty_intent" in node.intents \ No newline at end of file From 0926c223b2e167fbacd566d4b73d44a0016c2860 Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Tue, 3 Sep 2019 10:53:46 +0200 Subject: [PATCH 43/55] Add missing renderType: Text.NativeRendering CURA-6598 --- resources/qml/LabelBar.qml | 1 + resources/qml/PrintSetupSelector/Custom/CustomPrintSetup.qml | 2 ++ resources/qml/PrintSetupSelector/Custom/MenuButton.qml | 1 + .../qml/PrintSetupSelector/Custom/QualitiesWithIntentMenu.qml | 3 +++ 4 files changed, 7 insertions(+) diff --git a/resources/qml/LabelBar.qml b/resources/qml/LabelBar.qml index f6e655de79..3985a47368 100644 --- a/resources/qml/LabelBar.qml +++ b/resources/qml/LabelBar.qml @@ -35,6 +35,7 @@ Item text: model[modelKey] color: UM.Theme.getColor("text") font: UM.Theme.getFont("default") + renderType: Text.NativeRendering height: contentHeight anchors { diff --git a/resources/qml/PrintSetupSelector/Custom/CustomPrintSetup.qml b/resources/qml/PrintSetupSelector/Custom/CustomPrintSetup.qml index 656f58ac28..f329b1ce65 100644 --- a/resources/qml/PrintSetupSelector/Custom/CustomPrintSetup.qml +++ b/resources/qml/PrintSetupSelector/Custom/CustomPrintSetup.qml @@ -45,6 +45,7 @@ Item } text: catalog.i18nc("@label", "Profile") font: UM.Theme.getFont("medium") + renderType: Text.NativeRendering color: UM.Theme.getColor("text") verticalAlignment: Text.AlignVCenter } @@ -69,6 +70,7 @@ Item anchors.verticalCenter: intentSelection.verticalCenter height: contentHeight verticalAlignment: Text.AlignVCenter + renderType: Text.NativeRendering } background: Rectangle diff --git a/resources/qml/PrintSetupSelector/Custom/MenuButton.qml b/resources/qml/PrintSetupSelector/Custom/MenuButton.qml index 1652b71213..511e29de2a 100644 --- a/resources/qml/PrintSetupSelector/Custom/MenuButton.qml +++ b/resources/qml/PrintSetupSelector/Custom/MenuButton.qml @@ -44,5 +44,6 @@ Button verticalAlignment: Text.AlignVCenter anchors.left: button.left anchors.leftMargin: UM.Theme.getSize("wide_margin").width + renderType: Text.NativeRendering } } \ No newline at end of file diff --git a/resources/qml/PrintSetupSelector/Custom/QualitiesWithIntentMenu.qml b/resources/qml/PrintSetupSelector/Custom/QualitiesWithIntentMenu.qml index 6d51b9005b..cd2510163f 100644 --- a/resources/qml/PrintSetupSelector/Custom/QualitiesWithIntentMenu.qml +++ b/resources/qml/PrintSetupSelector/Custom/QualitiesWithIntentMenu.qml @@ -61,6 +61,7 @@ Popup { id: headerLabel text: model.name + renderType: Text.NativeRendering height: visible ? contentHeight: 0 enabled: false visible: qualitiesList.visibleChildren.length > 0 @@ -198,6 +199,7 @@ Popup anchors.left: parent.left anchors.leftMargin: UM.Theme.getSize("default_margin").width + UM.Theme.getSize("narrow_margin").width verticalAlignment: Text.AlignVCenter + renderType: Text.NativeRendering } Label { @@ -207,6 +209,7 @@ Popup anchors.right: parent.right anchors.rightMargin: UM.Theme.getSize("default_margin").width verticalAlignment: Text.AlignVCenter + renderType: Text.NativeRendering } } onClicked: From f77ad22fe3a7637f7b099330c99cf89cc8969730 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Tue, 3 Sep 2019 11:13:47 +0200 Subject: [PATCH 44/55] Fix hardcoded entries in radioCheckbar CURA-6598 --- resources/qml/RadioCheckbar.qml | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/resources/qml/RadioCheckbar.qml b/resources/qml/RadioCheckbar.qml index 4f959fc8fd..6f5ed301fa 100644 --- a/resources/qml/RadioCheckbar.qml +++ b/resources/qml/RadioCheckbar.qml @@ -1,18 +1,19 @@ import QtQuick 2.0 import QtQuick.Controls 2.3 import QtQuick.Layouts 1.3 +import UM 1.1 as UM Item { id: base property ButtonGroup buttonGroup: null - property color activeColor: "#3282ff" - property color inactiveColor: "#cccccc" - property color defaultItemColor: "#0a0850" - property int checkboxSize: 14 - property int inactiveMarkerSize: 4 - property int barSize: 2 + property color activeColor: UM.Theme.getColor("primary") + property color inactiveColor: UM.Theme.getColor("slider_groove") + property color defaultItemColor: UM.Theme.getColor("small_button_active") + property int checkboxSize: UM.Theme.getSize("radio_button").height * 0.75 + property int inactiveMarkerSize: 2 * barSize + property int barSize: UM.Theme.getSize("slider_groove_radius").height property var isCheckedFunction // Function that accepts the modelItem and returns if the item should be active. implicitWidth: 200 @@ -28,15 +29,13 @@ Item height: barSize - // This can (and should) be done wiht a verticalCenter. For some reason it does work in QtCreator - // but not when using the exact same QML in Cura. - y: 0.5 * checkboxSize anchors { left: buttonBar.left right: buttonBar.right leftMargin: (checkboxSize - inactiveMarkerSize) / 2 rightMargin: (checkboxSize - inactiveMarkerSize) / 2 + verticalCenter: parent.verticalCenter } } @@ -72,12 +71,11 @@ Item height: barSize width: buttonBar.width / (repeater.count - 1) - activeComponent.width - 2 color: defaultItemColor - // This can (and should) be done wiht a verticalCenter. For some reason it does work in QtCreator - // but not when using the exact same QML in Cura. - y: 0.5 * checkboxSize + anchors { right: activeComponent.left + verticalCenter: parent.verticalCenter } visible: previousItem !== null && previousItem.isEnabled && isEnabled } @@ -105,7 +103,7 @@ Item { // This can (and should) be done wiht a verticalCenter. For some reason it does work in QtCreator // but not when using the exact same QML in Cura. - y: 0.5 * checkboxSize - 1 + anchors.verticalCenter: parent.verticalCenter anchors.horizontalCenter: parent.horizontalCenter height: inactiveMarkerSize width: inactiveMarkerSize From 52f3f9b7735604f0d746459e4cec282956496906 Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Tue, 3 Sep 2019 11:01:39 +0200 Subject: [PATCH 45/55] Update QML import versions and add headings CURA-6598 --- resources/qml/LabelBar.qml | 9 +++++++-- .../qml/Menus/ConfigurationMenu/ConfigurationMenu.qml | 4 ++-- .../qml/PrintSetupSelector/Custom/CustomPrintSetup.qml | 6 +++--- resources/qml/PrintSetupSelector/Custom/MenuButton.qml | 7 +++++-- .../Custom/QualitiesWithIntentMenu.qml | 8 ++++++-- .../qml/PrintSetupSelector/PrintSetupSelectorHeader.qml | 2 +- .../Recommended/RecommendedPrintSetup.qml | 2 +- .../Recommended/RecommendedQualityProfileSelector.qml | 2 +- resources/qml/RadioCheckbar.qml | 5 ++++- 9 files changed, 30 insertions(+), 15 deletions(-) diff --git a/resources/qml/LabelBar.qml b/resources/qml/LabelBar.qml index 3985a47368..87cc825b3b 100644 --- a/resources/qml/LabelBar.qml +++ b/resources/qml/LabelBar.qml @@ -1,7 +1,12 @@ -import QtQuick 2.0 -import QtQuick.Controls 2.1 +// Copyright (c) 2019 Ultimaker B.V. +// Cura is released under the terms of the LGPLv3 or higher. + +import QtQuick 2.10 +import QtQuick.Controls 2.3 import QtQuick.Layouts 1.3 + import UM 1.2 as UM + // The labelBar shows a set of labels that are evenly spaced from oneother. // The first item is aligned to the left, the last is aligned to the right. // It's intended to be used together with RadioCheckBar. As such, it needs diff --git a/resources/qml/Menus/ConfigurationMenu/ConfigurationMenu.qml b/resources/qml/Menus/ConfigurationMenu/ConfigurationMenu.qml index fb074e948c..959d498054 100644 --- a/resources/qml/Menus/ConfigurationMenu/ConfigurationMenu.qml +++ b/resources/qml/Menus/ConfigurationMenu/ConfigurationMenu.qml @@ -1,8 +1,8 @@ // Copyright (c) 2018 Ultimaker B.V. // Cura is released under the terms of the LGPLv3 or higher. -import QtQuick 2.7 -import QtQuick.Controls 2.0 +import QtQuick 2.10 +import QtQuick.Controls 2.3 import QtQuick.Controls.Styles 1.4 import UM 1.2 as UM diff --git a/resources/qml/PrintSetupSelector/Custom/CustomPrintSetup.qml b/resources/qml/PrintSetupSelector/Custom/CustomPrintSetup.qml index f329b1ce65..d38dfc14f8 100644 --- a/resources/qml/PrintSetupSelector/Custom/CustomPrintSetup.qml +++ b/resources/qml/PrintSetupSelector/Custom/CustomPrintSetup.qml @@ -1,9 +1,9 @@ // Copyright (c) 2018 Ultimaker B.V. // Cura is released under the terms of the LGPLv3 or higher. -import QtQuick 2.7 -import QtQuick.Controls 2.0 -import QtQuick.Controls 1.1 as OldControls +import QtQuick 2.10 +import QtQuick.Controls 2.3 +import QtQuick.Controls 1.4 as OldControls import UM 1.3 as UM import Cura 1.6 as Cura diff --git a/resources/qml/PrintSetupSelector/Custom/MenuButton.qml b/resources/qml/PrintSetupSelector/Custom/MenuButton.qml index 511e29de2a..29436da9cf 100644 --- a/resources/qml/PrintSetupSelector/Custom/MenuButton.qml +++ b/resources/qml/PrintSetupSelector/Custom/MenuButton.qml @@ -1,8 +1,11 @@ -import QtQuick 2.0 +// Copyright (c) 2019 Ultimaker B.V. +// Cura is released under the terms of the LGPLv3 or higher. + +import QtQuick 2.10 import QtQuick.Controls 2.3 -import Cura 1.6 as Cura import UM 1.2 as UM +import Cura 1.6 as Cura Button { diff --git a/resources/qml/PrintSetupSelector/Custom/QualitiesWithIntentMenu.qml b/resources/qml/PrintSetupSelector/Custom/QualitiesWithIntentMenu.qml index cd2510163f..a885629247 100644 --- a/resources/qml/PrintSetupSelector/Custom/QualitiesWithIntentMenu.qml +++ b/resources/qml/PrintSetupSelector/Custom/QualitiesWithIntentMenu.qml @@ -1,8 +1,12 @@ -import QtQuick 2.0 +// Copyright (c) 2019 Ultimaker B.V. +// Cura is released under the terms of the LGPLv3 or higher. + +import QtQuick 2.10 import QtQuick.Controls 2.3 -import Cura 1.6 as Cura import UM 1.2 as UM +import Cura 1.6 as Cura + Popup { id: popup diff --git a/resources/qml/PrintSetupSelector/PrintSetupSelectorHeader.qml b/resources/qml/PrintSetupSelector/PrintSetupSelectorHeader.qml index 30691d32b9..5628867922 100644 --- a/resources/qml/PrintSetupSelector/PrintSetupSelectorHeader.qml +++ b/resources/qml/PrintSetupSelector/PrintSetupSelectorHeader.qml @@ -1,7 +1,7 @@ // Copyright (c) 2018 Ultimaker B.V. // Cura is released under the terms of the LGPLv3 or higher. -import QtQuick 2.7 +import QtQuick 2.10 import QtQuick.Controls 2.3 import QtQuick.Layouts 1.3 diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedPrintSetup.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedPrintSetup.qml index d9364681d2..a180ad6324 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedPrintSetup.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedPrintSetup.qml @@ -1,7 +1,7 @@ // Copyright (c) 2018 Ultimaker B.V. // Cura is released under the terms of the LGPLv3 or higher. -import QtQuick 2.7 +import QtQuick 2.10 import QtQuick.Controls 1.4 import QtQuick.Controls.Styles 1.4 diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedQualityProfileSelector.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedQualityProfileSelector.qml index 2742605399..68a3e4811d 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedQualityProfileSelector.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedQualityProfileSelector.qml @@ -1,7 +1,7 @@ // Copyright (c) 2018 Ultimaker B.V. // Cura is released under the terms of the LGPLv3 or higher. -import QtQuick 2.7 +import QtQuick 2.10 import QtQuick.Controls 1.4 import QtQuick.Controls 2.3 as Controls2 import QtQuick.Controls.Styles 1.4 diff --git a/resources/qml/RadioCheckbar.qml b/resources/qml/RadioCheckbar.qml index 6f5ed301fa..3c767a6201 100644 --- a/resources/qml/RadioCheckbar.qml +++ b/resources/qml/RadioCheckbar.qml @@ -1,4 +1,7 @@ -import QtQuick 2.0 +// Copyright (c) 2019 Ultimaker B.V. +// Cura is released under the terms of the LGPLv3 or higher. + +import QtQuick 2.10 import QtQuick.Controls 2.3 import QtQuick.Layouts 1.3 import UM 1.1 as UM From 39d52556f41f7f776167d406d02f3a7939160edf Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Tue, 3 Sep 2019 11:16:50 +0200 Subject: [PATCH 46/55] Fix text alignments by using rounding CURA-6598 --- resources/qml/LabelBar.qml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/resources/qml/LabelBar.qml b/resources/qml/LabelBar.qml index 87cc825b3b..571c9f0bfb 100644 --- a/resources/qml/LabelBar.qml +++ b/resources/qml/LabelBar.qml @@ -32,8 +32,9 @@ Item Item { Layout.fillWidth: true - Layout.maximumWidth: index + 1 === repeater.count || repeater.count <= 1 ? itemSize : base.width / (repeater.count - 1) + Layout.maximumWidth: Math.round(index + 1 === repeater.count || repeater.count <= 1 ? itemSize : base.width / (repeater.count - 1)) height: label.height + Label { id: label @@ -52,7 +53,7 @@ Item // We want the center of the label to align with the center of the item, so we negatively offset by half the contentWidth right: index + 1 === repeater.count ? parent.right: undefined left: index + 1 === repeater.count || index === 0 ? undefined: parent.left - leftMargin: (0.5 * itemSize) - 0.5 * contentWidth + leftMargin: Math.round((itemSize - contentWidth) * 0.5) } } } From ac0c7fd4d6b867dab9535f502c03e67abfead525 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Tue, 3 Sep 2019 11:27:11 +0200 Subject: [PATCH 47/55] Remove unused properties CURA-6598 --- .../qml/PrintSetupSelector/Custom/QualitiesWithIntentMenu.qml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/resources/qml/PrintSetupSelector/Custom/QualitiesWithIntentMenu.qml b/resources/qml/PrintSetupSelector/Custom/QualitiesWithIntentMenu.qml index cd2510163f..2aa80e8fe7 100644 --- a/resources/qml/PrintSetupSelector/Custom/QualitiesWithIntentMenu.qml +++ b/resources/qml/PrintSetupSelector/Custom/QualitiesWithIntentMenu.qml @@ -9,9 +9,7 @@ Popup implicitWidth: 400 property var dataModel: Cura.IntentCategoryModel {} - property int defaultMargin: 5 - property int checkmarkSize: 12 - property int buttonHeight: 25 + property int defaultMargin: UM.Theme.getSize("default_margin").width property color backgroundColor: UM.Theme.getColor("main_background") property color borderColor: UM.Theme.getColor("lining") From 2dbfbecd12c179b964d70a9f5f6fe81a07a3e55a Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Wed, 4 Sep 2019 16:37:10 +0200 Subject: [PATCH 48/55] Ensure that show/hide behavior of the qualities intent menu is correct It would previously blink if you pressed the button, as a click outside would hide it due to close policy, but a mouse release would show it again (as it's hidden and that's what the on clicked of the button did) CURA-6598 --- .../qml/PrintSetupSelector/Custom/QualitiesWithIntentMenu.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/qml/PrintSetupSelector/Custom/QualitiesWithIntentMenu.qml b/resources/qml/PrintSetupSelector/Custom/QualitiesWithIntentMenu.qml index 18088d50b9..e6bc798307 100644 --- a/resources/qml/PrintSetupSelector/Custom/QualitiesWithIntentMenu.qml +++ b/resources/qml/PrintSetupSelector/Custom/QualitiesWithIntentMenu.qml @@ -18,7 +18,7 @@ Popup property color borderColor: UM.Theme.getColor("lining") padding: 0 - + closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutsideParent background: Cura.RoundedRectangle { color: backgroundColor From 53aaaab891acab130e4c74fbd765c2a61e5ba544 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Wed, 4 Sep 2019 16:43:59 +0200 Subject: [PATCH 49/55] Add a topMargin for the qualities menu CURA-6598 --- .../Custom/QualitiesWithIntentMenu.qml | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/resources/qml/PrintSetupSelector/Custom/QualitiesWithIntentMenu.qml b/resources/qml/PrintSetupSelector/Custom/QualitiesWithIntentMenu.qml index e6bc798307..ccc3d3d71a 100644 --- a/resources/qml/PrintSetupSelector/Custom/QualitiesWithIntentMenu.qml +++ b/resources/qml/PrintSetupSelector/Custom/QualitiesWithIntentMenu.qml @@ -36,11 +36,17 @@ Popup contentItem: Column { - anchors.left: parent.left - anchors.leftMargin: UM.Theme.getSize("default_lining").width - anchors.rightMargin: UM.Theme.getSize("default_lining").width - anchors.right: parent.right - anchors.top: parent.top + anchors + { + left: parent.left + leftMargin: UM.Theme.getSize("default_lining").width + + right: parent.right + rightMargin: UM.Theme.getSize("default_lining").width + + top: parent.top + topMargin: UM.Theme.getSize("narrow_margin").height + } // This repeater adds the intent labels Repeater From 7f3b55a28670ef2f1770caf56165c1408d6709be Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Wed, 4 Sep 2019 16:48:06 +0200 Subject: [PATCH 50/55] Remove unknown reference CURA-6598 --- resources/qml/LabelBar.qml | 1 - 1 file changed, 1 deletion(-) diff --git a/resources/qml/LabelBar.qml b/resources/qml/LabelBar.qml index 571c9f0bfb..a6b54225f5 100644 --- a/resources/qml/LabelBar.qml +++ b/resources/qml/LabelBar.qml @@ -22,7 +22,6 @@ Item { anchors.left: parent.left anchors.right: parent.right - height: label.height spacing: 0 Repeater { From 994e0e53ccf99c34da0e307e912d6f3ff6c32f57 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Wed, 4 Sep 2019 16:54:35 +0200 Subject: [PATCH 51/55] Switch the anchors to paddings Otherwise the bottomb button would extend from the popup. CURA-6598 --- .../Custom/QualitiesWithIntentMenu.qml | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/resources/qml/PrintSetupSelector/Custom/QualitiesWithIntentMenu.qml b/resources/qml/PrintSetupSelector/Custom/QualitiesWithIntentMenu.qml index ccc3d3d71a..888a6ab309 100644 --- a/resources/qml/PrintSetupSelector/Custom/QualitiesWithIntentMenu.qml +++ b/resources/qml/PrintSetupSelector/Custom/QualitiesWithIntentMenu.qml @@ -17,6 +17,9 @@ Popup property color backgroundColor: UM.Theme.getColor("main_background") property color borderColor: UM.Theme.getColor("lining") + topPadding: UM.Theme.getSize("narrow_margin").height + rightPadding: UM.Theme.getSize("default_lining").width + leftPadding: UM.Theme.getSize("default_lining").width padding: 0 closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutsideParent background: Cura.RoundedRectangle @@ -36,18 +39,6 @@ Popup contentItem: Column { - anchors - { - left: parent.left - leftMargin: UM.Theme.getSize("default_lining").width - - right: parent.right - rightMargin: UM.Theme.getSize("default_lining").width - - top: parent.top - topMargin: UM.Theme.getSize("narrow_margin").height - } - // This repeater adds the intent labels Repeater { From 423b4ad8693fbe848a871f8999f65813b0c7d11b Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Wed, 4 Sep 2019 17:16:07 +0200 Subject: [PATCH 52/55] Fix binding loop CURA-6598 --- resources/qml/PrintSetupSelector/Custom/CustomPrintSetup.qml | 2 ++ .../qml/PrintSetupSelector/Custom/QualitiesWithIntentMenu.qml | 1 + 2 files changed, 3 insertions(+) diff --git a/resources/qml/PrintSetupSelector/Custom/CustomPrintSetup.qml b/resources/qml/PrintSetupSelector/Custom/CustomPrintSetup.qml index d38dfc14f8..682aefa821 100644 --- a/resources/qml/PrintSetupSelector/Custom/CustomPrintSetup.qml +++ b/resources/qml/PrintSetupSelector/Custom/CustomPrintSetup.qml @@ -61,6 +61,8 @@ Item height: textLabel.contentHeight + 2 * UM.Theme.getSize("narrow_margin").height hoverEnabled: true + baselineOffset: null // If we don't do this, there is a binding loop. WHich is a bit weird, since we override the contentItem anyway... + contentItem: Label { id: textLabel diff --git a/resources/qml/PrintSetupSelector/Custom/QualitiesWithIntentMenu.qml b/resources/qml/PrintSetupSelector/Custom/QualitiesWithIntentMenu.qml index 888a6ab309..96c8431112 100644 --- a/resources/qml/PrintSetupSelector/Custom/QualitiesWithIntentMenu.qml +++ b/resources/qml/PrintSetupSelector/Custom/QualitiesWithIntentMenu.qml @@ -20,6 +20,7 @@ Popup topPadding: UM.Theme.getSize("narrow_margin").height rightPadding: UM.Theme.getSize("default_lining").width leftPadding: UM.Theme.getSize("default_lining").width + padding: 0 closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutsideParent background: Cura.RoundedRectangle From 13011e375b7dd120f5cfe5df75bb4dc58819df14 Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Thu, 5 Sep 2019 09:00:53 +0200 Subject: [PATCH 53/55] Fix quality layer label alignment CURA-6598 --- resources/qml/LabelBar.qml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/resources/qml/LabelBar.qml b/resources/qml/LabelBar.qml index a6b54225f5..9a870811ca 100644 --- a/resources/qml/LabelBar.qml +++ b/resources/qml/LabelBar.qml @@ -53,6 +53,10 @@ Item right: index + 1 === repeater.count ? parent.right: undefined left: index + 1 === repeater.count || index === 0 ? undefined: parent.left leftMargin: Math.round((itemSize - contentWidth) * 0.5) + + // For some reason, the last label in the row gets misaligned with Qt 5.10. This lines seems to + // fix it. + verticalCenter: parent.verticalCenter } } } From 04e2ecde9355a7dd5838b4a178418c0a0d6ec1bb Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Mon, 9 Sep 2019 16:12:35 +0200 Subject: [PATCH 54/55] Init intent to empty_intent_container for new machine stacks CURA-6598 --- cura/Settings/CuraStackBuilder.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cura/Settings/CuraStackBuilder.py b/cura/Settings/CuraStackBuilder.py index 30eb0b009c..33b0fd8d2e 100644 --- a/cura/Settings/CuraStackBuilder.py +++ b/cura/Settings/CuraStackBuilder.py @@ -160,6 +160,7 @@ class CuraStackBuilder: stack.variant = variant_container stack.material = material_container stack.quality = quality_container + stack.intent = application.empty_intent_container stack.qualityChanges = application.empty_quality_changes_container stack.userChanges = user_container @@ -208,6 +209,7 @@ class CuraStackBuilder: stack.variant = variant_container stack.material = material_container stack.quality = quality_container + stack.intent = application.empty_intent_container stack.qualityChanges = application.empty_quality_changes_container stack.userChanges = user_container From dba3b77f61fa265f0e284a6a8304fa9c47902658 Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Mon, 9 Sep 2019 16:45:03 +0200 Subject: [PATCH 55/55] Fix tests CURA-6598 --- tests/Settings/TestCuraStackBuilder.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/tests/Settings/TestCuraStackBuilder.py b/tests/Settings/TestCuraStackBuilder.py index 9f2db2cf19..7a1e05296c 100644 --- a/tests/Settings/TestCuraStackBuilder.py +++ b/tests/Settings/TestCuraStackBuilder.py @@ -28,6 +28,14 @@ def quality_container(): return container +@pytest.fixture +def intent_container(): + container = InstanceContainer(container_id="intent container") + container.setMetaDataEntry("type", "intent") + + return container + + @pytest.fixture def quality_changes_container(): container = InstanceContainer(container_id="quality changes container") @@ -44,7 +52,8 @@ def test_createMachineWithUnknownDefinition(application, container_registry): assert mocked_config_error.addFaultyContainers.called_with("NOPE") -def test_createMachine(application, container_registry, definition_container, global_variant, material_instance_container, quality_container, quality_changes_container): +def test_createMachine(application, container_registry, definition_container, global_variant, material_instance_container, + quality_container, intent_container, quality_changes_container): variant_manager = MagicMock(name = "Variant Manager") quality_manager = MagicMock(name = "Quality Manager") global_variant_node = MagicMock( name = "global variant node") @@ -61,6 +70,7 @@ def test_createMachine(application, container_registry, definition_container, gl application.getQualityManager = MagicMock(return_value = quality_manager) application.empty_material_container = material_instance_container application.empty_quality_container = quality_container + application.empty_intent_container = intent_container application.empty_quality_changes_container = quality_changes_container application.empty_variant_container = global_variant @@ -83,9 +93,11 @@ def test_createMachine(application, container_registry, definition_container, gl assert machine.variant == global_variant -def test_createExtruderStack(application, definition_container, global_variant, material_instance_container, quality_container, quality_changes_container): +def test_createExtruderStack(application, definition_container, global_variant, material_instance_container, + quality_container, intent_container, quality_changes_container): application.empty_material_container = material_instance_container application.empty_quality_container = quality_container + application.empty_intent_container = intent_container application.empty_quality_changes_container = quality_changes_container with patch("cura.CuraApplication.CuraApplication.getInstance", MagicMock(return_value=application)): extruder_stack = CuraStackBuilder.createExtruderStack("Whatever", definition_container, "meh", 0, global_variant, material_instance_container, quality_container)