diff --git a/cura/Machines/Models/IntentCategoryModel.py b/cura/Machines/Models/IntentCategoryModel.py index d7d1ee2710..0268d067a9 100644 --- a/cura/Machines/Models/IntentCategoryModel.py +++ b/cura/Machines/Models/IntentCategoryModel.py @@ -3,7 +3,7 @@ from PyQt5.QtCore import Qt import collections -from typing import TYPE_CHECKING +from typing import TYPE_CHECKING, Optional from cura.Machines.Models.IntentModel import IntentModel from cura.Settings.IntentManager import IntentManager @@ -25,16 +25,26 @@ class IntentCategoryModel(ListModel): IntentCategoryRole = Qt.UserRole + 2 WeightRole = Qt.UserRole + 3 QualitiesRole = Qt.UserRole + 4 - - #Translations to user-visible string. Ordered by weight. - #TODO: Create a solution for this name and weight to be used dynamically. - name_translation = collections.OrderedDict() #type: "collections.OrderedDict[str,str]" - name_translation["default"] = catalog.i18nc("@label", "Default") - name_translation["engineering"] = catalog.i18nc("@label", "Engineering") - name_translation["smooth"] = catalog.i18nc("@label", "Smooth") + DescriptionRole = Qt.UserRole + 5 modelUpdated = pyqtSignal() + # Translations to user-visible string. Ordered by weight. + # TODO: Create a solution for this name and weight to be used dynamically. + _translations = collections.OrderedDict() # type: "collections.OrderedDict[str,Dict[str,Optional[str]]" + _translations["default"] = { + "name": catalog.i18nc("@label", "Default") + } + _translations["engineering"] = { + "name": catalog.i18nc("@label", "Engineering"), + "description": catalog.i18nc("@text", "An profile which is suitable for engineering work") + + } + _translations["smooth"] = { + "name": catalog.i18nc("@label", "Smooth"), + "description": catalog.i18nc("@text", "Ohhh yeah. So tender. So smooth. So Perfect.") + } + ## Creates a new model for a certain intent category. # \param The category to list the intent profiles for. def __init__(self, intent_category: str) -> None: @@ -45,6 +55,7 @@ class IntentCategoryModel(ListModel): self.addRoleName(self.IntentCategoryRole, "intent_category") self.addRoleName(self.WeightRole, "weight") self.addRoleName(self.QualitiesRole, "qualities") + self.addRoleName(self.DescriptionRole, "description") application = cura.CuraApplication.CuraApplication.getInstance() @@ -75,10 +86,18 @@ class IntentCategoryModel(ListModel): qualities = IntentModel() qualities.setIntentCategory(category) result.append({ - "name": self.name_translation.get(category, catalog.i18nc("@label", "Unknown")), + "name": IntentCategoryModel.translation(category, "name", catalog.i18nc("@label", "Unknown")), + "description": IntentCategoryModel.translation(category, "description", None), "intent_category": category, - "weight": list(self.name_translation.keys()).index(category), + "weight": list(self._translations.keys()).index(category), "qualities": qualities }) result.sort(key = lambda k: k["weight"]) self.setItems(result) + + ## Get a display value for a category. See IntenCategoryModel._translations + ## for categories and keys + @staticmethod + def translation(category: str, key: str, default: Optional[str] = None): + display_strings = IntentCategoryModel._translations.get(category, {}) + return display_strings.get(key, default) diff --git a/cura/Settings/MachineManager.py b/cura/Settings/MachineManager.py index 35f3268cce..d1f8cad4b3 100755 --- a/cura/Settings/MachineManager.py +++ b/cura/Settings/MachineManager.py @@ -1586,8 +1586,9 @@ class MachineManager(QObject): intent_category = self.activeIntentCategory if intent_category != "default": - intent_display_name = IntentCategoryModel.name_translation.get(intent_category, - catalog.i18nc("@label", "Unknown")) + intent_display_name = IntentCategoryModel.translation(intent_category, + "name", + catalog.i18nc("@label", "Unknown")) display_name = "{intent_name} - {the_rest}".format(intent_name = intent_display_name, the_rest = display_name) diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedQualityProfileSelector.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedQualityProfileSelector.qml index d1f7dd7de2..a75783d096 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedQualityProfileSelector.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedQualityProfileSelector.qml @@ -163,6 +163,25 @@ Item isCheckedFunction: checkedFunction } + + MouseArea // tooltip hover area + { + anchors.fill: parent + hoverEnabled: true + enabled: model.description !== undefined + acceptedButtons: Qt.NoButton // react to hover only, don't steal clicks + + onEntered: + { + print(model.description) + base.showTooltip( + intentCategoryLabel, + Qt.point(-(intentCategoryLabel.x - qualityRow.x) - UM.Theme.getSize("thick_margin").width, 0), + model.description + ) + } + onExited: base.hideTooltip() + } } }