mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 16:40:05 +00:00
Add NMEA to settings dialog
This commit is contained in:
parent
b7a258d143
commit
8270153957
4 changed files with 412 additions and 475 deletions
|
|
@ -96,24 +96,6 @@ static const std::unordered_map<std::string, ColorTableConversions>
|
|||
{"VIL", {0u, 255u, 1.0f, 2.5f}},
|
||||
{"???", {0u, 15u, 0.0f, 1.0f}}};
|
||||
|
||||
#define SCWX_ENUM_MAP_FROM_VALUE(Type, Iterator, ToName) \
|
||||
[](const std::string& text) -> std::string \
|
||||
{ \
|
||||
for (Type enumValue : Iterator) \
|
||||
{ \
|
||||
const std::string enumName = ToName(enumValue); \
|
||||
\
|
||||
if (boost::iequals(text, enumName)) \
|
||||
{ \
|
||||
/* Return label */ \
|
||||
return enumName; \
|
||||
} \
|
||||
} \
|
||||
\
|
||||
/* Label not found, return unknown */ \
|
||||
return "?"; \
|
||||
}
|
||||
|
||||
class SettingsDialogImpl
|
||||
{
|
||||
public:
|
||||
|
|
@ -134,6 +116,9 @@ public:
|
|||
&defaultAlertAction_,
|
||||
&clockFormat_,
|
||||
&defaultTimeZone_,
|
||||
&positioningPlugin_,
|
||||
&nmeaBaudRate_,
|
||||
&nmeaSource_,
|
||||
&warningsProvider_,
|
||||
&antiAliasingEnabled_,
|
||||
&showMapAttribution_,
|
||||
|
|
@ -235,6 +220,9 @@ public:
|
|||
settings::SettingsInterface<std::string> defaultAlertAction_ {};
|
||||
settings::SettingsInterface<std::string> clockFormat_ {};
|
||||
settings::SettingsInterface<std::string> defaultTimeZone_ {};
|
||||
settings::SettingsInterface<std::string> positioningPlugin_ {};
|
||||
settings::SettingsInterface<std::int64_t> nmeaBaudRate_ {};
|
||||
settings::SettingsInterface<std::string> nmeaSource_ {};
|
||||
settings::SettingsInterface<std::string> theme_ {};
|
||||
settings::SettingsInterface<std::string> warningsProvider_ {};
|
||||
settings::SettingsInterface<bool> antiAliasingEnabled_ {};
|
||||
|
|
@ -467,38 +455,11 @@ void SettingsDialogImpl::SetupGeneralTab()
|
|||
settings::GeneralSettings& generalSettings =
|
||||
settings::GeneralSettings::Instance();
|
||||
|
||||
for (const auto& uiStyle : types::UiStyleIterator())
|
||||
{
|
||||
self_->ui->themeComboBox->addItem(
|
||||
QString::fromStdString(types::GetUiStyleName(uiStyle)));
|
||||
}
|
||||
|
||||
theme_.SetSettingsVariable(generalSettings.theme());
|
||||
theme_.SetMapFromValueFunction(
|
||||
[](const std::string& text) -> std::string
|
||||
{
|
||||
for (types::UiStyle uiStyle : types::UiStyleIterator())
|
||||
{
|
||||
const std::string uiStyleName = types::GetUiStyleName(uiStyle);
|
||||
|
||||
if (boost::iequals(text, uiStyleName))
|
||||
{
|
||||
// Return UI style label
|
||||
return uiStyleName;
|
||||
}
|
||||
}
|
||||
|
||||
// UI style label not found, return unknown
|
||||
return "?";
|
||||
});
|
||||
theme_.SetMapToValueFunction(
|
||||
[](std::string text) -> std::string
|
||||
{
|
||||
// Convert label to lower case and return
|
||||
boost::to_lower(text);
|
||||
return text;
|
||||
});
|
||||
theme_.SetEditWidget(self_->ui->themeComboBox);
|
||||
SCWX_SETTINGS_COMBO_BOX(theme_,
|
||||
self_->ui->themeComboBox,
|
||||
types::UiStyleIterator(),
|
||||
types::GetUiStyleName);
|
||||
theme_.SetResetButton(self_->ui->resetThemeButton);
|
||||
|
||||
auto radarSites = config::RadarSite::GetAll();
|
||||
|
|
@ -561,39 +522,11 @@ void SettingsDialogImpl::SetupGeneralTab()
|
|||
gridHeight_.SetEditWidget(self_->ui->gridHeightSpinBox);
|
||||
gridHeight_.SetResetButton(self_->ui->resetGridHeightButton);
|
||||
|
||||
for (const auto& mapProvider : map::MapProviderIterator())
|
||||
{
|
||||
self_->ui->mapProviderComboBox->addItem(
|
||||
QString::fromStdString(map::GetMapProviderName(mapProvider)));
|
||||
}
|
||||
|
||||
mapProvider_.SetSettingsVariable(generalSettings.map_provider());
|
||||
mapProvider_.SetMapFromValueFunction(
|
||||
[](const std::string& text) -> std::string
|
||||
{
|
||||
for (map::MapProvider mapProvider : map::MapProviderIterator())
|
||||
{
|
||||
const std::string mapProviderName =
|
||||
map::GetMapProviderName(mapProvider);
|
||||
|
||||
if (boost::iequals(text, mapProviderName))
|
||||
{
|
||||
// Return map provider label
|
||||
return mapProviderName;
|
||||
}
|
||||
}
|
||||
|
||||
// Map provider label not found, return unknown
|
||||
return "?";
|
||||
});
|
||||
mapProvider_.SetMapToValueFunction(
|
||||
[](std::string text) -> std::string
|
||||
{
|
||||
// Convert label to lower case and return
|
||||
boost::to_lower(text);
|
||||
return text;
|
||||
});
|
||||
mapProvider_.SetEditWidget(self_->ui->mapProviderComboBox);
|
||||
SCWX_SETTINGS_COMBO_BOX(mapProvider_,
|
||||
self_->ui->mapProviderComboBox,
|
||||
map::MapProviderIterator(),
|
||||
map::GetMapProviderName);
|
||||
mapProvider_.SetResetButton(self_->ui->resetMapProviderButton);
|
||||
|
||||
mapboxApiKey_.SetSettingsVariable(generalSettings.mapbox_api_key());
|
||||
|
|
@ -604,70 +537,43 @@ void SettingsDialogImpl::SetupGeneralTab()
|
|||
mapTilerApiKey_.SetEditWidget(self_->ui->mapTilerApiKeyLineEdit);
|
||||
mapTilerApiKey_.SetResetButton(self_->ui->resetMapTilerApiKeyButton);
|
||||
|
||||
for (const auto& alertAction : types::AlertActionIterator())
|
||||
{
|
||||
self_->ui->defaultAlertActionComboBox->addItem(
|
||||
QString::fromStdString(types::GetAlertActionName(alertAction)));
|
||||
}
|
||||
|
||||
defaultAlertAction_.SetSettingsVariable(
|
||||
generalSettings.default_alert_action());
|
||||
defaultAlertAction_.SetMapFromValueFunction(
|
||||
SCWX_ENUM_MAP_FROM_VALUE(types::AlertAction,
|
||||
types::AlertActionIterator(),
|
||||
types::GetAlertActionName));
|
||||
defaultAlertAction_.SetMapToValueFunction(
|
||||
[](std::string text) -> std::string
|
||||
{
|
||||
// Convert label to lower case and return
|
||||
boost::to_lower(text);
|
||||
return text;
|
||||
});
|
||||
defaultAlertAction_.SetEditWidget(self_->ui->defaultAlertActionComboBox);
|
||||
SCWX_SETTINGS_COMBO_BOX(defaultAlertAction_,
|
||||
self_->ui->defaultAlertActionComboBox,
|
||||
types::AlertActionIterator(),
|
||||
types::GetAlertActionName);
|
||||
defaultAlertAction_.SetResetButton(self_->ui->resetDefaultAlertActionButton);
|
||||
|
||||
for (const auto& clockFormat : scwx::util::ClockFormatIterator())
|
||||
{
|
||||
self_->ui->clockFormatComboBox->addItem(
|
||||
QString::fromStdString(scwx::util::GetClockFormatName(clockFormat)));
|
||||
}
|
||||
|
||||
clockFormat_.SetSettingsVariable(generalSettings.clock_format());
|
||||
clockFormat_.SetMapFromValueFunction(
|
||||
SCWX_ENUM_MAP_FROM_VALUE(scwx::util::ClockFormat,
|
||||
scwx::util::ClockFormatIterator(),
|
||||
scwx::util::GetClockFormatName));
|
||||
clockFormat_.SetMapToValueFunction(
|
||||
[](std::string text) -> std::string
|
||||
{
|
||||
// Convert label to lower case and return
|
||||
boost::to_lower(text);
|
||||
return text;
|
||||
});
|
||||
clockFormat_.SetEditWidget(self_->ui->clockFormatComboBox);
|
||||
SCWX_SETTINGS_COMBO_BOX(clockFormat_,
|
||||
self_->ui->clockFormatComboBox,
|
||||
scwx::util::ClockFormatIterator(),
|
||||
scwx::util::GetClockFormatName);
|
||||
clockFormat_.SetResetButton(self_->ui->resetClockFormatButton);
|
||||
|
||||
for (const auto& timeZone : types::DefaultTimeZoneIterator())
|
||||
{
|
||||
self_->ui->defaultTimeZoneComboBox->addItem(
|
||||
QString::fromStdString(types::GetDefaultTimeZoneName(timeZone)));
|
||||
}
|
||||
|
||||
defaultTimeZone_.SetSettingsVariable(generalSettings.default_time_zone());
|
||||
defaultTimeZone_.SetMapFromValueFunction(
|
||||
SCWX_ENUM_MAP_FROM_VALUE(types::DefaultTimeZone,
|
||||
types::DefaultTimeZoneIterator(),
|
||||
types::GetDefaultTimeZoneName));
|
||||
defaultTimeZone_.SetMapToValueFunction(
|
||||
[](std::string text) -> std::string
|
||||
{
|
||||
// Convert label to lower case and return
|
||||
boost::to_lower(text);
|
||||
return text;
|
||||
});
|
||||
defaultTimeZone_.SetEditWidget(self_->ui->defaultTimeZoneComboBox);
|
||||
SCWX_SETTINGS_COMBO_BOX(defaultTimeZone_,
|
||||
self_->ui->defaultTimeZoneComboBox,
|
||||
types::DefaultTimeZoneIterator(),
|
||||
types::GetDefaultTimeZoneName);
|
||||
defaultTimeZone_.SetResetButton(self_->ui->resetDefaultTimeZoneButton);
|
||||
|
||||
positioningPlugin_.SetSettingsVariable(generalSettings.positioning_plugin());
|
||||
SCWX_SETTINGS_COMBO_BOX(positioningPlugin_,
|
||||
self_->ui->positioningPluginComboBox,
|
||||
types::PositioningPluginIterator(),
|
||||
types::GetPositioningPluginName);
|
||||
positioningPlugin_.SetResetButton(self_->ui->resetPositioningPluginButton);
|
||||
|
||||
nmeaBaudRate_.SetSettingsVariable(generalSettings.nmea_baud_rate());
|
||||
nmeaBaudRate_.SetEditWidget(self_->ui->nmeaBaudRateSpinBox);
|
||||
nmeaBaudRate_.SetResetButton(self_->ui->resetNmeaBaudRateButton);
|
||||
|
||||
nmeaSource_.SetSettingsVariable(generalSettings.nmea_source());
|
||||
nmeaSource_.SetEditWidget(self_->ui->nmeaSourceLineEdit);
|
||||
nmeaSource_.SetResetButton(self_->ui->resetNmeaSourceButton);
|
||||
|
||||
warningsProvider_.SetSettingsVariable(generalSettings.warnings_provider());
|
||||
warningsProvider_.SetEditWidget(self_->ui->warningsProviderLineEdit);
|
||||
warningsProvider_.SetResetButton(self_->ui->resetWarningsProviderButton);
|
||||
|
|
@ -991,27 +897,12 @@ void SettingsDialogImpl::SetupAudioTab()
|
|||
dialog->open();
|
||||
});
|
||||
|
||||
for (const auto& locationMethod : types::LocationMethodIterator())
|
||||
{
|
||||
self_->ui->alertAudioLocationMethodComboBox->addItem(
|
||||
QString::fromStdString(types::GetLocationMethodName(locationMethod)));
|
||||
}
|
||||
|
||||
alertAudioLocationMethod_.SetSettingsVariable(
|
||||
audioSettings.alert_location_method());
|
||||
alertAudioLocationMethod_.SetMapFromValueFunction(
|
||||
SCWX_ENUM_MAP_FROM_VALUE(types::LocationMethod,
|
||||
types::LocationMethodIterator(),
|
||||
types::GetLocationMethodName));
|
||||
alertAudioLocationMethod_.SetMapToValueFunction(
|
||||
[](std::string text) -> std::string
|
||||
{
|
||||
// Convert label to lower case and return
|
||||
boost::to_lower(text);
|
||||
return text;
|
||||
});
|
||||
alertAudioLocationMethod_.SetEditWidget(
|
||||
self_->ui->alertAudioLocationMethodComboBox);
|
||||
SCWX_SETTINGS_COMBO_BOX(alertAudioLocationMethod_,
|
||||
self_->ui->alertAudioLocationMethodComboBox,
|
||||
types::LocationMethodIterator(),
|
||||
types::GetLocationMethodName);
|
||||
alertAudioLocationMethod_.SetResetButton(
|
||||
self_->ui->resetAlertAudioLocationMethodButton);
|
||||
|
||||
|
|
@ -1159,40 +1050,11 @@ void SettingsDialogImpl::SetupTextTab()
|
|||
hoverTextWrap_.SetEditWidget(self_->ui->hoverTextWrapSpinBox);
|
||||
hoverTextWrap_.SetResetButton(self_->ui->resetHoverTextWrapButton);
|
||||
|
||||
for (const auto& tooltipMethod : types::TooltipMethodIterator())
|
||||
{
|
||||
self_->ui->tooltipMethodComboBox->addItem(
|
||||
QString::fromStdString(types::GetTooltipMethodName(tooltipMethod)));
|
||||
}
|
||||
|
||||
tooltipMethod_.SetSettingsVariable(textSettings.tooltip_method());
|
||||
tooltipMethod_.SetMapFromValueFunction(
|
||||
[](const std::string& text) -> std::string
|
||||
{
|
||||
for (types::TooltipMethod tooltipMethod :
|
||||
types::TooltipMethodIterator())
|
||||
{
|
||||
const std::string tooltipMethodName =
|
||||
types::GetTooltipMethodName(tooltipMethod);
|
||||
|
||||
if (boost::iequals(text, tooltipMethodName))
|
||||
{
|
||||
// Return tooltip method label
|
||||
return tooltipMethodName;
|
||||
}
|
||||
}
|
||||
|
||||
// Tooltip method label not found, return unknown
|
||||
return "?";
|
||||
});
|
||||
tooltipMethod_.SetMapToValueFunction(
|
||||
[](std::string text) -> std::string
|
||||
{
|
||||
// Convert label to lower case and return
|
||||
boost::to_lower(text);
|
||||
return text;
|
||||
});
|
||||
tooltipMethod_.SetEditWidget(self_->ui->tooltipMethodComboBox);
|
||||
SCWX_SETTINGS_COMBO_BOX(tooltipMethod_,
|
||||
self_->ui->tooltipMethodComboBox,
|
||||
types::TooltipMethodIterator(),
|
||||
types::GetTooltipMethodName);
|
||||
tooltipMethod_.SetResetButton(self_->ui->resetTooltipMethodButton);
|
||||
|
||||
placefileTextDropShadowEnabled_.SetSettingsVariable(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue