Move required settingPropertyProvider into InfillSlider.

Use new RecommendedSetting components for Strength section of recommended.

CURA-9793
This commit is contained in:
Joey de l'Arago 2022-11-29 17:50:40 +01:00
parent f99f1a4528
commit 7ba0281136
5 changed files with 45 additions and 98 deletions

View file

@ -15,9 +15,18 @@ RowLayout
anchors
{
left: infillRowTitle.right
left: strengthSection.right
right: parent.right
verticalCenter: infillRowTitle.verticalCenter
verticalCenter: strengthSection.verticalCenter
}
UM.SettingPropertyProvider
{
id: infillDensity
containerStackId: Cura.MachineManager.activeStackId
key: "infill_sparse_density"
watchedProperties: [ "value" ]
storeIndex: 0
}
UM.Label { Layout.fillWidth: false; text: "0" }

View file

@ -86,9 +86,7 @@ Item
RecommendedStrengthSelector
{
width: parent.width
labelColumnWidth: parent.firstColumnWidth
Layout.fillWidth: true
Layout.rightMargin: UM.Theme.getSize("default_margin").width
}
RecommendedSupportSelector

View file

@ -18,6 +18,7 @@ Item
property alias settingControl: settingContainer.children
property alias settingName: settingLabel.text
property string tooltipText: ""
UM.Label
{

View file

@ -5,108 +5,39 @@ import QtQuick 2.7
import QtQuick.Controls 2.15
import UM 1.5 as UM
import Cura 1.0 as Cura
import Cura 1.7 as Cura
//
// Infill
//
Item
RecommendedSettingSection
{
id: infillRow
height: childrenRect.height
id: strengthSection
property real labelColumnWidth: Math.round(width / 3)
title: catalog.i18nc("@label", "Strength")
icon: UM.Theme.getIcon("Hammer")
enableSectionVisible: false
enableSectionEnabled: false
// Here are the elements that are shown in the left column
Cura.IconWithText
{
id: infillRowTitle
anchors.top: parent.top
anchors.left: parent.left
source: UM.Theme.getIcon("Infill1")
text: `${catalog.i18nc("@label", "Infill")} (%)`
font: UM.Theme.getFont("medium")
width: labelColumnWidth
iconSize: UM.Theme.getSize("medium_button_icon").width
tooltipText: catalog.i18nc("@label", "Gradual infill will gradually increase the amount of infill towards the top.")
}
InfillSlider
{
id: infillSliderContainer
height: childrenRect.height
}
// Gradual Support Infill Checkbox
UM.CheckBox
{
id: enableGradualInfillCheckBox
property alias _hovered: enableGradualInfillMouseArea.containsMouse
anchors.top: infillSliderContainer.bottom
anchors.topMargin: UM.Theme.getSize("default_margin").height
anchors.left: infillSliderContainer.left
text: catalog.i18nc("@label", "Gradual infill")
enabled: recommendedPrintSetup.settingsEnabled
visible: infillSteps.properties.enabled == "True"
checked: parseInt(infillSteps.properties.value) > 0
MouseArea
contents: [
RecommendedSettingItem
{
id: enableGradualInfillMouseArea
anchors.fill: parent
hoverEnabled: true
enabled: true
property var previousInfillDensity: parseInt(infillDensity.properties.value)
onClicked:
settingName: catalog.i18nc("@action:label", "Infill Density")
tooltipText: catalog.i18nc("@label", "Gradual infill will gradually increase the amount of infill towards the top.")
settingControl: InfillSlider
{
// Set to 90% only when enabling gradual infill
var newInfillDensity;
if (parseInt(infillSteps.properties.value) == 0)
{
previousInfillDensity = parseInt(infillDensity.properties.value)
newInfillDensity = 90
} else {
newInfillDensity = previousInfillDensity
}
Cura.MachineManager.setSettingForAllExtruders("infill_sparse_density", "value", String(newInfillDensity))
var infill_steps_value = 0
if (parseInt(infillSteps.properties.value) == 0)
{
infill_steps_value = 5
}
Cura.MachineManager.setSettingForAllExtruders("gradual_infill_steps", "value", infill_steps_value)
height: UM.Theme.getSize("combobox").height
width: parent.width
}
},
RecommendedSettingItem
{
settingName: catalog.i18nc("@action:label", "Infill Pattern")
onEntered: base.showTooltip(enableGradualInfillCheckBox, Qt.point(-infillSliderContainer.x - UM.Theme.getSize("thick_margin").width, 0),
catalog.i18nc("@label", "Gradual infill will gradually increase the amount of infill towards the top."))
onExited: base.hideTooltip()
settingControl: Cura.SingleSettingComboBox
{
width: parent.width
height: UM.Theme.getSize("combobox").height
settingName: "infill_pattern"
}
}
}
UM.SettingPropertyProvider
{
id: infillDensity
containerStackId: Cura.MachineManager.activeStackId
key: "infill_sparse_density"
watchedProperties: [ "value" ]
storeIndex: 0
}
UM.SettingPropertyProvider
{
id: infillSteps
containerStackId: Cura.MachineManager.activeStackId
key: "gradual_infill_steps"
watchedProperties: ["value", "enabled"]
storeIndex: 0
}
]
}