mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-08-09 23:05:01 -06:00
Improved elision
It seems to correctly place the elide character now. One more detail that's incorrect is that it shows two elision characters if it's eliding due to maximum line count. I'll see what I can do... Contributes to issue CURA-8561.
This commit is contained in:
parent
57093f0ef6
commit
7b7cb43b02
1 changed files with 24 additions and 4 deletions
|
@ -112,6 +112,7 @@ Rectangle
|
|||
{
|
||||
id: descriptionLabel
|
||||
width: parent.width
|
||||
property real lastLineWidth: 0; //Store the width of the last line, to properly position the elision.
|
||||
|
||||
text: packageData.description
|
||||
maximumLineCount: 2
|
||||
|
@ -122,7 +123,9 @@ Rectangle
|
|||
{
|
||||
if(truncated && line.isLast)
|
||||
{
|
||||
line.width = Math.min(line.width, parent.width - readMoreButton.width);
|
||||
line.width = Math.min(line.implicitWidth,
|
||||
parent.width - readMoreButton.width - fontMetrics.advanceWidth("… "));
|
||||
descriptionLabel.lastLineWidth = line.implicitWidth;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -132,15 +135,26 @@ Rectangle
|
|||
id: readMoreButton
|
||||
anchors.right: parent.right
|
||||
anchors.bottom: parent.bottom
|
||||
height: authorBy.height //Height of a single line.
|
||||
height: fontMetrics.height //Height of a single line.
|
||||
|
||||
text: catalog.i18nc("@info", "Read more")
|
||||
iconSource: UM.Theme.getIcon("LinkExternal")
|
||||
|
||||
visible: descriptionLabel.truncated
|
||||
enabled: visible
|
||||
leftPadding: UM.Theme.getSize("default_margin").width
|
||||
rightPadding: 0
|
||||
rightPadding: UM.Theme.getSize("wide_margin").width
|
||||
textFont: descriptionLabel.font
|
||||
isIconOnRightSide: true
|
||||
}
|
||||
|
||||
text: catalog.i18nc("@info", "Read more")
|
||||
Label
|
||||
{
|
||||
text: "... "
|
||||
visible: descriptionLabel.truncated
|
||||
anchors.left: parent.left
|
||||
anchors.leftMargin: descriptionLabel.lastLineWidth
|
||||
anchors.bottom: readMoreButton.bottom
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -186,4 +200,10 @@ Rectangle
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
FontMetrics
|
||||
{
|
||||
id: fontMetrics
|
||||
font: UM.Theme.getFont("default")
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue