Add tooltips for intent profiles to the Custom Quality panel.

The description is optional.
Tooltip will not show if no description is set

CURA-6853
This commit is contained in:
Nino van Hooff 2019-10-17 17:17:06 +02:00
parent 3709cfa4ed
commit b182830c21
3 changed files with 21 additions and 3 deletions

View file

@ -37,7 +37,7 @@ class IntentCategoryModel(ListModel):
} }
_translations["engineering"] = { _translations["engineering"] = {
"name": catalog.i18nc("@label", "Engineering"), "name": catalog.i18nc("@label", "Engineering"),
"description": catalog.i18nc("@text", "An profile which is suitable for engineering work") "description": catalog.i18nc("@text", "A profile which is suitable for engineering work")
} }
_translations["smooth"] = { _translations["smooth"] = {

View file

@ -70,12 +70,31 @@ Popup
{ {
id: headerLabel id: headerLabel
text: model.name text: model.name
color: UM.Theme.getColor("text_inactive")
renderType: Text.NativeRendering renderType: Text.NativeRendering
width: parent.width
height: visible ? contentHeight: 0 height: visible ? contentHeight: 0
enabled: false
visible: qualitiesList.visibleChildren.length > 0 visible: qualitiesList.visibleChildren.length > 0
anchors.left: parent.left anchors.left: parent.left
anchors.leftMargin: UM.Theme.getSize("default_margin").width anchors.leftMargin: UM.Theme.getSize("default_margin").width
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:
{
base.showTooltip(
headerLabel,
Qt.point(- UM.Theme.getSize("default_margin").width, 0),
model.description
)
}
onExited: base.hideTooltip()
}
} }
Column Column

View file

@ -173,7 +173,6 @@ Item
onEntered: onEntered:
{ {
print(model.description)
base.showTooltip( base.showTooltip(
intentCategoryLabel, intentCategoryLabel,
Qt.point(-(intentCategoryLabel.x - qualityRow.x) - UM.Theme.getSize("thick_margin").width, 0), Qt.point(-(intentCategoryLabel.x - qualityRow.x) - UM.Theme.getSize("thick_margin").width, 0),