1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2026-06-03 06:24:48 -04:00

freqdisplay: add font family combo box and transparent background toggle

Agent-Logs-Url: https://github.com/srcejon/sdrangel/sessions/b4da7187-ba56-4943-ae14-800f326fb72b

Co-authored-by: srcejon <57259258+srcejon@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-04-18 16:28:15 +00:00
committed by GitHub
parent 5df45136f7
commit f5a3dce168
5 changed files with 110 additions and 1 deletions
+53 -1
View File
@@ -3,6 +3,7 @@
#include <QResizeEvent>
#include "channel/channelwebapiutils.h"
#include "gui/buttonswitch.h"
#include "feature/featureuiset.h"
@@ -82,6 +83,8 @@ FreqDisplayGUI::FreqDisplayGUI(PluginAPI* pluginAPI, FeatureUISet *featureUISet,
m_availableChannelOrFeatureHandler.scanAvailableChannelsAndFeatures();
connect(ui->channels, qOverload<int>(&QComboBox::currentIndexChanged), this, &FreqDisplayGUI::on_channels_currentIndexChanged);
connect(ui->fontFamily, &QFontComboBox::currentFontChanged, this, &FreqDisplayGUI::on_fontFamily_currentFontChanged);
connect(ui->transparentBackground, &ButtonSwitch::toggled, this, &FreqDisplayGUI::on_transparentBackground_toggled);
connect(&m_pollTimer, &QTimer::timeout, this, &FreqDisplayGUI::pollSelectedChannel);
m_pollTimer.start(pollIntervalMs);
@@ -105,6 +108,18 @@ void FreqDisplayGUI::displaySettings()
setWindowTitle(m_settings.m_title);
setTitle(m_settings.m_title);
// Populate font combo box with the saved font (or system default if empty)
ui->fontFamily->blockSignals(true);
if (!m_settings.m_fontName.isEmpty()) {
ui->fontFamily->setCurrentFont(QFont(m_settings.m_fontName));
}
ui->fontFamily->blockSignals(false);
ui->transparentBackground->blockSignals(true);
ui->transparentBackground->setChecked(m_settings.m_transparentBackground);
ui->transparentBackground->blockSignals(false);
applyTransparency();
updateChannelList();
}
@@ -119,6 +134,8 @@ void FreqDisplayGUI::applySettings(bool force)
settingsKeys.append("selectedChannel");
settingsKeys.append("workspaceIndex");
settingsKeys.append("geometryBytes");
settingsKeys.append("fontName");
settingsKeys.append("transparentBackground");
m_freqDisplay->applySettings(m_settings, settingsKeys, force);
}
@@ -247,9 +264,14 @@ void FreqDisplayGUI::updateFrequencyFont()
return;
}
// Build a font with the user-chosen family (or the widget's current family if none saved)
QFont font = ui->frequencyValue->font();
if (!m_settings.m_fontName.isEmpty()) {
font.setFamily(m_settings.m_fontName);
}
// Probe at a large reference size to get accurate text dimensions, then
// scale linearly to find the largest point size that fits in both directions.
QFont font = ui->frequencyValue->font();
constexpr int probeSize = 200;
font.setPointSize(probeSize);
const QFontMetrics fm(font);
@@ -267,6 +289,36 @@ void FreqDisplayGUI::updateFrequencyFont()
ui->frequencyValue->setFont(font);
}
void FreqDisplayGUI::applyTransparency()
{
if (m_settings.m_transparentBackground)
{
// Make the content area and frequency label fully transparent so that
// only the text is visible over whatever is behind the window.
ui->settingsContainer->setStyleSheet("background-color: transparent;");
ui->frequencyValue->setStyleSheet("background-color: transparent;");
}
else
{
ui->settingsContainer->setStyleSheet(QString());
ui->frequencyValue->setStyleSheet(QString());
}
}
void FreqDisplayGUI::on_fontFamily_currentFontChanged(const QFont& font)
{
m_settings.m_fontName = font.family();
applySettings();
updateFrequencyFont();
}
void FreqDisplayGUI::on_transparentBackground_toggled(bool checked)
{
m_settings.m_transparentBackground = checked;
applyTransparency();
applySettings();
}
void FreqDisplayGUI::resizeEvent(QResizeEvent *event)
{
FeatureGUI::resizeEvent(event);