From 2c5f5170c2d05f5ffce1da5c471ff14b8289cc5b Mon Sep 17 00:00:00 2001 From: Diego Prado Gesto Date: Fri, 30 Nov 2018 15:38:28 +0100 Subject: [PATCH] Add the labels of the layer height to the slider Contributes to CURA-5941. --- .../RecommendedQualityProfileSelector.qml | 205 +++++++++--------- 1 file changed, 108 insertions(+), 97 deletions(-) diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedQualityProfileSelector.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedQualityProfileSelector.qml index 50da35814c..f7e1d870c9 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedQualityProfileSelector.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedQualityProfileSelector.qml @@ -158,78 +158,116 @@ Item } } - Cura.IconWithText + Item { - id: qualityRowTitle - source: UM.Theme.getIcon("category_layer_height") - text: catalog.i18nc("@label", "Layer Height") + id: titleRow width: labelColumnWidth + height: childrenRect.height + + Cura.IconWithText + { + id: qualityRowTitle + source: UM.Theme.getIcon("category_layer_height") + text: catalog.i18nc("@label", "Layer Height") + anchors.left: parent.left + anchors.right: customisedSettings.left + } + + UM.SimpleButton + { + id: customisedSettings + + visible: Cura.SimpleModeSettingsManager.isProfileCustomized || Cura.SimpleModeSettingsManager.isProfileUserCreated + height: visible ? Math.round(0.8 * qualityRowTitle.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, customisedSettings.height), tooltipContent) + } + onExited: base.hideTooltip() + } + } + + // Show titles for the each quality slider ticks + Item + { + anchors.left: speedSlider.left + anchors.top: speedSlider.bottom + + Repeater + { + model: qualityModel + + Label + { + anchors.verticalCenter: parent.verticalCenter + anchors.top: parent.top + 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)) + } + } + } + } } -// -// // Show titles for the each quality slider ticks -// Item -// { -// anchors.left: speedSlider.left -// anchors.top: speedSlider.bottom -// -// Repeater -// { -// model: qualityModel -// -// Label -// { -// anchors.verticalCenter: parent.verticalCenter -// anchors.top: parent.top -// 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)) -// } -// } -// } -// } -// } -// //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. @@ -240,8 +278,9 @@ Item anchors { - left: qualityRowTitle.right + left: titleRow.right right: parent.right + verticalCenter: titleRow.verticalCenter } // Draw unavailable slider @@ -401,32 +440,4 @@ Item onExited: base.hideTooltip() } } - - UM.SimpleButton - { - id: customisedSettings - - visible: Cura.SimpleModeSettingsManager.isProfileCustomized || Cura.SimpleModeSettingsManager.isProfileUserCreated - height: Math.round(speedSlider.height * 0.8) - width: Math.round(speedSlider.height * 0.8) - - anchors.verticalCenter: speedSlider.verticalCenter - anchors.right: speedSlider.left - anchors.rightMargin: Math.round(UM.Theme.getSize("thick_margin").width / 2) - - 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, customisedSettings.height), tooltipContent) - } - onExited: base.hideTooltip() - } } \ No newline at end of file