Reuse the Cura ToolTip while showing long object item

It will only show the tooltip when the text is longer than the elided text.

Contributes to CURA-6666.
This commit is contained in:
Diego Prado Gesto 2019-09-17 13:52:37 +02:00
parent fd452e74b3
commit b9ed619c9a

View File

@ -51,21 +51,20 @@ Button
border.color: objectItemButton.checked ? UM.Theme.getColor("primary") : "transparent"
}
ToolTip
TextMetrics
{
visible: hovered
delay: 1000
id: buttonTextMetrics
text: buttonText.text
font: buttonText.font
elide: buttonText.elide
elideWidth: buttonText.width
}
contentItem: Text
{
text: objectItemButton.text
font: UM.Theme.getFont("default")
color: UM.Theme.getColor("tooltip_text")
}
background: Rectangle
{
color: UM.Theme.getColor("tooltip")
}
Cura.ToolTip
{
id: tooltip
tooltipText: objectItemButton.text
visible: objectItemButton.hovered && buttonTextMetrics.elidedText != buttonText.text
}
onClicked: Cura.SceneController.changeSelection(index)