Add warning icon to show which extruder makes the configuration Not Supported

This commit is contained in:
fieldOfView 2020-11-12 14:04:58 +01:00
parent cd1e3bbde6
commit 0c668053e5
2 changed files with 50 additions and 2 deletions

View file

@ -12,6 +12,7 @@ from UM.Scene.SceneNode import SceneNode
from UM.Scene.Selection import Selection
from UM.Scene.Iterator.BreadthFirstIterator import BreadthFirstIterator
from UM.Settings.ContainerRegistry import ContainerRegistry # Finding containers by ID.
from cura.Machines.ContainerTree import ContainerTree
from typing import Any, cast, Dict, List, Optional, TYPE_CHECKING, Union
@ -403,6 +404,32 @@ class ExtruderManager(QObject):
raise IndexError(msg)
extruder_stack_0.definition = extruder_definition
@pyqtSlot("QVariant", result = bool)
def getExtruderHasQualityForMaterial(self, extruder_stack: "ExtruderStack") -> bool:
"""Checks if quality nodes exist for the variant/material combination."""
application = cura.CuraApplication.CuraApplication.getInstance()
global_stack = application.getGlobalContainerStack()
if not global_stack or not extruder_stack:
return False
if not global_stack.getMetaDataEntry("has_materials"):
return True
machine_node = ContainerTree.getInstance().machines[global_stack.definition.getId()]
active_variant_name = extruder_stack.variant.getMetaDataEntry("name")
if active_variant_name not in machine_node.variants:
Logger.log("w", "Could not find the variant %s", active_variant_name)
return True
active_variant_node = machine_node.variants[active_variant_name]
active_material_node = active_variant_node.materials[extruder_stack.material.getMetaDataEntry("base_file")]
active_material_node_qualities = active_material_node.qualities
if not active_material_node_qualities:
return False
return list(active_material_node_qualities.keys())[0] != "empty_quality"
@pyqtSlot(str, result="QVariant")
def getInstanceExtruderValues(self, key: str) -> List:
"""Get all extruder values for a certain setting.

View file

@ -60,6 +60,27 @@ Cura.ExpandablePopup
width: height
}
// Warning icon that indicates if no qualities are available for the variant/material combination for this extruder
UM.RecolorImage
{
id: configurationWarning
property var extruderStack: Cura.MachineManager.activeMachine.extruders[model.index]
property bool valueWarning: !Cura.ExtruderManager.getExtruderHasQualityForMaterial(extruderStack)
property bool valueError: Cura.ContainerManager.getContainerMetaDataEntry(extruderStack.material.id, "compatible", "") != "True"
visible: valueWarning || valueError
anchors.left: extruderIcon.right
anchors.leftMargin: visible ? UM.Theme.getSize("thin_margin").width : 0
anchors.verticalCenter: parent.verticalCenter
source: valueError ? UM.Theme.getIcon("cross2") : UM.Theme.getIcon("warning")
color: valueError ? UM.Theme.getColor("setting_validation_error_background") : UM.Theme.getColor("setting_validation_warning_background")
width: visible ? UM.Theme.getSize("section_icon").width : 0
height: width
}
// Label for the brand of the material
Label
{
@ -74,7 +95,7 @@ Cura.ExpandablePopup
anchors
{
top: extruderIcon.top
left: extruderIcon.right
left: configurationWarning.right
leftMargin: UM.Theme.getSize("default_margin").width
right: parent.right
rightMargin: UM.Theme.getSize("default_margin").width
@ -95,7 +116,7 @@ Cura.ExpandablePopup
anchors
{
left: extruderIcon.right
left: configurationWarning.right
leftMargin: UM.Theme.getSize("default_margin").width
top: typeAndBrandNameLabel.bottom
right: parent.right