From 20e46f4d8b093baf488aec5bbb790f5070240da8 Mon Sep 17 00:00:00 2001 From: Arjen Hiemstra Date: Wed, 17 May 2017 11:30:48 +0200 Subject: [PATCH] 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 --- resources/qml/Settings/SettingExtruder.qml | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/resources/qml/Settings/SettingExtruder.qml b/resources/qml/Settings/SettingExtruder.qml index 92d2da31e8..4a946d16f8 100644 --- a/resources/qml/Settings/SettingExtruder.qml +++ b/resources/qml/Settings/SettingExtruder.qml @@ -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 {