From 5a698bd91fafbd2bd4b95ced7c9f4e8628fd9f23 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Tue, 9 Nov 2021 17:20:37 +0100 Subject: [PATCH] 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. --- plugins/Marketplace/resources/qml/PackageCard.qml | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/plugins/Marketplace/resources/qml/PackageCard.qml b/plugins/Marketplace/resources/qml/PackageCard.qml index ee35e6c5a0..d9a99c44d0 100644 --- a/plugins/Marketplace/resources/qml/PackageCard.qml +++ b/plugins/Marketplace/resources/qml/PackageCard.qml @@ -123,8 +123,15 @@ Rectangle { if(truncated && line.isLast) { - line.width = Math.min(line.implicitWidth, - parent.width - readMoreButton.width - fontMetrics.advanceWidth("… ")); + let max_line_width = 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; } } @@ -150,7 +157,7 @@ Rectangle Label { - text: "... " + text: "… " visible: descriptionLabel.truncated anchors.left: parent.left anchors.leftMargin: descriptionLabel.lastLineWidth