Update the single setting components to optionally update all extruders when a setting is settable per extruder or limited to extruder.

This forces all extruders to have their settings updated but only displays the value from a single extruder.

CURA-9793
This commit is contained in:
Joey de l'Arago 2022-12-05 11:32:24 +01:00
parent 540d810293
commit d7e1aa08ac
4 changed files with 41 additions and 15 deletions

View file

@ -11,7 +11,7 @@ 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.
// If the setting is limited to a single extruder or is settable with different values per extruder use "updateAllExtruders: true"
RowLayout
{
height: childrenRect.height
@ -20,6 +20,12 @@ RowLayout
property alias settingName: propertyProvider.key
property alias enabled: settingSlider.enabled
// If true, all extruders will have "settingName" property updated.
// The displayed value will be read from the extruder with index "defaultExtruderIndex" instead of the machine.
property bool updateAllExtruders: false
// This is only used if updateAllExtruders == true
property int defaultExtruderIndex: 0
property bool roundToNearestTen: false
property int maxValue: 100
property int minValue: 0
@ -28,8 +34,8 @@ RowLayout
UM.SettingPropertyProvider
{
id: propertyProvider
containerStackId: Cura.MachineManager.activeStackId
watchedProperties: [ "value" ]
containerStackId: updateAllExtruders ? Cura.ExtruderManager.extruderIds[defaultExtruderIndex] : Cura.MachineManager.activeMachine.id
watchedProperties: ["value"]
storeIndex: 0
}
@ -99,6 +105,13 @@ RowLayout
// Override this function to update a setting differently
function updateSetting(value) {
propertyProvider.setPropertyValue("value", value)
if (updateAllExtruders)
{
Cura.MachineManager.setSettingForAllExtruders(propertyProvider.key, "value", value)
}
else
{
propertyProvider.setPropertyValue("value", value)
}
}
}