From 74727469f0593603f27c5408b3c694b687d601d2 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Sat, 9 Feb 2019 17:47:06 +0100 Subject: [PATCH] Ref T534, fixed/improved settings component * allow to set counts as info (see if something is filtered) * used Qt::QueuedConnection to not override changes in same step from toggled signal * set radio button correctly --- .../settingsatcstationsinlinecomponent.cpp | 26 ++++++++++++++++--- .../settingsatcstationsinlinecomponent.h | 3 +++ 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/blackgui/components/settingsatcstationsinlinecomponent.cpp b/src/blackgui/components/settingsatcstationsinlinecomponent.cpp index 1d43e3017..54fe95146 100644 --- a/src/blackgui/components/settingsatcstationsinlinecomponent.cpp +++ b/src/blackgui/components/settingsatcstationsinlinecomponent.cpp @@ -12,6 +12,7 @@ #include #include +#include using namespace BlackGui::Settings; @@ -24,9 +25,9 @@ namespace BlackGui ui(new Ui::CSettingsAtcStationsInlineComponent) { ui->setupUi(this); - connect(ui->rb_InRange, &QRadioButton::toggled, this, &CSettingsAtcStationsInlineComponent::changeSettings); - connect(ui->cb_Frequency, &QRadioButton::released, this, &CSettingsAtcStationsInlineComponent::changeSettings); - connect(ui->cb_VoiceRoom, &QRadioButton::released, this, &CSettingsAtcStationsInlineComponent::changeSettings); + connect(ui->rb_InRange, &QRadioButton::toggled, this, &CSettingsAtcStationsInlineComponent::changeSettings, Qt::QueuedConnection); + connect(ui->cb_Frequency, &QRadioButton::released, this, &CSettingsAtcStationsInlineComponent::changeSettings, Qt::QueuedConnection); + connect(ui->cb_VoiceRoom, &QRadioButton::released, this, &CSettingsAtcStationsInlineComponent::changeSettings, Qt::QueuedConnection); QPointer myself(this); QTimer::singleShot(2000, this, [ = ] @@ -39,10 +40,27 @@ namespace BlackGui CSettingsAtcStationsInlineComponent::~CSettingsAtcStationsInlineComponent() { } + void CSettingsAtcStationsInlineComponent::setCounts(int all, int inRange) + { + static const QString sAll = ui->rb_All->text(); + static const QString sInRange = ui->rb_InRange->text(); + + ui->rb_All->setText(all < 0 ? sAll : sAll % QStringLiteral(" (%1)").arg(all)); + ui->rb_InRange->setText(inRange < 0 ? sInRange : sInRange % QStringLiteral(" (%1)").arg(inRange)); + } + void CSettingsAtcStationsInlineComponent::onSettingsChanged() { const CAtcStationsSettings s = m_atcSettings.getThreadLocal(); - ui->rb_InRange->setChecked(s.showOnlyInRange()); + if (s.showOnlyInRange()) + { + ui->rb_InRange->setChecked(true); + } + else + { + ui->rb_All->setChecked(true); + } + ui->cb_Frequency->setChecked(s.showOnlyWithValidFrequency()); ui->cb_VoiceRoom->setChecked(s.showOnlyWithValidVoiceRoom()); } diff --git a/src/blackgui/components/settingsatcstationsinlinecomponent.h b/src/blackgui/components/settingsatcstationsinlinecomponent.h index 86101b01d..1204564b0 100644 --- a/src/blackgui/components/settingsatcstationsinlinecomponent.h +++ b/src/blackgui/components/settingsatcstationsinlinecomponent.h @@ -37,6 +37,9 @@ namespace BlackGui //! Get the settings Settings::CAtcStationsSettings getSettings() const { return m_atcSettings.get(); } + //! Set count information + void setCounts(int all, int inRange); + signals: //! Changed value void changed();