Truncate double ellipsis where possible

I couldn't get it to truncate it if the double ellipsis is the only text on the line, like if the description contains a white line and more than 2 lines in total. It then looks like a double ellipsis (6 dots instead of 3). Doesn't look the worst, but a bit strange, but it's really difficult to fix.

Contributes to issue CURA-8561.
This commit is contained in:
Ghostkeeper 2021-11-09 17:20:37 +01:00
parent 7b7cb43b02
commit 5a698bd91f
No known key found for this signature in database
GPG Key ID: 68F39EA88EEED5FF

View File

@ -123,8 +123,15 @@ Rectangle
{ {
if(truncated && line.isLast) if(truncated && line.isLast)
{ {
line.width = Math.min(line.implicitWidth, let max_line_width = parent.width - readMoreButton.width - fontMetrics.advanceWidth("… ");
parent.width - readMoreButton.width - fontMetrics.advanceWidth("… ")); if(line.implicitWidth > max_line_width)
{
line.width = max_line_width;
}
else
{
line.width = line.implicitWidth - fontMetrics.advanceWidth("…"); //Truncate the ellipsis. We're adding this ourselves.
}
descriptionLabel.lastLineWidth = line.implicitWidth; descriptionLabel.lastLineWidth = line.implicitWidth;
} }
} }
@ -150,7 +157,7 @@ Rectangle
Label Label
{ {
text: "... " text: " "
visible: descriptionLabel.truncated visible: descriptionLabel.truncated
anchors.left: parent.left anchors.left: parent.left
anchors.leftMargin: descriptionLabel.lastLineWidth anchors.leftMargin: descriptionLabel.lastLineWidth