From a81b14b6cfb1da6c2be9f6bdc4f7dd12b24f42ab Mon Sep 17 00:00:00 2001 From: Michael Gregorius Date: Tue, 18 Jul 2017 19:52:17 +0200 Subject: [PATCH] Handle cases where elided text becomes empty or "..." MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Render the whole text if the elided text becomes empty or if it only contains one character, i.e. if it becomes "…". Solved as implemented because I was not able to check for "…" explicitly, i.e. the comparison against "…" still failed. --- src/core/Track.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/core/Track.cpp b/src/core/Track.cpp index a46a83a8a..ed0637a16 100644 --- a/src/core/Track.cpp +++ b/src/core/Track.cpp @@ -656,6 +656,11 @@ void TrackContentObjectView::paintTextLabel(QString const & text, QPainter & pai QFontMetrics fontMetrics(labelFont); QString elidedPatternName = fontMetrics.elidedText(text, Qt::ElideMiddle, width() - 2 * textLeft); + if (elidedPatternName.length() < 2) + { + elidedPatternName = text.trimmed(); + } + painter.fillRect(QRect(0, 0, width(), fontMetrics.height() + 2 * textTop), textBackgroundColor()); painter.setPen( textColor() );