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);
|
types::GetAccumulationUnitsName(types::AccumulationUnits::Inches);
|
||||||
std::string defaultEchoTopsUnitsValue =
|
std::string defaultEchoTopsUnitsValue =
|
||||||
types::GetEchoTopsUnitsName(types::EchoTopsUnits::Kilofeet);
|
types::GetEchoTopsUnitsName(types::EchoTopsUnits::Kilofeet);
|
||||||
|
std::string defaultOtherUnitsValue =
|
||||||
|
types::GetOtherUnitsName(types::OtherUnits::Default);
|
||||||
std::string defaultSpeedUnitsValue =
|
std::string defaultSpeedUnitsValue =
|
||||||
types::GetSpeedUnitsName(types::SpeedUnits::Knots);
|
types::GetSpeedUnitsName(types::SpeedUnits::Knots);
|
||||||
|
|
||||||
boost::to_lower(defaultAccumulationUnitsValue);
|
boost::to_lower(defaultAccumulationUnitsValue);
|
||||||
boost::to_lower(defaultEchoTopsUnitsValue);
|
boost::to_lower(defaultEchoTopsUnitsValue);
|
||||||
|
boost::to_lower(defaultOtherUnitsValue);
|
||||||
boost::to_lower(defaultSpeedUnitsValue);
|
boost::to_lower(defaultSpeedUnitsValue);
|
||||||
|
|
||||||
accumulationUnits_.SetDefault(defaultAccumulationUnitsValue);
|
accumulationUnits_.SetDefault(defaultAccumulationUnitsValue);
|
||||||
echoTopsUnits_.SetDefault(defaultEchoTopsUnitsValue);
|
echoTopsUnits_.SetDefault(defaultEchoTopsUnitsValue);
|
||||||
|
otherUnits_.SetDefault(defaultOtherUnitsValue);
|
||||||
speedUnits_.SetDefault(defaultSpeedUnitsValue);
|
speedUnits_.SetDefault(defaultSpeedUnitsValue);
|
||||||
|
|
||||||
accumulationUnits_.SetValidator(
|
accumulationUnits_.SetValidator(
|
||||||
|
|
@ -41,6 +45,10 @@ public:
|
||||||
SCWX_SETTINGS_ENUM_VALIDATOR(types::EchoTopsUnits,
|
SCWX_SETTINGS_ENUM_VALIDATOR(types::EchoTopsUnits,
|
||||||
types::EchoTopsUnitsIterator(),
|
types::EchoTopsUnitsIterator(),
|
||||||
types::GetEchoTopsUnitsName));
|
types::GetEchoTopsUnitsName));
|
||||||
|
otherUnits_.SetValidator(
|
||||||
|
SCWX_SETTINGS_ENUM_VALIDATOR(types::OtherUnits,
|
||||||
|
types::OtherUnitsIterator(),
|
||||||
|
types::GetOtherUnitsName));
|
||||||
speedUnits_.SetValidator(
|
speedUnits_.SetValidator(
|
||||||
SCWX_SETTINGS_ENUM_VALIDATOR(types::SpeedUnits,
|
SCWX_SETTINGS_ENUM_VALIDATOR(types::SpeedUnits,
|
||||||
types::SpeedUnitsIterator(),
|
types::SpeedUnitsIterator(),
|
||||||
|
|
@ -51,14 +59,17 @@ public:
|
||||||
|
|
||||||
SettingsVariable<std::string> accumulationUnits_ {"accumulation_units"};
|
SettingsVariable<std::string> accumulationUnits_ {"accumulation_units"};
|
||||||
SettingsVariable<std::string> echoTopsUnits_ {"echo_tops_units"};
|
SettingsVariable<std::string> echoTopsUnits_ {"echo_tops_units"};
|
||||||
|
SettingsVariable<std::string> otherUnits_ {"other_units"};
|
||||||
SettingsVariable<std::string> speedUnits_ {"speed_units"};
|
SettingsVariable<std::string> speedUnits_ {"speed_units"};
|
||||||
};
|
};
|
||||||
|
|
||||||
UnitSettings::UnitSettings() :
|
UnitSettings::UnitSettings() :
|
||||||
SettingsCategory("unit"), p(std::make_unique<Impl>())
|
SettingsCategory("unit"), p(std::make_unique<Impl>())
|
||||||
{
|
{
|
||||||
RegisterVariables(
|
RegisterVariables({&p->accumulationUnits_,
|
||||||
{&p->accumulationUnits_, &p->echoTopsUnits_, &p->speedUnits_});
|
&p->echoTopsUnits_,
|
||||||
|
&p->otherUnits_,
|
||||||
|
&p->speedUnits_});
|
||||||
SetDefaults();
|
SetDefaults();
|
||||||
}
|
}
|
||||||
UnitSettings::~UnitSettings() = default;
|
UnitSettings::~UnitSettings() = default;
|
||||||
|
|
@ -76,6 +87,11 @@ SettingsVariable<std::string>& UnitSettings::echo_tops_units() const
|
||||||
return p->echoTopsUnits_;
|
return p->echoTopsUnits_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SettingsVariable<std::string>& UnitSettings::other_units() const
|
||||||
|
{
|
||||||
|
return p->otherUnits_;
|
||||||
|
}
|
||||||
|
|
||||||
SettingsVariable<std::string>& UnitSettings::speed_units() const
|
SettingsVariable<std::string>& UnitSettings::speed_units() const
|
||||||
{
|
{
|
||||||
return p->speedUnits_;
|
return p->speedUnits_;
|
||||||
|
|
@ -91,6 +107,7 @@ bool operator==(const UnitSettings& lhs, const UnitSettings& rhs)
|
||||||
{
|
{
|
||||||
return (lhs.p->accumulationUnits_ == rhs.p->accumulationUnits_ &&
|
return (lhs.p->accumulationUnits_ == rhs.p->accumulationUnits_ &&
|
||||||
lhs.p->echoTopsUnits_ == rhs.p->echoTopsUnits_ &&
|
lhs.p->echoTopsUnits_ == rhs.p->echoTopsUnits_ &&
|
||||||
|
lhs.p->otherUnits_ == rhs.p->otherUnits_ &&
|
||||||
lhs.p->speedUnits_ == rhs.p->speedUnits_);
|
lhs.p->speedUnits_ == rhs.p->speedUnits_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@ public:
|
||||||
|
|
||||||
SettingsVariable<std::string>& accumulation_units() const;
|
SettingsVariable<std::string>& accumulation_units() const;
|
||||||
SettingsVariable<std::string>& echo_tops_units() const;
|
SettingsVariable<std::string>& echo_tops_units() const;
|
||||||
|
SettingsVariable<std::string>& other_units() const;
|
||||||
SettingsVariable<std::string>& speed_units() const;
|
SettingsVariable<std::string>& speed_units() const;
|
||||||
|
|
||||||
static UnitSettings& Instance();
|
static UnitSettings& Instance();
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,11 @@ static const std::unordered_map<EchoTopsUnits, std::string> echoTopsUnitsName_ {
|
||||||
{EchoTopsUnits::User, "User-defined"},
|
{EchoTopsUnits::User, "User-defined"},
|
||||||
{EchoTopsUnits::Unknown, "?"}};
|
{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>
|
static const std::unordered_map<SpeedUnits, std::string>
|
||||||
speedUnitsAbbreviation_ {{SpeedUnits::KilometersPerHour, "km/h"},
|
speedUnitsAbbreviation_ {{SpeedUnits::KilometersPerHour, "km/h"},
|
||||||
{SpeedUnits::Knots, "kts"},
|
{SpeedUnits::Knots, "kts"},
|
||||||
|
|
@ -69,6 +74,7 @@ SCWX_GET_ENUM(AccumulationUnits,
|
||||||
GetAccumulationUnitsFromName,
|
GetAccumulationUnitsFromName,
|
||||||
accumulationUnitsName_)
|
accumulationUnitsName_)
|
||||||
SCWX_GET_ENUM(EchoTopsUnits, GetEchoTopsUnitsFromName, echoTopsUnitsName_)
|
SCWX_GET_ENUM(EchoTopsUnits, GetEchoTopsUnitsFromName, echoTopsUnitsName_)
|
||||||
|
SCWX_GET_ENUM(OtherUnits, GetOtherUnitsFromName, otherUnitsName_)
|
||||||
SCWX_GET_ENUM(SpeedUnits, GetSpeedUnitsFromName, speedUnitsName_)
|
SCWX_GET_ENUM(SpeedUnits, GetSpeedUnitsFromName, speedUnitsName_)
|
||||||
|
|
||||||
const std::string& GetAccumulationUnitsAbbreviation(AccumulationUnits units)
|
const std::string& GetAccumulationUnitsAbbreviation(AccumulationUnits units)
|
||||||
|
|
@ -91,6 +97,11 @@ const std::string& GetEchoTopsUnitsName(EchoTopsUnits units)
|
||||||
return echoTopsUnitsName_.at(units);
|
return echoTopsUnitsName_.at(units);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const std::string& GetOtherUnitsName(OtherUnits units)
|
||||||
|
{
|
||||||
|
return otherUnitsName_.at(units);
|
||||||
|
}
|
||||||
|
|
||||||
const std::string& GetSpeedUnitsAbbreviation(SpeedUnits units)
|
const std::string& GetSpeedUnitsAbbreviation(SpeedUnits units)
|
||||||
{
|
{
|
||||||
return speedUnitsAbbreviation_.at(units);
|
return speedUnitsAbbreviation_.at(units);
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,15 @@ typedef scwx::util::
|
||||||
Iterator<EchoTopsUnits, EchoTopsUnits::Kilofeet, EchoTopsUnits::User>
|
Iterator<EchoTopsUnits, EchoTopsUnits::Kilofeet, EchoTopsUnits::User>
|
||||||
EchoTopsUnitsIterator;
|
EchoTopsUnitsIterator;
|
||||||
|
|
||||||
|
enum class OtherUnits
|
||||||
|
{
|
||||||
|
Default,
|
||||||
|
User,
|
||||||
|
Unknown
|
||||||
|
};
|
||||||
|
typedef scwx::util::Iterator<OtherUnits, OtherUnits::Default, OtherUnits::User>
|
||||||
|
OtherUnitsIterator;
|
||||||
|
|
||||||
enum class SpeedUnits
|
enum class SpeedUnits
|
||||||
{
|
{
|
||||||
KilometersPerHour,
|
KilometersPerHour,
|
||||||
|
|
@ -55,6 +64,9 @@ const std::string& GetEchoTopsUnitsAbbreviation(EchoTopsUnits units);
|
||||||
const std::string& GetEchoTopsUnitsName(EchoTopsUnits units);
|
const std::string& GetEchoTopsUnitsName(EchoTopsUnits units);
|
||||||
EchoTopsUnits GetEchoTopsUnitsFromName(const std::string& name);
|
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& GetSpeedUnitsAbbreviation(SpeedUnits units);
|
||||||
const std::string& GetSpeedUnitsName(SpeedUnits units);
|
const std::string& GetSpeedUnitsName(SpeedUnits units);
|
||||||
SpeedUnits GetSpeedUnitsFromName(const std::string& name);
|
SpeedUnits GetSpeedUnitsFromName(const std::string& name);
|
||||||
|
|
|
||||||
|
|
@ -132,6 +132,16 @@ public:
|
||||||
types::GetSpeedUnitsName);
|
types::GetSpeedUnitsName);
|
||||||
AddRow(speedUnits_, "Speed", speedComboBox);
|
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 =
|
QSpacerItem* spacer =
|
||||||
new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding);
|
new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding);
|
||||||
gridLayout_->addItem(spacer, row, 0);
|
gridLayout_->addItem(spacer, row, 0);
|
||||||
|
|
@ -145,6 +155,7 @@ public:
|
||||||
|
|
||||||
settings::SettingsInterface<std::string> accumulationUnits_ {};
|
settings::SettingsInterface<std::string> accumulationUnits_ {};
|
||||||
settings::SettingsInterface<std::string> echoTopsUnits_ {};
|
settings::SettingsInterface<std::string> echoTopsUnits_ {};
|
||||||
|
settings::SettingsInterface<std::string> otherUnits_ {};
|
||||||
settings::SettingsInterface<std::string> speedUnits_ {};
|
settings::SettingsInterface<std::string> speedUnits_ {};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
Subproject commit 03b6188cdf1b85f65bae0de822194bc6fab9bd14
|
Subproject commit 6b8df3fbed0bda444348a23fb06b95f52a65f592
|
||||||
Loading…
Add table
Add a link
Reference in a new issue