mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-12 19:49:00 +08:00
The slider was not forcing its setting value to stay the same when changes were made in the "Advanced" menu. This is because the slider updating and setting updating functions were intertwined. I've seperated them so that the slider no longer interferes with changes to the setting.
The Shell thickness settings were not being read or set correctly. I fixed this by setting the value to all extruders and reading from extruder 1. This setting is not set per machine but for all extruders. Not sure why. CURA-9793
This commit is contained in:
parent
df8d0e9b46
commit
540d810293
@ -58,6 +58,11 @@ RecommendedSettingSection
|
||||
{
|
||||
width: parent.width
|
||||
settingName: "infill_pattern"
|
||||
|
||||
function updateSetting(value)
|
||||
{
|
||||
Cura.MachineManager.setSettingForAllExtruders("infill_pattern", "value", value)
|
||||
}
|
||||
}
|
||||
},
|
||||
RecommendedSettingItem
|
||||
@ -76,6 +81,7 @@ RecommendedSettingSection
|
||||
{
|
||||
width: parent.width
|
||||
settingName: "wall_thickness"
|
||||
updateAllExtruders: true
|
||||
validator: Cura.FloatValidator {}
|
||||
unitText: catalog.i18nc("@label", "mm")
|
||||
}
|
||||
@ -88,6 +94,7 @@ RecommendedSettingSection
|
||||
{
|
||||
width: parent.width
|
||||
settingName: "top_bottom_thickness"
|
||||
updateAllExtruders: true
|
||||
validator: Cura.FloatValidator {}
|
||||
unitText: catalog.i18nc("@label", "mm")
|
||||
}
|
||||
|
@ -8,25 +8,29 @@ import UM 1.7 as UM
|
||||
import Cura 1.7 as Cura
|
||||
import QtQuick.Layouts 1.3
|
||||
|
||||
// This silder allows changing of a single setting. Only the setting name has to be passed in to "settingName".
|
||||
// All of the setting updating logic is handled by this component.
|
||||
// This component allows you to choose values between minValue -> maxValue and rounds them to the nearest 10.
|
||||
|
||||
RowLayout
|
||||
{
|
||||
height: childrenRect.height
|
||||
spacing: UM.Theme.getSize("default_margin").width
|
||||
|
||||
property alias settingName: settingPropertyProvider.key
|
||||
property alias settingName: propertyProvider.key
|
||||
property alias enabled: settingSlider.enabled
|
||||
|
||||
property bool roundToNearestTen: false
|
||||
property int maxValue: 100
|
||||
property int minValue: 0
|
||||
property int previousValue: -1
|
||||
|
||||
UM.SettingPropertyProvider
|
||||
{
|
||||
id: settingPropertyProvider
|
||||
id: propertyProvider
|
||||
containerStackId: Cura.MachineManager.activeStackId
|
||||
watchedProperties: [ "value" ]
|
||||
storeIndex: 0
|
||||
|
||||
}
|
||||
|
||||
UM.Label { Layout.fillWidth: false; text: minValue }
|
||||
@ -41,55 +45,56 @@ RowLayout
|
||||
from: minValue; to: maxValue; stepSize: 1
|
||||
|
||||
// set initial value from stack
|
||||
value: parseInt(settingPropertyProvider.properties.value)
|
||||
value: parseInt(propertyProvider.properties.value)
|
||||
|
||||
// When the slider is released trigger an update immediately. This forces the slider to snap to the rounded value.
|
||||
onPressedChanged: if(!pressed) { parseValueUpdateSetting() }
|
||||
onPressedChanged: if(!pressed) { roundSliderValueUpdateSetting() }
|
||||
}
|
||||
|
||||
UM.Label { Layout.fillWidth: false; text: maxValue }
|
||||
|
||||
Connections
|
||||
{
|
||||
target: settingPropertyProvider
|
||||
target: propertyProvider
|
||||
function onContainerStackChanged() { updateTimer.restart() }
|
||||
function onIsValueUsedChanged() { updateTimer.restart() }
|
||||
}
|
||||
|
||||
// Updates to the setting are delayed by interval. This stops lag caused by calling the
|
||||
// parseValueUpdateSetting() function being call repeatedly while dragging the slider.
|
||||
// Updates to the setting are delayed by interval. This reduces lag by waiting a bit after a setting change to update the slider contents.
|
||||
Timer
|
||||
{
|
||||
id: updateTimer
|
||||
interval: 100
|
||||
repeat: false
|
||||
onTriggered: parseValueUpdateSetting()
|
||||
onTriggered: parseValueUpdateSetting(false)
|
||||
}
|
||||
|
||||
function parseValueUpdateSetting()
|
||||
function updateSlider(value)
|
||||
{
|
||||
// Work around, the `settingPropertyProvider.properties.value` is initially `undefined`. As
|
||||
// `parseInt(settingPropertyProvider.properties.value)` is parsed as 0 and is initially set as
|
||||
// the slider value. By setting this 0 value an update is triggered setting the actual
|
||||
// sitting value to 0.
|
||||
if (isNaN(parseInt(settingPropertyProvider.properties.value)))
|
||||
{
|
||||
return;
|
||||
settingSlider.value = value
|
||||
}
|
||||
|
||||
// Don't update if the setting value, if the slider has the same value
|
||||
if (parseInt(settingPropertyProvider.properties.value) == settingSlider.value)
|
||||
function roundSliderValueUpdateSetting()
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Round the slider value to the nearest multiple of 10 (simulate step size of 10)
|
||||
// If the user interacts with the slider we round the value and update the setting.
|
||||
print("roundSliderValueUpdateSetting()")
|
||||
const roundedSliderValue = roundToNearestTen ? Math.round(settingSlider.value / 10) * 10 : Math.round(settingSlider.value)
|
||||
settingSlider.value = roundedSliderValue
|
||||
updateSetting(roundedSliderValue)
|
||||
}
|
||||
|
||||
// Update the slider value to represent the rounded value
|
||||
settingSlider.value = roundedSliderValue;
|
||||
|
||||
updateSetting(roundedSliderValue);
|
||||
function parseValueUpdateSetting(triggerUpdate)
|
||||
{
|
||||
// Only run when the setting value is updated by something other than the slider.
|
||||
// This sets the slider value based on the setting value, it does not update the setting value.
|
||||
|
||||
if (parseInt(propertyProvider.properties.value) == settingSlider.value)
|
||||
{
|
||||
return
|
||||
}
|
||||
|
||||
settingSlider.value = propertyProvider.properties.value
|
||||
}
|
||||
|
||||
// Override this function to update a setting differently
|
||||
|
@ -15,6 +15,10 @@ UM.TextField
|
||||
id: control
|
||||
property alias settingName: propertyProvider.key
|
||||
|
||||
// If true, all extruders will have "settingName" property updated.
|
||||
// The displayed value will be read from the first extruder instead of the machine.
|
||||
property bool updateAllExtruders: false
|
||||
|
||||
// Resolving the value in the textField.
|
||||
Binding
|
||||
{
|
||||
@ -28,6 +32,15 @@ UM.TextField
|
||||
// This stops the text being reformatted as you edit. For example "10.1" -Edit-> "10." -Auto Format-> "10.0".
|
||||
return control.text
|
||||
}
|
||||
|
||||
if (( propertyProvider.properties.resolve != "None" && propertyProvider.properties.resolve) && ( propertyProvider.properties.stackLevels[0] != 0) && ( propertyProvider.properties.stackLevels[0] != 1))
|
||||
{
|
||||
// We have a resolve function. Indicates that the setting is not settable per extruder and that
|
||||
// we have to choose between the resolved value (default) and the global value
|
||||
// (if user has explicitly set this).
|
||||
return base.resolve
|
||||
}
|
||||
|
||||
return propertyProvider.properties.value
|
||||
}
|
||||
|
||||
@ -36,8 +49,8 @@ UM.TextField
|
||||
property UM.SettingPropertyProvider propertyProvider: UM.SettingPropertyProvider
|
||||
{
|
||||
id: propertyProvider
|
||||
containerStack: Cura.MachineManager.activeMachine
|
||||
watchedProperties: [ "value", "validationState" ]
|
||||
watchedProperties: [ "value", "validationState", "resolve" ]
|
||||
containerStackId: updateAllExtruders ? Cura.ExtruderManager.extruderIds[0] : Cura.MachineManager.activeMachine
|
||||
}
|
||||
|
||||
Connections
|
||||
@ -51,7 +64,7 @@ UM.TextField
|
||||
// textfield styling while typing.
|
||||
Keys.onReleased: updateTimer.restart()
|
||||
// Forces formatting when you finish editing "10.1" -Edit-> "10." -Focus Change-> "10"
|
||||
onActiveFocusChanged: updateTime.restart()
|
||||
onActiveFocusChanged: updateTimer.restart()
|
||||
|
||||
// Updates to the setting are delayed by interval. This stops lag caused by calling the
|
||||
// parseValueUpdateSetting() function being called repeatedly while changing the text value.
|
||||
@ -65,13 +78,19 @@ UM.TextField
|
||||
|
||||
function parseValueUpdateSetting()
|
||||
{
|
||||
// Do some parsing of text here
|
||||
if (propertyProvider && text != propertyProvider.properties.value)
|
||||
{
|
||||
updateSetting(text);
|
||||
}
|
||||
}
|
||||
|
||||
function updateSetting(value)
|
||||
{
|
||||
if (propertyProvider && text != propertyProvider.properties.value)
|
||||
if (updateAllExtruders)
|
||||
{
|
||||
Cura.MachineManager.setSettingForAllExtruders(propertyProvider.key, "value", value)
|
||||
}
|
||||
else
|
||||
{
|
||||
propertyProvider.setPropertyValue("value", text)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user