Make Extruder setting type update its color properly

The binding for the material color would not get updated properly when
the model changes. This fixes that.

Contributes to CURA-3804
This commit is contained in:
Arjen Hiemstra 2017-05-17 11:30:48 +02:00
parent a9ec3f2712
commit 20e46f4d8b

View file

@ -17,7 +17,7 @@ SettingItem
id: control
anchors.fill: parent
model: Cura.ExtrudersModel { }
model: Cura.ExtrudersModel { onModelChanged: control.color = getItem(control.currentIndex).color }
textRole: "name"
@ -36,6 +36,17 @@ SettingItem
onWheel: wheel.accepted = true;
}
property string color: "#fff"
Binding
{
// We override the color property's value when the ExtruderModel changes. So we need to use an
// explicit binding here otherwise we do not handle value changes after the model changes.
target: control
property: "color"
value: control.currentText != "" ? control.model.getItem(control.currentIndex).color : ""
}
style: ComboBoxStyle
{
background: Rectangle
@ -83,7 +94,7 @@ SettingItem
border.width: UM.Theme.getSize("default_lining").width
border.color: enabled ? UM.Theme.getColor("setting_control_border") : UM.Theme.getColor("setting_control_disabled_border")
color: control.currentText != "" ? control.model.getItem(control.currentIndex).color : ""
color: control.color
}
Label
{