From b9ed619c9aba2371dc4140c36c66db19aa8bab34 Mon Sep 17 00:00:00 2001 From: Diego Prado Gesto Date: Tue, 17 Sep 2019 13:52:37 +0200 Subject: [PATCH] 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. --- resources/qml/ObjectItemButton.qml | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/resources/qml/ObjectItemButton.qml b/resources/qml/ObjectItemButton.qml index 7acfa7a7b5..b454fd929a 100644 --- a/resources/qml/ObjectItemButton.qml +++ b/resources/qml/ObjectItemButton.qml @@ -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)