From 061bc8837f230062f2a9db4a7dbf9bd892627872 Mon Sep 17 00:00:00 2001 From: Dan Paulat Date: Tue, 2 May 2023 22:37:30 -0500 Subject: [PATCH] Add default alert action to settings dialog --- scwx-qt/source/scwx/qt/ui/settings_dialog.cpp | 50 +++++- scwx-qt/source/scwx/qt/ui/settings_dialog.ui | 147 ++++++++++-------- 2 files changed, 130 insertions(+), 67 deletions(-) diff --git a/scwx-qt/source/scwx/qt/ui/settings_dialog.cpp b/scwx-qt/source/scwx/qt/ui/settings_dialog.cpp index 5793f6bb..27b49c22 100644 --- a/scwx-qt/source/scwx/qt/ui/settings_dialog.cpp +++ b/scwx-qt/source/scwx/qt/ui/settings_dialog.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -88,6 +89,7 @@ public: &mapProvider_, &mapboxApiKey_, &mapTilerApiKey_, + &defaultAlertAction_, &updateNotificationsEnabled_, &debugEnabled_}} { @@ -144,8 +146,9 @@ public: settings::SettingsInterface mapProvider_ {}; settings::SettingsInterface mapboxApiKey_ {}; settings::SettingsInterface mapTilerApiKey_ {}; - settings::SettingsInterface updateNotificationsEnabled_ {}; - settings::SettingsInterface debugEnabled_ {}; + settings::SettingsInterface defaultAlertAction_ {}; + settings::SettingsInterface updateNotificationsEnabled_ {}; + settings::SettingsInterface debugEnabled_ {}; std::unordered_map> colorTables_ {}; @@ -331,10 +334,13 @@ void SettingsDialogImpl::SetupGeneralTab() { for (map::MapProvider mapProvider : map::MapProviderIterator()) { - if (boost::iequals(text, map::GetMapProviderName(mapProvider))) + const std::string mapProviderName = + map::GetMapProviderName(mapProvider); + + if (boost::iequals(text, mapProviderName)) { // Return map provider label - return GetMapProviderName(mapProvider); + return mapProviderName; } } @@ -359,6 +365,42 @@ 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( + [](const std::string& text) -> std::string + { + for (types::AlertAction alertAction : types::AlertActionIterator()) + { + const std::string alertActionName = + types::GetAlertActionName(alertAction); + + if (boost::iequals(text, alertActionName)) + { + // Return alert action label + return alertActionName; + } + } + + // Alert action label not found, return unknown + return "?"; + }); + 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); + defaultAlertAction_.SetResetButton(self_->ui->resetDefaultAlertActionButton); + updateNotificationsEnabled_.SetSettingsVariable( generalSettings.update_notifications_enabled()); updateNotificationsEnabled_.SetEditWidget( diff --git a/scwx-qt/source/scwx/qt/ui/settings_dialog.ui b/scwx-qt/source/scwx/qt/ui/settings_dialog.ui index 9a748feb..e12f8909 100644 --- a/scwx-qt/source/scwx/qt/ui/settings_dialog.ui +++ b/scwx-qt/source/scwx/qt/ui/settings_dialog.ui @@ -109,39 +109,58 @@ 0 + + + + + + + Font Sizes + + + + + + + + + + Default Radar Site + + + + + + + ... + + + + :/res/icons/font-awesome-6/rotate-left-solid.svg:/res/icons/font-awesome-6/rotate-left-solid.svg + + + - - + + - ... + Mapbox API Key - - + + - ... - - - - :/res/icons/font-awesome-6/rotate-left-solid.svg:/res/icons/font-awesome-6/rotate-left-solid.svg + MapTiler API Key - - - - ... - - - - :/res/icons/font-awesome-6/rotate-left-solid.svg:/res/icons/font-awesome-6/rotate-left-solid.svg - - + + - + ... @@ -152,17 +171,10 @@ - - + + - Font Sizes - - - - - - - MapTiler API Key + ... @@ -177,8 +189,22 @@ - - + + + + + + + + + + ... + + + + :/res/icons/font-awesome-6/rotate-left-solid.svg:/res/icons/font-awesome-6/rotate-left-solid.svg + + @@ -199,12 +225,9 @@ - + - - - - + ... @@ -215,19 +238,6 @@ - - - - - - - Mapbox API Key - - - - - - @@ -235,25 +245,36 @@ - - - - Default Radar Site - - - - + Map Provider - - + + + + ... + + + + :/res/icons/font-awesome-6/rotate-left-solid.svg:/res/icons/font-awesome-6/rotate-left-solid.svg + + - - + + + + Default Alert Action + + + + + + + + ...