From 73a6c5b3138ebdf0970fca9af250561932f60f04 Mon Sep 17 00:00:00 2001 From: Michael Gregorius Date: Sun, 9 Jul 2023 17:33:35 +0200 Subject: [PATCH] Elide long parameter names Elide long parameter names if needed. --- src/gui/widgets/BarModelEditor.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/gui/widgets/BarModelEditor.cpp b/src/gui/widgets/BarModelEditor.cpp index 845a4915c..74c2e2b1f 100644 --- a/src/gui/widgets/BarModelEditor.cpp +++ b/src/gui/widgets/BarModelEditor.cpp @@ -67,8 +67,13 @@ void BarModelEditor::paintEvent(QPaintEvent *event) // Draw the text into the value rectangle but move it slightly to the right QRect const textRect = valueRect.marginsRemoved(QMargins(3, 0, 0, 0)); + + // Elide the text if needed + auto const fm = fontMetrics(); + QString const elidedText = fm.elidedText(m_text, Qt::ElideRight, textRect.width()); + painter.setPen(textColor); - painter.drawText(textRect, m_text); + painter.drawText(textRect, elidedText); } } // namespace lmms::gui