CURA-4400 make extruder combobox disabled items grey

This commit is contained in:
Jack Ha 2018-03-01 16:22:40 +01:00
parent ba7b18a88b
commit 2538c689f1
3 changed files with 25 additions and 5 deletions

View File

@ -24,6 +24,8 @@ class ExtrudersModel(UM.Qt.ListModel.ListModel):
## Human-readable name of the extruder.
NameRole = Qt.UserRole + 2
## Is the extruder enabled?
EnabledRole = Qt.UserRole + 9
## Colour of the material loaded in the extruder.
ColorRole = Qt.UserRole + 3
@ -58,6 +60,7 @@ class ExtrudersModel(UM.Qt.ListModel.ListModel):
self.addRoleName(self.IdRole, "id")
self.addRoleName(self.NameRole, "name")
self.addRoleName(self.EnabledRole, "enabled")
self.addRoleName(self.ColorRole, "color")
self.addRoleName(self.IndexRole, "index")
self.addRoleName(self.DefinitionRole, "definition")
@ -185,6 +188,7 @@ class ExtrudersModel(UM.Qt.ListModel.ListModel):
item = {
"id": extruder.getId(),
"name": extruder.getName(),
"enabled": extruder.isEnabled,
"color": color,
"index": position,
"definition": extruder.getBottom().getId(),

View File

@ -811,10 +811,12 @@ class MachineManager(QObject):
def setExtruderEnabled(self, position: int, enabled) -> None:
extruder = self.getExtruder(position)
extruder.setEnabled(enabled)
if enabled == False:
self.updateDefaultExtruder()
if enabled == False:
self.correctExtruderSettings()
self.extruderChanged.emit()
# HACK to update items in SettingExtruder
ExtruderManager.getInstance().extrudersChanged.emit(self._global_container_stack.getId())
def _onMachineNameChanged(self):
self.globalContainerChanged.emit()

View File

@ -17,14 +17,22 @@ SettingItem
id: control
anchors.fill: parent
model: Cura.ExtrudersModel { onModelChanged: control.color = getItem(control.currentIndex).color }
model: Cura.ExtrudersModel {
onModelChanged: {
control.color = getItem(control.currentIndex).color;
}
}
textRole: "name"
onActivated:
{
if (model.getItem(index).enabled) {
forceActiveFocus();
propertyProvider.setPropertyValue("value", model.getItem(index).index);
} else {
currentIndex = propertyProvider.properties.value; // keep the old value
}
}
onActiveFocusChanged:
@ -173,7 +181,13 @@ SettingItem
{
text: model.name
renderType: Text.NativeRendering
color: UM.Theme.getColor("setting_control_text")
color: {
if (model.enabled) {
UM.Theme.getColor("setting_control_text")
} else {
UM.Theme.getColor("action_button_disabled_text");
}
}
font: UM.Theme.getFont("default")
elide: Text.ElideRight
verticalAlignment: Text.AlignVCenter