diff --git a/scwx-qt/source/scwx/qt/settings/unit_settings.cpp b/scwx-qt/source/scwx/qt/settings/unit_settings.cpp index 54e64364..e4cf4073 100644 --- a/scwx-qt/source/scwx/qt/settings/unit_settings.cpp +++ b/scwx-qt/source/scwx/qt/settings/unit_settings.cpp @@ -22,15 +22,19 @@ public: types::GetAccumulationUnitsName(types::AccumulationUnits::Inches); std::string defaultEchoTopsUnitsValue = types::GetEchoTopsUnitsName(types::EchoTopsUnits::Kilofeet); + std::string defaultOtherUnitsValue = + types::GetOtherUnitsName(types::OtherUnits::Default); std::string defaultSpeedUnitsValue = types::GetSpeedUnitsName(types::SpeedUnits::Knots); boost::to_lower(defaultAccumulationUnitsValue); boost::to_lower(defaultEchoTopsUnitsValue); + boost::to_lower(defaultOtherUnitsValue); boost::to_lower(defaultSpeedUnitsValue); accumulationUnits_.SetDefault(defaultAccumulationUnitsValue); echoTopsUnits_.SetDefault(defaultEchoTopsUnitsValue); + otherUnits_.SetDefault(defaultOtherUnitsValue); speedUnits_.SetDefault(defaultSpeedUnitsValue); accumulationUnits_.SetValidator( @@ -41,6 +45,10 @@ public: SCWX_SETTINGS_ENUM_VALIDATOR(types::EchoTopsUnits, types::EchoTopsUnitsIterator(), types::GetEchoTopsUnitsName)); + otherUnits_.SetValidator( + SCWX_SETTINGS_ENUM_VALIDATOR(types::OtherUnits, + types::OtherUnitsIterator(), + types::GetOtherUnitsName)); speedUnits_.SetValidator( SCWX_SETTINGS_ENUM_VALIDATOR(types::SpeedUnits, types::SpeedUnitsIterator(), @@ -51,14 +59,17 @@ public: SettingsVariable accumulationUnits_ {"accumulation_units"}; SettingsVariable echoTopsUnits_ {"echo_tops_units"}; + SettingsVariable otherUnits_ {"other_units"}; SettingsVariable speedUnits_ {"speed_units"}; }; UnitSettings::UnitSettings() : SettingsCategory("unit"), p(std::make_unique()) { - RegisterVariables( - {&p->accumulationUnits_, &p->echoTopsUnits_, &p->speedUnits_}); + RegisterVariables({&p->accumulationUnits_, + &p->echoTopsUnits_, + &p->otherUnits_, + &p->speedUnits_}); SetDefaults(); } UnitSettings::~UnitSettings() = default; @@ -76,6 +87,11 @@ SettingsVariable& UnitSettings::echo_tops_units() const return p->echoTopsUnits_; } +SettingsVariable& UnitSettings::other_units() const +{ + return p->otherUnits_; +} + SettingsVariable& UnitSettings::speed_units() const { return p->speedUnits_; @@ -91,6 +107,7 @@ bool operator==(const UnitSettings& lhs, const UnitSettings& rhs) { return (lhs.p->accumulationUnits_ == rhs.p->accumulationUnits_ && lhs.p->echoTopsUnits_ == rhs.p->echoTopsUnits_ && + lhs.p->otherUnits_ == rhs.p->otherUnits_ && lhs.p->speedUnits_ == rhs.p->speedUnits_); } diff --git a/scwx-qt/source/scwx/qt/settings/unit_settings.hpp b/scwx-qt/source/scwx/qt/settings/unit_settings.hpp index c058857a..c849cffb 100644 --- a/scwx-qt/source/scwx/qt/settings/unit_settings.hpp +++ b/scwx-qt/source/scwx/qt/settings/unit_settings.hpp @@ -27,6 +27,7 @@ public: SettingsVariable& accumulation_units() const; SettingsVariable& echo_tops_units() const; + SettingsVariable& other_units() const; SettingsVariable& speed_units() const; static UnitSettings& Instance(); diff --git a/scwx-qt/source/scwx/qt/types/unit_types.cpp b/scwx-qt/source/scwx/qt/types/unit_types.cpp index fb242dd7..71d6288c 100644 --- a/scwx-qt/source/scwx/qt/types/unit_types.cpp +++ b/scwx-qt/source/scwx/qt/types/unit_types.cpp @@ -37,6 +37,11 @@ static const std::unordered_map echoTopsUnitsName_ { {EchoTopsUnits::User, "User-defined"}, {EchoTopsUnits::Unknown, "?"}}; +static const std::unordered_map otherUnitsName_ { + {OtherUnits::Default, "Default"}, + {OtherUnits::User, "User-defined"}, + {OtherUnits::Unknown, "?"}}; + static const std::unordered_map speedUnitsAbbreviation_ {{SpeedUnits::KilometersPerHour, "km/h"}, {SpeedUnits::Knots, "kts"}, @@ -69,6 +74,7 @@ SCWX_GET_ENUM(AccumulationUnits, GetAccumulationUnitsFromName, accumulationUnitsName_) SCWX_GET_ENUM(EchoTopsUnits, GetEchoTopsUnitsFromName, echoTopsUnitsName_) +SCWX_GET_ENUM(OtherUnits, GetOtherUnitsFromName, otherUnitsName_) SCWX_GET_ENUM(SpeedUnits, GetSpeedUnitsFromName, speedUnitsName_) const std::string& GetAccumulationUnitsAbbreviation(AccumulationUnits units) @@ -91,6 +97,11 @@ const std::string& GetEchoTopsUnitsName(EchoTopsUnits units) return echoTopsUnitsName_.at(units); } +const std::string& GetOtherUnitsName(OtherUnits units) +{ + return otherUnitsName_.at(units); +} + const std::string& GetSpeedUnitsAbbreviation(SpeedUnits units) { return speedUnitsAbbreviation_.at(units); diff --git a/scwx-qt/source/scwx/qt/types/unit_types.hpp b/scwx-qt/source/scwx/qt/types/unit_types.hpp index f0c2147f..2fd1c5ab 100644 --- a/scwx-qt/source/scwx/qt/types/unit_types.hpp +++ b/scwx-qt/source/scwx/qt/types/unit_types.hpp @@ -34,6 +34,15 @@ typedef scwx::util:: Iterator EchoTopsUnitsIterator; +enum class OtherUnits +{ + Default, + User, + Unknown +}; +typedef scwx::util::Iterator + OtherUnitsIterator; + enum class SpeedUnits { KilometersPerHour, @@ -55,6 +64,9 @@ const std::string& GetEchoTopsUnitsAbbreviation(EchoTopsUnits units); const std::string& GetEchoTopsUnitsName(EchoTopsUnits units); EchoTopsUnits GetEchoTopsUnitsFromName(const std::string& name); +const std::string& GetOtherUnitsName(OtherUnits units); +OtherUnits GetOtherUnitsFromName(const std::string& name); + const std::string& GetSpeedUnitsAbbreviation(SpeedUnits units); const std::string& GetSpeedUnitsName(SpeedUnits units); SpeedUnits GetSpeedUnitsFromName(const std::string& name); diff --git a/scwx-qt/source/scwx/qt/ui/settings/unit_settings_widget.cpp b/scwx-qt/source/scwx/qt/ui/settings/unit_settings_widget.cpp index f38ae8a1..fc1a6b9a 100644 --- a/scwx-qt/source/scwx/qt/ui/settings/unit_settings_widget.cpp +++ b/scwx-qt/source/scwx/qt/ui/settings/unit_settings_widget.cpp @@ -132,6 +132,16 @@ public: types::GetSpeedUnitsName); AddRow(speedUnits_, "Speed", speedComboBox); + QComboBox* otherComboBox = new QComboBox(self); + otherComboBox->setSizePolicy(QSizePolicy::Expanding, + QSizePolicy::Preferred); + otherUnits_.SetSettingsVariable(unitSettings.other_units()); + SCWX_SETTINGS_COMBO_BOX(otherUnits_, + otherComboBox, + types::OtherUnitsIterator(), + types::GetOtherUnitsName); + AddRow(otherUnits_, "Other", otherComboBox); + QSpacerItem* spacer = new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding); gridLayout_->addItem(spacer, row, 0); @@ -145,6 +155,7 @@ public: settings::SettingsInterface accumulationUnits_ {}; settings::SettingsInterface echoTopsUnits_ {}; + settings::SettingsInterface otherUnits_ {}; settings::SettingsInterface speedUnits_ {}; }; diff --git a/test/data b/test/data index 03b6188c..6b8df3fb 160000 --- a/test/data +++ b/test/data @@ -1 +1 @@ -Subproject commit 03b6188cdf1b85f65bae0de822194bc6fab9bd14 +Subproject commit 6b8df3fbed0bda444348a23fb06b95f52a65f592