Remove the show property from the tooltip

This was a bit of a weird setup, so i removed it. This way the tooltip can be used
in the same way as the regular tooltip (by simply setting the visibility)

CURA-6004
This commit is contained in:
Jaime van Kessel 2018-12-20 16:41:26 +01:00
parent 3f599bd06f
commit 0965d909c0
3 changed files with 6 additions and 9 deletions

View File

@ -115,6 +115,6 @@ Button
Cura.ToolTip Cura.ToolTip
{ {
id: tooltip id: tooltip
show: button.hovered visible: button.hovered
} }
} }

View File

@ -9,29 +9,26 @@ import Cura 1.0 as Cura
ToolTip ToolTip
{ {
enum ContentAlignment enum ContentAlignment
{ {
AlignLeft, AlignLeft,
AlignRight AlignRight
} }
// This property indicates when the tooltip has to show, for instance when a button is hovered
property bool show: false
// Defines the alignment of the content, by default to the left // Defines the alignment of the content, by default to the left
property int contentAlignment: Cura.ToolTip.ContentAlignment.AlignRight property int contentAlignment: Cura.ToolTip.ContentAlignment.AlignRight
property alias tooltipText: tooltip.text property alias tooltipText: tooltip.text
property var targetPoint: Qt.point(parent.x, y + Math.round(height/2)) property var targetPoint: Qt.point(parent.x, y + Math.round(height/2))
id: tooltip id: tooltip
text: "" text: ""
delay: 500 delay: 500
visible: text != "" && show
font: UM.Theme.getFont("default") font: UM.Theme.getFont("default")
// If the text is not set, just set the height to 0 to prevent it from showing
height: text != "" ? label.contentHeight + 2 * UM.Theme.getSize("thin_margin").width: 0
x: x:
{ {
if (contentAlignment == Cura.ToolTip.ContentAlignment.AlignLeft) if (contentAlignment == Cura.ToolTip.ContentAlignment.AlignLeft)
@ -43,7 +40,7 @@ ToolTip
y: Math.round(parent.height / 2 - label.height / 2 ) - padding y: Math.round(parent.height / 2 - label.height / 2 ) - padding
padding: 2 padding: UM.Theme.getSize("thin_margin").width
background: UM.PointingRectangle background: UM.PointingRectangle
{ {

View File

@ -101,6 +101,6 @@ Button
{ {
id: tooltip id: tooltip
tooltipText: base.text tooltipText: base.text
show: base.hovered visible: base.hovered
} }
} }