[Default Tooltip] Fix sizing

Unset the Label's default height which completely confuses the renderer either shifting the item vertically (e.g. when toggling
system tray popup), or letting it get too wide (e.g. when moving from a two-line tooltip to a one-line tooltip).
Also let the Layouts figure out sizing rather than trying to overrule it with flaky values.

BUG: 386260
BUG: 389371

Differential Revision: https://phabricator.kde.org/D10077
This commit is contained in:
Kai Uwe Broulik 2018-01-26 15:49:06 +01:00
parent 595fd88054
commit f31e7860d9

View File

@ -66,13 +66,12 @@ Item {
} }
ColumnLayout { ColumnLayout {
Layout.maximumWidth: preferredTextWidth
PlasmaExtras.Heading { PlasmaExtras.Heading {
id: tooltipMaintext id: tooltipMaintext
level: 3 level: 3
property int _width: Math.min(implicitWidth, preferredTextWidth) Layout.fillWidth: true
Layout.minimumWidth: _width
Layout.maximumWidth: preferredTextWidth
elide: Text.ElideRight elide: Text.ElideRight
wrapMode: Text.Wrap wrapMode: Text.Wrap
text: toolTip ? toolTip.mainText : "" text: toolTip ? toolTip.mainText : ""
@ -80,9 +79,10 @@ Item {
} }
PlasmaComponents.Label { PlasmaComponents.Label {
id: tooltipSubtext id: tooltipSubtext
property int _width: Math.min(implicitWidth, preferredTextWidth) Layout.fillWidth: true
Layout.minimumWidth: _width // Unset Label default height, confuses the layout engine completely
Layout.maximumWidth: preferredTextWidth // either shifting the item vertically or letting it get too wide
height: undefined
wrapMode: Text.WordWrap wrapMode: Text.WordWrap
text: toolTip ? toolTip.subText : "" text: toolTip ? toolTip.subText : ""
textFormat: toolTip ? toolTip.textFormat : Text.AutoText textFormat: toolTip ? toolTip.textFormat : Text.AutoText