diff --git a/resources/qml/Settings/SettingExtruder.qml b/resources/qml/Settings/SettingExtruder.qml index 86ab728fc1..0160dab7fa 100644 --- a/resources/qml/Settings/SettingExtruder.qml +++ b/resources/qml/Settings/SettingExtruder.qml @@ -16,17 +16,18 @@ SettingItem { id: control - model: Cura.ExtrudersModel { + model: Cura.ExtrudersModel + { id: extruders_model } - textRole: "name"; + textRole: "name" anchors.fill: parent MouseArea { - anchors.fill: parent; - acceptedButtons: Qt.NoButton; + anchors.fill: parent + acceptedButtons: Qt.NoButton onWheel: wheel.accepted = true; } @@ -38,44 +39,44 @@ SettingItem { if (!enabled) { - return UM.Theme.getColor("setting_control_disabled") + return UM.Theme.getColor("setting_control_disabled"); } if(control.hovered || base.activeFocus) { - return UM.Theme.getColor("setting_control_highlight") + return UM.Theme.getColor("setting_control_highlight"); } else { - return UM.Theme.getColor("setting_control") + return extruders_model.getItem(index).colour; } } - border.width: UM.Theme.getSize("default_lining").width; - border.color: !enabled ? UM.Theme.getColor("setting_control_disabled_border") : control.hovered ? UM.Theme.getColor("setting_control_border_highlight") : UM.Theme.getColor("setting_control_border"); + border.width: UM.Theme.getSize("default_lining").width + border.color: !enabled ? UM.Theme.getColor("setting_control_disabled_border") : control.hovered ? UM.Theme.getColor("setting_control_border_highlight") : UM.Theme.getColor("setting_control_border") } label: Item { Label { - anchors.left: parent.left; + anchors.left: parent.left anchors.leftMargin: UM.Theme.getSize("default_lining").width - anchors.right: downArrow.left; - anchors.rightMargin: UM.Theme.getSize("default_lining").width; - anchors.verticalCenter: parent.verticalCenter; + anchors.right: downArrow.left + anchors.rightMargin: UM.Theme.getSize("default_lining").width + anchors.verticalCenter: parent.verticalCenter - text: control.currentText; - font: UM.Theme.getFont("default"); - color: !enabled ? UM.Theme.getColor("setting_control_disabled_text") : UM.Theme.getColor("setting_control_text"); + text: control.currentText + font: UM.Theme.getFont("default") + color: !enabled ? UM.Theme.getColor("setting_control_disabled_text") : extruders_model.getItem(index).colour - elide: Text.ElideRight; - verticalAlignment: Text.AlignVCenter; + elide: Text.ElideRight + verticalAlignment: Text.AlignVCenter } UM.RecolorImage { id: downArrow - anchors.right: parent.right; - anchors.rightMargin: UM.Theme.getSize("default_lining").width * 2; - anchors.verticalCenter: parent.verticalCenter; + anchors.right: parent.right + anchors.rightMargin: UM.Theme.getSize("default_lining").width * 2 + anchors.verticalCenter: parent.verticalCenter source: UM.Theme.getIcon("arrow_bottom") width: UM.Theme.getSize("standard_arrow").width @@ -83,29 +84,30 @@ SettingItem sourceSize.width: width + 5 sourceSize.height: width + 5 - color: UM.Theme.getColor("setting_control_text"); - + color: UM.Theme.getColor("setting_control_text") } } } - onActivated: provider.setPropertyValue("value", extruders_model.getItem(index).index) + onActivated: provider.setPropertyValue("value", extruders_model.getItem(index).index); onModelChanged: updateCurrentIndex(); Connections { target: provider - onPropertiesChanged: control.updateCurrentIndex() + onPropertiesChanged: control.updateCurrentIndex(); } - function updateCurrentIndex() { - for(var i = 0; i < extruders_model.rowCount(); ++i) { - if(extruders_model.getItem(i).index == provider.properties.value) { + function updateCurrentIndex() + { + for(var i = 0; i < extruders_model.rowCount(); ++i) + { + if(extruders_model.getItem(i).index == provider.properties.value) + { currentIndex = i; return; } } - currentIndex = -1; } }