mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 13:30:06 +00:00
Add other units to settings
This commit is contained in:
parent
fb4e111f84
commit
d937ffa9a4
6 changed files with 55 additions and 3 deletions
|
|
@ -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<std::string> accumulationUnits_ {"accumulation_units"};
|
||||
SettingsVariable<std::string> echoTopsUnits_ {"echo_tops_units"};
|
||||
SettingsVariable<std::string> otherUnits_ {"other_units"};
|
||||
SettingsVariable<std::string> speedUnits_ {"speed_units"};
|
||||
};
|
||||
|
||||
UnitSettings::UnitSettings() :
|
||||
SettingsCategory("unit"), p(std::make_unique<Impl>())
|
||||
{
|
||||
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<std::string>& UnitSettings::echo_tops_units() const
|
|||
return p->echoTopsUnits_;
|
||||
}
|
||||
|
||||
SettingsVariable<std::string>& UnitSettings::other_units() const
|
||||
{
|
||||
return p->otherUnits_;
|
||||
}
|
||||
|
||||
SettingsVariable<std::string>& 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_);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ public:
|
|||
|
||||
SettingsVariable<std::string>& accumulation_units() const;
|
||||
SettingsVariable<std::string>& echo_tops_units() const;
|
||||
SettingsVariable<std::string>& other_units() const;
|
||||
SettingsVariable<std::string>& speed_units() const;
|
||||
|
||||
static UnitSettings& Instance();
|
||||
|
|
|
|||
|
|
@ -37,6 +37,11 @@ static const std::unordered_map<EchoTopsUnits, std::string> echoTopsUnitsName_ {
|
|||
{EchoTopsUnits::User, "User-defined"},
|
||||
{EchoTopsUnits::Unknown, "?"}};
|
||||
|
||||
static const std::unordered_map<OtherUnits, std::string> otherUnitsName_ {
|
||||
{OtherUnits::Default, "Default"},
|
||||
{OtherUnits::User, "User-defined"},
|
||||
{OtherUnits::Unknown, "?"}};
|
||||
|
||||
static const std::unordered_map<SpeedUnits, std::string>
|
||||
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);
|
||||
|
|
|
|||
|
|
@ -34,6 +34,15 @@ typedef scwx::util::
|
|||
Iterator<EchoTopsUnits, EchoTopsUnits::Kilofeet, EchoTopsUnits::User>
|
||||
EchoTopsUnitsIterator;
|
||||
|
||||
enum class OtherUnits
|
||||
{
|
||||
Default,
|
||||
User,
|
||||
Unknown
|
||||
};
|
||||
typedef scwx::util::Iterator<OtherUnits, OtherUnits::Default, OtherUnits::User>
|
||||
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);
|
||||
|
|
|
|||
|
|
@ -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<std::string> accumulationUnits_ {};
|
||||
settings::SettingsInterface<std::string> echoTopsUnits_ {};
|
||||
settings::SettingsInterface<std::string> otherUnits_ {};
|
||||
settings::SettingsInterface<std::string> speedUnits_ {};
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit 03b6188cdf1b85f65bae0de822194bc6fab9bd14
|
||||
Subproject commit 6b8df3fbed0bda444348a23fb06b95f52a65f592
|
||||
Loading…
Add table
Add a link
Reference in a new issue