Skip to content

Commit

Permalink
Merge pull request #1284 from gqrx-sdr/elide-band-names
Browse files Browse the repository at this point in the history
Shorten band names to fit in narrow spaces
  • Loading branch information
argilo authored Sep 29, 2023
2 parents 707e6c1 + f02d325 commit af47867
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
1 change: 1 addition & 0 deletions resources/news.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
14 changes: 5 additions & 9 deletions src/qtgui/plotter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down

0 comments on commit af47867

Please sign in to comment.