mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-05-07 06:48:58 +08:00
CURA-4381 use modulus to set infill slider step size and tick show
This commit is contained in:
parent
aed5e631dc
commit
f8e8dcacdf
@ -393,7 +393,7 @@ Item
|
|||||||
|
|
||||||
minimumValue: 0
|
minimumValue: 0
|
||||||
maximumValue: 100
|
maximumValue: 100
|
||||||
stepSize: 10
|
stepSize: (parseInt(infillDensity.properties.value) % 10 == 0) ? 10 : 1
|
||||||
tickmarksEnabled: true
|
tickmarksEnabled: true
|
||||||
|
|
||||||
// disable slider when gradual support is enabled
|
// disable slider when gradual support is enabled
|
||||||
@ -403,12 +403,12 @@ Item
|
|||||||
value: parseInt(infillDensity.properties.value)
|
value: parseInt(infillDensity.properties.value)
|
||||||
|
|
||||||
onValueChanged: {
|
onValueChanged: {
|
||||||
|
// Explicitly cast to string to make sure the value passed to Python is an integer.
|
||||||
infillDensity.setPropertyValue("value", String(parseInt(infillSlider.value)))
|
infillDensity.setPropertyValue("value", String(parseInt(infillSlider.value)))
|
||||||
}
|
}
|
||||||
|
|
||||||
style: SliderStyle
|
style: SliderStyle
|
||||||
{
|
{
|
||||||
|
|
||||||
groove: Rectangle {
|
groove: Rectangle {
|
||||||
id: groove
|
id: groove
|
||||||
implicitWidth: 200
|
implicitWidth: 200
|
||||||
@ -431,6 +431,18 @@ Item
|
|||||||
tickmarks: Repeater {
|
tickmarks: Repeater {
|
||||||
id: repeater
|
id: repeater
|
||||||
model: control.maximumValue / control.stepSize + 1
|
model: control.maximumValue / control.stepSize + 1
|
||||||
|
|
||||||
|
// check if a tick should be shown based on it's index and wether the infill density is a multiple of 10 (slider step size)
|
||||||
|
function shouldShowTick (index) {
|
||||||
|
if ((parseInt(infillDensity.properties.value) % 10 == 0)) {
|
||||||
|
return true
|
||||||
|
} else if (index % 10 == 0) {
|
||||||
|
return true
|
||||||
|
} else {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
color: control.enabled ? UM.Theme.getColor("quality_slider_available") : UM.Theme.getColor("quality_slider_unavailable")
|
color: control.enabled ? UM.Theme.getColor("quality_slider_available") : UM.Theme.getColor("quality_slider_unavailable")
|
||||||
@ -438,6 +450,7 @@ Item
|
|||||||
height: 6
|
height: 6
|
||||||
y: 0
|
y: 0
|
||||||
x: styleData.handleWidth / 2 + index * ((repeater.width - styleData.handleWidth) / (repeater.count-1))
|
x: styleData.handleWidth / 2 + index * ((repeater.width - styleData.handleWidth) / (repeater.count-1))
|
||||||
|
visible: shouldShowTick(index)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user