From aa9329cf5db10361403a9108923c6d2d12457dcc Mon Sep 17 00:00:00 2001 From: Lars Toenning Date: Mon, 17 Jun 2024 20:42:33 +0200 Subject: [PATCH] refactor: Remove inline ATC settings (all/in range, valid freqs.) Fixes #193 --- src/blackgui/CMakeLists.txt | 6 -- .../components/atcstationcomponent.cpp | 20 ----- src/blackgui/components/atcstationcomponent.h | 4 - .../components/atcstationcomponent.ui | 18 +---- .../copysettingsandcachescomponent.cpp | 16 ---- .../copysettingsandcachescomponent.h | 2 - .../copysettingsandcachescomponent.ui | 8 -- .../settingsatcstationsinlinecomponent.cpp | 70 ---------------- .../settingsatcstationsinlinecomponent.h | 53 ------------ .../settingsatcstationsinlinecomponent.ui | 76 ----------------- src/blackgui/registermetadata.cpp | 2 - src/blackgui/settings/atcstationssettings.cpp | 49 ----------- src/blackgui/settings/atcstationssettings.h | 81 ------------------- 13 files changed, 1 insertion(+), 404 deletions(-) delete mode 100644 src/blackgui/components/settingsatcstationsinlinecomponent.cpp delete mode 100644 src/blackgui/components/settingsatcstationsinlinecomponent.h delete mode 100644 src/blackgui/components/settingsatcstationsinlinecomponent.ui delete mode 100644 src/blackgui/settings/atcstationssettings.cpp delete mode 100644 src/blackgui/settings/atcstationssettings.h diff --git a/src/blackgui/CMakeLists.txt b/src/blackgui/CMakeLists.txt index bf820f254..90e37131d 100644 --- a/src/blackgui/CMakeLists.txt +++ b/src/blackgui/CMakeLists.txt @@ -409,7 +409,6 @@ add_library(gui SHARED components/commandinput.h components/configsimulatorcomponent.ui components/datamaininfoareacomponent.cpp - components/settingsatcstationsinlinecomponent.cpp components/applicationclosedialog.cpp components/settingshotkeycomponent.h components/datamaininfoareacomponent.h @@ -550,7 +549,6 @@ add_library(gui SHARED components/dbcountryselectorcomponent.ui components/dbusserveraddressselector.h components/copysettingsandcachescomponent.cpp - components/settingstextmessageinlinecomponent.ui components/colorselector.ui components/dbusserveraddressselector.cpp components/audioadvanceddistributedcomponent.h @@ -622,7 +620,6 @@ add_library(gui SHARED components/texteditdialog.cpp components/dbairlineicaoselectorbase.cpp components/aircraftmodelstringcompleter.h - components/settingsatcstationsinlinecomponent.ui components/modelbrowserdialog.cpp components/airportdialog.cpp components/rawfsdmessagescomponent.ui @@ -657,7 +654,6 @@ add_library(gui SHARED components/dblogincomponent.cpp components/aircraftmodelsetvalidationdialog.h components/audiodevicevolumesetupcomponent.cpp - components/settingsatcstationsinlinecomponent.h components/aboutdialog.h components/textmessagecomponent.ui components/aircraftmodelsetvalidationdialog.cpp @@ -904,10 +900,8 @@ add_library(gui SHARED settings/navigatorsettings.cpp settings/guisettings.cpp settings/textmessagesettings.h - settings/atcstationssettings.h settings/dockwidgetsettings.cpp settings/textmessagesettings.cpp - settings/atcstationssettings.cpp managedstatusbar.cpp sharedstringlistcompleter.cpp overlaymessages.ui diff --git a/src/blackgui/components/atcstationcomponent.cpp b/src/blackgui/components/atcstationcomponent.cpp index 50ea06d59..705963fce 100644 --- a/src/blackgui/components/atcstationcomponent.cpp +++ b/src/blackgui/components/atcstationcomponent.cpp @@ -101,8 +101,6 @@ namespace BlackGui::Components connect(ui->tvp_AtcStationsOnlineTree, &CAtcStationTreeView::objectSelected, this, &CAtcStationComponent::onOnlineAtcStationSelected, Qt::QueuedConnection); connect(ui->tvp_AtcStationsOnlineTree, &CAtcStationTreeView::requestTextMessageWidget, this, &CAtcStationComponent::requestTextMessageWidget); - connect(ui->comp_AtcStationsSettings, &CSettingsAtcStationsInlineComponent::changed, this, &CAtcStationComponent::forceUpdate, Qt::QueuedConnection); - connect(ui->tb_AtcStationsAtisReload, &QPushButton::clicked, this, &CAtcStationComponent::requestAtisUpdates); connect(&m_updateTimer, &QTimer::timeout, this, &CAtcStationComponent::update); @@ -164,12 +162,6 @@ namespace BlackGui::Components return c && parentDockableWidget; } - void CAtcStationComponent::forceUpdate() - { - m_timestampOnlineStationsChanged = QDateTime::currentDateTimeUtc(); - this->update(); - } - void CAtcStationComponent::update() { if (!this->canAccessContext()) { return; } @@ -190,25 +182,14 @@ namespace BlackGui::Components // update if (m_timestampOnlineStationsChanged > m_timestampLastReadOnlineStations) { - const CAtcStationsSettings settings = ui->comp_AtcStationsSettings->getSettings(); CAtcStationList onlineStations = sGui->getIContextNetwork()->getAtcStationsOnline(true); const int allStationsCount = onlineStations.sizeInt(); - int inRangeCount = -1; - - if (settings.showOnlyWithValidFrequency()) { onlineStations = onlineStations.stationsWithValidFrequency(); } - if (settings.showOnlyInRange()) - { - onlineStations.removeIfOutsideRange(); - inRangeCount = onlineStations.sizeInt(); - } - const int stationsCount = onlineStations.sizeInt(); ui->tvp_AtcStationsOnline->updateContainerMaybeAsync(onlineStations); m_timestampLastReadOnlineStations = QDateTime::currentDateTimeUtc(); m_timestampOnlineStationsChanged = m_timestampLastReadOnlineStations; this->updateTreeView(); this->setOnlineTabs(allStationsCount, stationsCount); - ui->comp_AtcStationsSettings->setCounts(allStationsCount, inRangeCount); if (stationsCount < 1 && allStationsCount > 0) { @@ -480,7 +461,6 @@ namespace BlackGui::Components } ui->te_AtcStationsOnlineInfo->setVisible(checked); - ui->comp_AtcStationsSettings->setVisible(checked); ui->le_AtcStationsOnlineMetar->setVisible(checked); ui->tb_AtcStationsAtisReload->setVisible(checked); ui->tb_AtcStationsLoadMetar->setVisible(checked); diff --git a/src/blackgui/components/atcstationcomponent.h b/src/blackgui/components/atcstationcomponent.h index 25b20e1af..ddb0f31b8 100644 --- a/src/blackgui/components/atcstationcomponent.h +++ b/src/blackgui/components/atcstationcomponent.h @@ -7,7 +7,6 @@ #define BLACKGUI_COMPONENTS_ATCSTATIONCOMPONENT_H #include "blackgui/settings/viewupdatesettings.h" -#include "blackgui/settings/atcstationssettings.h" #include "blackgui/overlaymessagesframe.h" #include "blackgui/blackguiexport.h" #include "blackmisc/aviation/atcstation.h" @@ -84,9 +83,6 @@ namespace BlackGui void requestAudioWidget(); private: - //! Set timestampd and call update - void forceUpdate(); - //! ATC station disconnected void atcStationDisconnected(const BlackMisc::Aviation::CAtcStation &station); diff --git a/src/blackgui/components/atcstationcomponent.ui b/src/blackgui/components/atcstationcomponent.ui index ecf46be7d..03178299f 100644 --- a/src/blackgui/components/atcstationcomponent.ui +++ b/src/blackgui/components/atcstationcomponent.ui @@ -123,7 +123,7 @@ - Details (METAR, ATIS, range) + Details (METAR, ATIS) true @@ -141,16 +141,6 @@ 3 - - - - - 0 - 25 - - - - @@ -265,12 +255,6 @@ QTableView
blackgui/views/atcstationview.h
- - BlackGui::Components::CSettingsAtcStationsInlineComponent - QFrame -
blackgui/components/settingsatcstationsinlinecomponent.h
- 1 -
BlackGui::Views::CAtcStationTreeView QTreeView diff --git a/src/blackgui/components/copysettingsandcachescomponent.cpp b/src/blackgui/components/copysettingsandcachescomponent.cpp index 98ed52bd0..e3c2335aa 100644 --- a/src/blackgui/components/copysettingsandcachescomponent.cpp +++ b/src/blackgui/components/copysettingsandcachescomponent.cpp @@ -70,7 +70,6 @@ namespace BlackGui::Components readOnlyCheckbox(ui->cb_SettingsActionHotkeys, !CCacheSettingsUtils::hasOtherVersionSettingsFile(info, m_settingsActionHotkeys.getFilename())); readOnlyCheckbox(ui->cb_SettingsTextMessages, !CCacheSettingsUtils::hasOtherVersionSettingsFile(info, m_settingsTextMessage.getFilename())); - readOnlyCheckbox(ui->cb_SettingsAtcStations, !CCacheSettingsUtils::hasOtherVersionSettingsFile(info, m_settingsAtcStations.getFilename())); readOnlyCheckbox(ui->cb_SettingsDirectories, !CCacheSettingsUtils::hasOtherVersionSettingsFile(info, m_settingsDirectories.getFilename())); readOnlyCheckbox(ui->cb_SettingsConsolidation, !CCacheSettingsUtils::hasOtherVersionSettingsFile(info, m_settingsConsolidation.getFilename())); @@ -119,7 +118,6 @@ namespace BlackGui::Components void CCopySettingsAndCachesComponent::initMisc() { ui->cb_SettingsActionHotkeys->setText(checkBoxText(TActionHotkeys::humanReadable(), true)); - ui->cb_SettingsAtcStations->setText(checkBoxText(TAtcStationsSettings::humanReadable(), true)); ui->cb_SettingsTextMessages->setText(checkBoxText(TextMessageSettings::humanReadable(), true)); ui->cb_SettingsDirectories->setText(checkBoxText(TDirectorySettings::humanReadable(), true)); } @@ -362,20 +360,6 @@ namespace BlackGui::Components } } - if (ui->cb_SettingsAtcStations->isChecked()) - { - const QString joStr = CCacheSettingsUtils::otherVersionSettingsFileContent(otherVersionInfo, m_settingsAtcStations.getFilename()); - if (!joStr.isEmpty()) - { - const CAtcStationsSettings settings = CAtcStationsSettings::fromJsonNoThrow(joStr, true, success, errMsg); - if (this->parsingMessage(success, errMsg, m_settingsAtcStations.getKey())) - { - this->displayStatusMessage(m_settingsAtcStations.setAndSave(settings), settings.toQString(true)); - copied++; - } - } - } - if (ui->cb_SettingsTextMessages->isChecked()) { const QString joStr = CCacheSettingsUtils::otherVersionSettingsFileContent(otherVersionInfo, m_settingsTextMessage.getFilename()); diff --git a/src/blackgui/components/copysettingsandcachescomponent.h b/src/blackgui/components/copysettingsandcachescomponent.h index 8c7fac22c..2444ba60a 100644 --- a/src/blackgui/components/copysettingsandcachescomponent.h +++ b/src/blackgui/components/copysettingsandcachescomponent.h @@ -10,7 +10,6 @@ #include "blackgui/settings/dockwidgetsettings.h" #include "blackgui/settings/viewupdatesettings.h" #include "blackgui/settings/textmessagesettings.h" -#include "blackgui/settings/atcstationssettings.h" #include "blackgui/overlaymessagesframe.h" #include "blackgui/blackguiexport.h" #include "blackcore/data/launchersetup.h" @@ -116,7 +115,6 @@ namespace BlackGui::Components BlackMisc::CSetting m_settingsDockWidget { this }; BlackMisc::CSetting m_settingsViewUpdate { this }; BlackMisc::CSetting m_settingsConsolidation { this }; //!< consolidation time - BlackMisc::CSetting m_settingsAtcStations { this }; BlackMisc::CSetting m_settingsTextMessage { this }; BlackMisc::CSetting m_settingsEnabledSimulators { this }; BlackMisc::CSetting m_settingsActionHotkeys { this }; diff --git a/src/blackgui/components/copysettingsandcachescomponent.ui b/src/blackgui/components/copysettingsandcachescomponent.ui index 55672f1e4..c2b21105d 100644 --- a/src/blackgui/components/copysettingsandcachescomponent.ui +++ b/src/blackgui/components/copysettingsandcachescomponent.ui @@ -222,13 +222,6 @@
- - - - ATC stations - - - @@ -351,7 +344,6 @@ cb_SettingsConsolidation cb_SettingsActionHotkeys cb_SettingsDirectories - cb_SettingsAtcStations cb_SettingsTextMessages le_Status pb_DeselectAll diff --git a/src/blackgui/components/settingsatcstationsinlinecomponent.cpp b/src/blackgui/components/settingsatcstationsinlinecomponent.cpp deleted file mode 100644 index 8f73e916e..000000000 --- a/src/blackgui/components/settingsatcstationsinlinecomponent.cpp +++ /dev/null @@ -1,70 +0,0 @@ -// SPDX-FileCopyrightText: Copyright (C) 2016 swift Project Community / Contributors -// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1 - -#include "settingsatcstationsinlinecomponent.h" -#include "ui_settingsatcstationsinlinecomponent.h" - -#include -#include -#include - -using namespace BlackGui::Settings; - -namespace BlackGui::Components -{ - CSettingsAtcStationsInlineComponent::CSettingsAtcStationsInlineComponent(QWidget *parent) : QFrame(parent), - ui(new Ui::CSettingsAtcStationsInlineComponent) - { - ui->setupUi(this); - ui->rb_All->setChecked(true); // default for AFV - - connect(ui->rb_InRange, &QRadioButton::toggled, this, &CSettingsAtcStationsInlineComponent::changeSettings, Qt::QueuedConnection); - connect(ui->cb_Frequency, &QRadioButton::released, this, &CSettingsAtcStationsInlineComponent::changeSettings, Qt::QueuedConnection); - - QPointer myself(this); - QTimer::singleShot(2000, this, [=] { - if (!myself) { return; } - this->onSettingsChanged(); - }); - } - - 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(); - if (s.showOnlyInRange()) - { - ui->rb_InRange->setChecked(true); - } - else - { - ui->rb_All->setChecked(true); - } - - ui->cb_Frequency->setChecked(s.showOnlyWithValidFrequency()); - } - - void CSettingsAtcStationsInlineComponent::changeSettings() - { - const bool onlyInRange = ui->rb_InRange->isChecked(); - const bool freq = ui->cb_Frequency->isChecked(); - CAtcStationsSettings s = m_atcSettings.getThreadLocal(); - const CAtcStationsSettings oldSettings = s; - s.setShowOnlyInRange(onlyInRange); - s.setShowOnlyWithValidFrequency(freq); - if (oldSettings == s) { return; } - m_atcSettings.setAndSave(s); - emit this->changed(); - } -} // ns diff --git a/src/blackgui/components/settingsatcstationsinlinecomponent.h b/src/blackgui/components/settingsatcstationsinlinecomponent.h deleted file mode 100644 index 6057013f6..000000000 --- a/src/blackgui/components/settingsatcstationsinlinecomponent.h +++ /dev/null @@ -1,53 +0,0 @@ -// SPDX-FileCopyrightText: Copyright (C) 2016 swift Project Community / Contributors -// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1 - -//! \file - -#ifndef BLACKGUI_COMPONENTS_SETTINGSATCSTATIONSINLINECOMPONENT_H -#define BLACKGUI_COMPONENTS_SETTINGSATCSTATIONSINLINECOMPONENT_H - -#include "blackgui/settings/atcstationssettings.h" -#include - -namespace Ui -{ - class CSettingsAtcStationsInlineComponent; -} -namespace BlackGui::Components -{ - /*! - * How ATC stations will be displayed - */ - class CSettingsAtcStationsInlineComponent : public QFrame - { - Q_OBJECT - - public: - //! Constructor - explicit CSettingsAtcStationsInlineComponent(QWidget *parent = nullptr); - - //! Destructor - virtual ~CSettingsAtcStationsInlineComponent(); - - //! 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(); - - private: - //! Settings have been changed - void onSettingsChanged(); - - //! Change the settings - void changeSettings(); - - QScopedPointer ui; - BlackMisc::CSetting m_atcSettings { this, &CSettingsAtcStationsInlineComponent::onSettingsChanged }; - }; -} // ns -#endif // guard diff --git a/src/blackgui/components/settingsatcstationsinlinecomponent.ui b/src/blackgui/components/settingsatcstationsinlinecomponent.ui deleted file mode 100644 index f38617c97..000000000 --- a/src/blackgui/components/settingsatcstationsinlinecomponent.ui +++ /dev/null @@ -1,76 +0,0 @@ - - - CSettingsAtcStationsInlineComponent - - - - 0 - 0 - 291 - 24 - - - - ATC stations settings - - - - 2 - - - 2 - - - 2 - - - 2 - - - - - valid frequencies only - - - freq. only - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - all - - - true - - - - - - - in range - - - false - - - - - - - - diff --git a/src/blackgui/registermetadata.cpp b/src/blackgui/registermetadata.cpp index 52fe5f50b..fbf44231d 100644 --- a/src/blackgui/registermetadata.cpp +++ b/src/blackgui/registermetadata.cpp @@ -7,7 +7,6 @@ #include "blackgui/settings/viewupdatesettings.h" #include "blackgui/settings/guisettings.h" #include "blackgui/settings/textmessagesettings.h" -#include "blackgui/settings/atcstationssettings.h" #include "blackgui/components/registermetadatacomponents.h" namespace BlackGui @@ -19,7 +18,6 @@ namespace BlackGui BlackGui::Settings::CViewUpdateSettings::registerMetadata(); BlackGui::Settings::CGeneralGuiSettings::registerMetadata(); BlackGui::Settings::CTextMessageSettings::registerMetadata(); - BlackGui::Settings::CAtcStationsSettings::registerMetadata(); BlackGui::Components::registerMetadata(); } } diff --git a/src/blackgui/settings/atcstationssettings.cpp b/src/blackgui/settings/atcstationssettings.cpp deleted file mode 100644 index 26feb531a..000000000 --- a/src/blackgui/settings/atcstationssettings.cpp +++ /dev/null @@ -1,49 +0,0 @@ -// SPDX-FileCopyrightText: Copyright (C) 2016 swift Project Community / Contributors -// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1 - -#include "atcstationssettings.h" - -using namespace BlackMisc; - -BLACK_DEFINE_VALUEOBJECT_MIXINS(BlackGui::Settings, CAtcStationsSettings) - -namespace BlackGui::Settings -{ - CAtcStationsSettings::CAtcStationsSettings() - {} - - QString CAtcStationsSettings::convertToQString(bool i18n) const - { - Q_UNUSED(i18n) - static const QString s("In range only: %1 valid freq: %2"); - return s.arg(boolToOnOff(this->showOnlyInRange()), boolToOnOff(this->showOnlyWithValidFrequency())); - } - - QVariant CAtcStationsSettings::propertyByIndex(CPropertyIndexRef index) const - { - if (index.isMyself()) { return QVariant::fromValue(*this); } - const ColumnIndex i = index.frontCasted(); - switch (i) - { - case IndexInRangeOnly: return QVariant::fromValue(m_showOnlyInRange); - case IndexValidFrequencyOnly: return QVariant::fromValue(m_onlyWithValidFrequency); - default: return CValueObject::propertyByIndex(index); - } - } - - void CAtcStationsSettings::setPropertyByIndex(CPropertyIndexRef index, const QVariant &variant) - { - if (index.isMyself()) - { - (*this) = variant.value(); - return; - } - const ColumnIndex i = index.frontCasted(); - switch (i) - { - case IndexInRangeOnly: this->setShowOnlyInRange(variant.toBool()); break; - case IndexValidFrequencyOnly: this->setShowOnlyWithValidFrequency(variant.toBool()); break; - default: CValueObject::setPropertyByIndex(index, variant); break; - } - } -} // ns diff --git a/src/blackgui/settings/atcstationssettings.h b/src/blackgui/settings/atcstationssettings.h deleted file mode 100644 index ec3afb36f..000000000 --- a/src/blackgui/settings/atcstationssettings.h +++ /dev/null @@ -1,81 +0,0 @@ -// SPDX-FileCopyrightText: Copyright (C) 2016 swift Project Community / Contributors -// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1 - -//! \file - -#ifndef BLACKGUI_SETTINGS_ATCSTATIONSSETTINGS_H -#define BLACKGUI_SETTINGS_ATCSTATIONSSETTINGS_H - -#include "blackgui/blackguiexport.h" -#include "blackmisc/settingscache.h" -#include - -BLACK_DECLARE_VALUEOBJECT_MIXINS(BlackGui::Settings, CAtcStationsSettings) - -namespace BlackGui::Settings -{ - //! How to display ATC stations - class BLACKGUI_EXPORT CAtcStationsSettings : public BlackMisc::CValueObject - { - public: - //! Properties by index - enum ColumnIndex - { - IndexInRangeOnly = BlackMisc::CPropertyIndexRef::GlobalIndexCAtcStationsSettings, - IndexValidFrequencyOnly - }; - - //! Default constructor - CAtcStationsSettings(); - - //! Show in range ATC stations only? - bool showOnlyInRange() const { return m_showOnlyInRange; } - - //! Show in range ATC stations only - void setShowOnlyInRange(bool onlyInRange) { m_showOnlyInRange = onlyInRange; } - - //! Show only with valid frequency? - bool showOnlyWithValidFrequency() const { return m_onlyWithValidFrequency; } - - //! Show only with valid frequency - void setShowOnlyWithValidFrequency(bool onlyValidFrequency) { m_onlyWithValidFrequency = onlyValidFrequency; } - - //! \copydoc BlackMisc::Mixin::String::toQString - QString convertToQString(bool i18n = false) const; - - //! \copydoc BlackMisc::Mixin::Index::propertyByIndex - QVariant propertyByIndex(BlackMisc::CPropertyIndexRef index) const; - - //! \copydoc BlackMisc::Mixin::Index::setPropertyByIndex - void setPropertyByIndex(BlackMisc::CPropertyIndexRef index, const QVariant &variant); - - private: - bool m_showOnlyInRange = true; - bool m_onlyWithValidFrequency = true; - - BLACK_METACLASS( - CAtcStationsSettings, - BLACK_METAMEMBER(showOnlyInRange), - BLACK_METAMEMBER(onlyWithValidFrequency) - ); - }; - - //! ATC stations settings - struct TAtcStationsSettings : public BlackMisc::TSettingTrait - { - //! \copydoc BlackMisc::TSettingTrait::key - static const char *key() { return "atcstations"; } - - //! \copydoc BlackMisc::TSettingTrait::humanReadable - static const QString &humanReadable() - { - static const QString name("ATC stations"); - return name; - } - }; -} // ns - -Q_DECLARE_METATYPE(BlackGui::Settings::CAtcStationsSettings) -Q_DECLARE_METATYPE(BlackMisc::CCollection) - -#endif // guard