From f02d3257c679485f58bdc6e4069f7c8dab74e630 Mon Sep 17 00:00:00 2001 From: Clayton Smith Date: Thu, 28 Sep 2023 23:45:16 -0400 Subject: [PATCH] Shorten band names to fit in narrow spaces --- resources/news.txt | 1 + src/qtgui/plotter.cpp | 14 +++++--------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/resources/news.txt b/resources/news.txt index 2f84aaf2a..ca7389787 100644 --- a/resources/news.txt +++ b/resources/news.txt @@ -28,6 +28,7 @@ IMPROVED: Use logarithmic scale for frequency zoom slider. IMPROVED: Reduced CPU utilization of demodulators. IMPROVED: Properly handle smooth scrolling. + IMPROVED: Shorten band names to fit in narrow spaces. CHANGED: Frequency zoom slider zooms around center of display. CHANGED: Disallow scrolling beyond the FFT frequency limits. CHANGED: Default narrow FM deviation increased to 5 kHz. diff --git a/src/qtgui/plotter.cpp b/src/qtgui/plotter.cpp index 7894794e9..eac37ee64 100644 --- a/src/qtgui/plotter.cpp +++ b/src/qtgui/plotter.cpp @@ -2114,15 +2114,11 @@ void CPlotter::drawOverlay() int band_width = band_right - band_left; QRectF rect(band_left, xAxisTop - m_BandPlanHeight, band_width, m_BandPlanHeight); painter.fillRect(rect, band.color); - QString band_label = band.name + " (" + band.modulation + ")"; - qreal textWidth = metrics.boundingRect(band_label).width(); - if (band_left < w && band_width > textWidth + 20) - { - painter.setOpacity(1.0); - QRectF textRect(band_left, xAxisTop - m_BandPlanHeight, band_width, metrics.height()); - painter.setPen(QPen(QColor(PLOTTER_TEXT_COLOR), m_DPR)); - painter.drawText(textRect, Qt::AlignCenter, band_label); - } + QString band_label = metrics.elidedText(band.name + " (" + band.modulation + ")", Qt::ElideRight, band_width - 10); + painter.setOpacity(1.0); + QRectF textRect(band_left, xAxisTop - m_BandPlanHeight, band_width, metrics.height()); + painter.setPen(QPen(QColor(PLOTTER_TEXT_COLOR), m_DPR)); + painter.drawText(textRect, Qt::AlignCenter, band_label); } }