From 0c668053e54811220b033e9cc696fd84ae321665 Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Thu, 12 Nov 2020 14:04:58 +0100 Subject: [PATCH 1/8] 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 From 14cf23c65fbbfea05c84f2d257eab14738e459d2 Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Mon, 26 Jul 2021 14:17:58 +0200 Subject: [PATCH 2/8] Update to new icon names --- resources/qml/Menus/ConfigurationMenu/ConfigurationMenu.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/qml/Menus/ConfigurationMenu/ConfigurationMenu.qml b/resources/qml/Menus/ConfigurationMenu/ConfigurationMenu.qml index 6517aa2d4e..b1f3f72918 100644 --- a/resources/qml/Menus/ConfigurationMenu/ConfigurationMenu.qml +++ b/resources/qml/Menus/ConfigurationMenu/ConfigurationMenu.qml @@ -74,7 +74,7 @@ Cura.ExpandablePopup anchors.leftMargin: visible ? UM.Theme.getSize("thin_margin").width : 0 anchors.verticalCenter: parent.verticalCenter - source: valueError ? UM.Theme.getIcon("cross2") : UM.Theme.getIcon("warning") + source: valueError ? UM.Theme.getIcon("Cancel") : 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 From 660cc12382785d80d18f02f704065263acd90089 Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Tue, 24 Aug 2021 17:58:50 +0200 Subject: [PATCH 3/8] Use UM.StatusIcon instead of our own --- .../ConfigurationMenu/ConfigurationMenu.qml | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/resources/qml/Menus/ConfigurationMenu/ConfigurationMenu.qml b/resources/qml/Menus/ConfigurationMenu/ConfigurationMenu.qml index b1f3f72918..5787ee97b2 100644 --- a/resources/qml/Menus/ConfigurationMenu/ConfigurationMenu.qml +++ b/resources/qml/Menus/ConfigurationMenu/ConfigurationMenu.qml @@ -6,7 +6,7 @@ import QtQuick.Controls 2.3 import QtQuick.Controls.Styles 1.4 import QtQuick.Layouts 1.3 -import UM 1.2 as UM +import UM 1.4 as UM import Cura 1.0 as Cura @@ -60,7 +60,7 @@ Cura.ExpandablePopup } // Warning icon that indicates if no qualities are available for the variant/material combination for this extruder - UM.RecolorImage + UM.StatusIcon { id: configurationWarning @@ -74,10 +74,21 @@ Cura.ExpandablePopup anchors.leftMargin: visible ? UM.Theme.getSize("thin_margin").width : 0 anchors.verticalCenter: parent.verticalCenter - source: valueError ? UM.Theme.getIcon("Cancel") : 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 + + status: + { + if (valueError) + { + return UM.StatusIcon.Status.ERROR + } + if (valueWarning) + { + return UM.StatusIcon.Status.WARNING + } + return UM.StatusIcon.Status.NEUTRAL + } } ColumnLayout From d1f21ec7c48e6c5ca19f3bad9909e1e9d3573b2b Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Tue, 16 Nov 2021 15:34:10 +0100 Subject: [PATCH 4/8] Adjust size and position of extruder warning "badges" --- .../Menus/ConfigurationMenu/ConfigurationMenu.qml | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/resources/qml/Menus/ConfigurationMenu/ConfigurationMenu.qml b/resources/qml/Menus/ConfigurationMenu/ConfigurationMenu.qml index a4fcc4265d..cd396f8169 100644 --- a/resources/qml/Menus/ConfigurationMenu/ConfigurationMenu.qml +++ b/resources/qml/Menus/ConfigurationMenu/ConfigurationMenu.qml @@ -74,11 +74,16 @@ Cura.ExpandablePopup visible: valueWarning || valueError - anchors.left: extruderIcon.right - anchors.leftMargin: visible ? UM.Theme.getSize("thin_margin").width : 0 - anchors.verticalCenter: parent.verticalCenter + anchors + { + top: extruderIcon.top + topMargin: - Math.round(height * 1 / 6) + left: extruderIcon.left + leftMargin: extruderIcon.width - Math.round(width * 5 / 6) + } - width: visible ? UM.Theme.getSize("section_icon").width : 0 + // width is set to draw the same size as the MachineSelector connectionStatusImage, which is drawn as an image instead of a statusicon + width: UM.Theme.getSize("icon_indicator").width + 2 * UM.Theme.getSize("default_lining").width height: width status: @@ -102,7 +107,7 @@ Cura.ExpandablePopup visible: width > 0 anchors { - left: configurationWarning.visible ? configurationWarning.right : extruderIcon.right + left: extruderIcon.right leftMargin: UM.Theme.getSize("default_margin").width verticalCenter: parent.verticalCenter right: parent.right From 452aa4cc1c204e8d21a1513575c815006a1385c6 Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Tue, 16 Nov 2021 16:05:02 +0100 Subject: [PATCH 5/8] Add a tooltip explaining the status of the extruder --- .../ConfigurationMenu/ConfigurationMenu.qml | 50 ++++++++++++++++--- 1 file changed, 43 insertions(+), 7 deletions(-) diff --git a/resources/qml/Menus/ConfigurationMenu/ConfigurationMenu.qml b/resources/qml/Menus/ConfigurationMenu/ConfigurationMenu.qml index cd396f8169..dc48264783 100644 --- a/resources/qml/Menus/ConfigurationMenu/ConfigurationMenu.qml +++ b/resources/qml/Menus/ConfigurationMenu/ConfigurationMenu.qml @@ -54,6 +54,10 @@ Cura.ExpandablePopup Layout.maximumWidth: Math.round(parent.width / extrudersModel.count) Layout.fillHeight: true + 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" + // Extruder icon. Shows extruder index and has the same color as the active material. Cura.ExtruderIcon { @@ -63,16 +67,48 @@ Cura.ExpandablePopup anchors.verticalCenter: parent.verticalCenter } + MouseArea // Connection status tooltip hover area + { + id: tooltipHoverArea + anchors.fill: parent + hoverEnabled: true //getConnectionStatusMessage() !== "" + acceptedButtons: Qt.NoButton // react to hover only, don't steal clicks + + onEntered: + { + base.mouseArea.entered() // we want both this and the outer area to be entered + tooltip.show() + } + onExited: { tooltip.hide() } + } + + Cura.ToolTip + { + id: tooltip + x: 0 + y: parent.height + UM.Theme.getSize("default_margin").height + width: UM.Theme.getSize("tooltip").width + targetPoint: Qt.point(Math.round(extruderIcon.width / 2), 0) + text: + { + if (parent.valueError) + { + return catalog.i18nc("@tooltip", "The configuration of this extruder is not allowed, and prohibits slicing.") + } + if (parent.valueWarning) + { + return catalog.i18nc("@tooltip", "There are no profiles matching the configuration of this extruder.") + } + return "" + } + } + // Warning icon that indicates if no qualities are available for the variant/material combination for this extruder UM.StatusIcon { 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 + visible: parent.valueWarning || parent.valueError anchors { @@ -88,11 +124,11 @@ Cura.ExpandablePopup status: { - if (valueError) + if (parent.valueError) { return UM.StatusIcon.Status.ERROR } - if (valueWarning) + if (parent.valueWarning) { return UM.StatusIcon.Status.WARNING } From 77cfd8218a1459de8840917c8da3c0e3be835eda Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Thu, 18 Nov 2021 10:23:53 +0100 Subject: [PATCH 6/8] Add warning and error badge icons --- resources/themes/cura-light/icons/low/ErrorBadge.svg | 4 ++++ resources/themes/cura-light/icons/low/WarningBadge.svg | 4 ++++ 2 files changed, 8 insertions(+) create mode 100644 resources/themes/cura-light/icons/low/ErrorBadge.svg create mode 100644 resources/themes/cura-light/icons/low/WarningBadge.svg diff --git a/resources/themes/cura-light/icons/low/ErrorBadge.svg b/resources/themes/cura-light/icons/low/ErrorBadge.svg new file mode 100644 index 0000000000..a4df126394 --- /dev/null +++ b/resources/themes/cura-light/icons/low/ErrorBadge.svg @@ -0,0 +1,4 @@ + + + + diff --git a/resources/themes/cura-light/icons/low/WarningBadge.svg b/resources/themes/cura-light/icons/low/WarningBadge.svg new file mode 100644 index 0000000000..63a77919d4 --- /dev/null +++ b/resources/themes/cura-light/icons/low/WarningBadge.svg @@ -0,0 +1,4 @@ + + + + From 9ebd8524ad7cd7db86e9d3b286b0a5a7e5f9da90 Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Thu, 18 Nov 2021 10:53:35 +0100 Subject: [PATCH 7/8] Use badge icons --- .../ConfigurationMenu/ConfigurationMenu.qml | 72 ++++++++++++++----- resources/themes/cura-light/theme.json | 4 +- 2 files changed, 57 insertions(+), 19 deletions(-) diff --git a/resources/qml/Menus/ConfigurationMenu/ConfigurationMenu.qml b/resources/qml/Menus/ConfigurationMenu/ConfigurationMenu.qml index dc48264783..5dfb3da103 100644 --- a/resources/qml/Menus/ConfigurationMenu/ConfigurationMenu.qml +++ b/resources/qml/Menus/ConfigurationMenu/ConfigurationMenu.qml @@ -50,6 +50,8 @@ Cura.ExpandablePopup model: extrudersModel delegate: Item { + id: extruderItem + Layout.preferredWidth: Math.round(parent.width / extrudersModel.count) Layout.maximumWidth: Math.round(parent.width / extrudersModel.count) Layout.fillHeight: true @@ -91,11 +93,11 @@ Cura.ExpandablePopup targetPoint: Qt.point(Math.round(extruderIcon.width / 2), 0) text: { - if (parent.valueError) + if (extruderItem.valueError) { return catalog.i18nc("@tooltip", "The configuration of this extruder is not allowed, and prohibits slicing.") } - if (parent.valueWarning) + if (extruderItem.valueWarning) { return catalog.i18nc("@tooltip", "There are no profiles matching the configuration of this extruder.") } @@ -104,35 +106,69 @@ Cura.ExpandablePopup } // Warning icon that indicates if no qualities are available for the variant/material combination for this extruder - UM.StatusIcon + UM.RecolorImage { - id: configurationWarning - - visible: parent.valueWarning || parent.valueError - + id: badge anchors { - top: extruderIcon.top + top: parent.top topMargin: - Math.round(height * 1 / 6) - left: extruderIcon.left + left: parent.left leftMargin: extruderIcon.width - Math.round(width * 5 / 6) } - // width is set to draw the same size as the MachineSelector connectionStatusImage, which is drawn as an image instead of a statusicon - width: UM.Theme.getSize("icon_indicator").width + 2 * UM.Theme.getSize("default_lining").width - height: width + width: UM.Theme.getSize("icon_indicator").width + height: UM.Theme.getSize("icon_indicator").height - status: + visible: extruderItem.valueError || extruderItem.valueWarning + + source: { - if (parent.valueError) + if (extruderItem.valueError) { - return UM.StatusIcon.Status.ERROR + return UM.Theme.getIcon("ErrorBadge", "low") } - if (parent.valueWarning) + if (extruderItem.valueWarning) { - return UM.StatusIcon.Status.WARNING + return UM.Theme.getIcon("WarningBadge", "low") + } + return "" + } + + color: + { + if (extruderItem.valueError) + { + return UM.Theme.getColor("error") + } + if (extruderItem.valueWarning) + { + return UM.Theme.getColor("warning") + } + return "transparent" + } + + // Make a themable circle in the background so we can change it in other themes + Rectangle + { + id: iconBackground + anchors.centerIn: parent + width: parent.width - 1.5 //1.5 pixels smaller, (at least sqrt(2), regardless of screen pixel scale) so that the circle doesn't show up behind the icon due to anti-aliasing. + height: parent.height - 1.5 + radius: width / 2 + z: parent.z - 1 + color: + { + if (extruderItem.valueError) + { + return UM.Theme.getColor("error_badge_background") + } + if (extruderItem.valueWarning) + { + return UM.Theme.getColor("warning_badge_background") + } + return "transparent" } - return UM.StatusIcon.Status.NEUTRAL } } diff --git a/resources/themes/cura-light/theme.json b/resources/themes/cura-light/theme.json index 9dc3d8d114..f59231d960 100644 --- a/resources/themes/cura-light/theme.json +++ b/resources/themes/cura-light/theme.json @@ -472,7 +472,9 @@ "monitor_carousel_dot_current": [119, 119, 119, 255], "cloud_unavailable": [153, 153, 153, 255], - "connection_badge_background": [255, 255, 255, 255] + "connection_badge_background": [255, 255, 255, 255], + "warning_badge_background": [0, 0, 0, 255], + "error_badge_background": [255, 255, 255, 255] }, "sizes": { From c805aac3cc9e3f659c11e8e3b5f6d0eda6e06a1c Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Fri, 19 Nov 2021 13:43:34 +0100 Subject: [PATCH 8/8] Deactivate tooltip hover if there is no tooltip to show --- resources/qml/Menus/ConfigurationMenu/ConfigurationMenu.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/qml/Menus/ConfigurationMenu/ConfigurationMenu.qml b/resources/qml/Menus/ConfigurationMenu/ConfigurationMenu.qml index 5dfb3da103..57d003b65b 100644 --- a/resources/qml/Menus/ConfigurationMenu/ConfigurationMenu.qml +++ b/resources/qml/Menus/ConfigurationMenu/ConfigurationMenu.qml @@ -73,7 +73,7 @@ Cura.ExpandablePopup { id: tooltipHoverArea anchors.fill: parent - hoverEnabled: true //getConnectionStatusMessage() !== "" + hoverEnabled: tooltip.text != "" acceptedButtons: Qt.NoButton // react to hover only, don't steal clicks onEntered: