Don't show materials if printer has no materials

But if the printer does have other configurations to change, do show a placeholder text to indicate that the configuration can be selected here.
This also simplifies a bit of code where it would need to call an updateEnabled() function, since it turns out that these properties in Cura.MachineManager have proper signals (contrary to what was previously used, the metadata entry stuff).

Contributes to issue UCRA-5876.
This commit is contained in:
Ghostkeeper 2018-12-07 13:39:42 +01:00
parent c232107e95
commit e74258c26b
No known key found for this signature in database
GPG key ID: 86BEF881AE2CF276

View file

@ -34,9 +34,11 @@ Cura.ExpandablePopup
Custom
}
enabled: Cura.MachineManager.hasMaterials || Cura.MachineManager.hasVariants || Cura.MachineManager.hasVariantBuildplates; //Only let it drop down if there is any configuration that you could change.
headerItem: Item
{
// Horizontal list that shows the extruders
// Horizontal list that shows the extruders and their materials
ListView
{
id: extrudersList
@ -44,7 +46,7 @@ Cura.ExpandablePopup
orientation: ListView.Horizontal
anchors.fill: parent
model: extrudersModel
visible: base.enabled
visible: Cura.MachineManager.hasMaterials
delegate: Item
{
@ -101,24 +103,26 @@ Cura.ExpandablePopup
}
}
}
}
//Disable the menu if there are no materials, variants or build plates to change.
function updateEnabled()
{
var active_definition_id = Cura.MachineManager.activeMachine.definition.id;
var has_materials = Cura.ContainerManager.getContainerMetaDataEntry(active_definition_id, "has_materials");
var has_variants = Cura.ContainerManager.getContainerMetaDataEntry(active_definition_id, "has_variants");
var has_buildplates = Cura.ContainerManager.getContainerMetaDataEntry(active_definition_id, "has_variant_buildplates");
base.enabled = has_materials || has_variants || has_buildplates; //Only let it drop down if there is any configuration that you could change.
}
//Placeholder text if there is a configuration to select but no materials (so we can't show the materials per extruder).
Label
{
text: catalog.i18nc("@label", "Select configuration")
elide: Text.ElideRight
font: UM.Theme.getFont("default")
color: UM.Theme.getColor("text")
renderType: Text.NativeRendering
Connections
{
target: Cura.MachineManager
onGlobalContainerChanged: base.updateEnabled();
visible: !Cura.MachineManager.hasMaterials && (Cura.MachineManager.hasVariants || Cura.MachineManager.hasVariantBuildplates)
anchors
{
left: parent.left
leftMargin: UM.Theme.getSize("default_margin").width
verticalCenter: parent.verticalCenter
}
}
}
Component.onCompleted: updateEnabled();
contentItem: Column
{