From 0c668053e54811220b033e9cc696fd84ae321665 Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Thu, 12 Nov 2020 14:04:58 +0100 Subject: [PATCH] Add warning icon to show which extruder makes the configuration Not Supported --- cura/Settings/ExtruderManager.py | 27 +++++++++++++++++++ .../ConfigurationMenu/ConfigurationMenu.qml | 25 +++++++++++++++-- 2 files changed, 50 insertions(+), 2 deletions(-) diff --git a/cura/Settings/ExtruderManager.py b/cura/Settings/ExtruderManager.py index 1e9199d525..81d3f733b4 100755 --- a/cura/Settings/ExtruderManager.py +++ b/cura/Settings/ExtruderManager.py @@ -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. diff --git a/resources/qml/Menus/ConfigurationMenu/ConfigurationMenu.qml b/resources/qml/Menus/ConfigurationMenu/ConfigurationMenu.qml index a499242c94..aae964a5c8 100644 --- a/resources/qml/Menus/ConfigurationMenu/ConfigurationMenu.qml +++ b/resources/qml/Menus/ConfigurationMenu/ConfigurationMenu.qml @@ -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