Remove unnecessary placeholder

Text.implicitWidth holds the size the text would be if it wasn't
truncated
This commit is contained in:
David Edmundson 2014-05-28 15:26:48 +02:00
parent d33aa6dfdf
commit 78684c46cd
2 changed files with 72 additions and 9 deletions

View File

@ -71,18 +71,10 @@ Row {
x: _s x: _s
y: _s y: _s
//This instance is purely for metrics
PlasmaExtras.Heading {
id: tooltipMaintextPlaceholder
visible: false
level: 3
text: toolTip ? toolTip.mainText : ""
}
PlasmaExtras.Heading { PlasmaExtras.Heading {
id: tooltipMaintext id: tooltipMaintext
level: 3 level: 3
width: Math.min(tooltipMaintextPlaceholder.width, preferredTextWidth) width: Math.min(tooltipMaintext.implicitWidth, preferredTextWidth)
//width: 400
elide: Text.ElideRight elide: Text.ElideRight
text: toolTip ? toolTip.mainText : "" text: toolTip ? toolTip.mainText : ""
} }

71
tests/tooltip.qml Normal file
View File

@ -0,0 +1,71 @@
import QtQuick 2.2
import org.kde.plasma.core 2.0 as PlasmaCore
Rectangle {
color: "white"
width: 600
height: 800
Column {
anchors.centerIn: parent
spacing: 4
PlasmaCore.ToolTipArea {
width: 300
height: 50
mainText: "This is some really really really really long text that should be truncated"
subText: "subtext"
Rectangle {
color: "red"
anchors.fill: parent
}
Text {
anchors.fill: parent
text: "long tooltip"
}
}
PlasmaCore.ToolTipArea {
width: 300
height: 50
mainText: "A"
subText: "B"
Rectangle {
color: "red"
anchors.fill: parent
}
Text {
anchors.fill: parent
text: "short tooltip"
}
}
PlasmaCore.ToolTipArea {
width: 300
height: 50
mainText: "A"
subText: "Lorem ipsum dolor sit amet, consectetur adipiscing spaghetti italiano random cheesecake blah blah"
Rectangle {
color: "red"
anchors.fill: parent
}
Text {
anchors.fill: parent
text: "long subtext"
}
}
}
}