diff --git a/scwx-qt/source/scwx/qt/settings/audio_settings.cpp b/scwx-qt/source/scwx/qt/settings/audio_settings.cpp index f5719525..c8bae71b 100644 --- a/scwx-qt/source/scwx/qt/settings/audio_settings.cpp +++ b/scwx-qt/source/scwx/qt/settings/audio_settings.cpp @@ -1,3 +1,4 @@ +#include #include #include #include @@ -47,6 +48,14 @@ public: types::LocationMethodIterator(), types::GetLocationMethodName)); + alertCounty_.SetValidator( + [](const std::string& value) + { + // Empty, or county exists in the database + return value.empty() || + config::CountyDatabase::GetCountyName(value) != value; + }); + for (auto& phenomenon : types::GetAlertAudioPhenomena()) { std::string phenomenonCode = awips::GetPhenomenonCode(phenomenon); @@ -73,6 +82,7 @@ public: SettingsVariable alertLocationMethod_ {"alert_location_method"}; SettingsVariable alertLatitude_ {"alert_latitude"}; SettingsVariable alertLongitude_ {"alert_longitude"}; + SettingsVariable alertCounty_ {"alert_county"}; std::unordered_map> alertEnabled_ {}; @@ -85,7 +95,8 @@ AudioSettings::AudioSettings() : RegisterVariables({&p->alertSoundFile_, &p->alertLocationMethod_, &p->alertLatitude_, - &p->alertLongitude_}); + &p->alertLongitude_, + &p->alertCounty_}); RegisterVariables(p->variables_); SetDefaults(); @@ -116,6 +127,11 @@ SettingsVariable& AudioSettings::alert_longitude() const return p->alertLongitude_; } +SettingsVariable& AudioSettings::alert_county() const +{ + return p->alertCounty_; +} + SettingsVariable& AudioSettings::alert_enabled(awips::Phenomenon phenomenon) const { @@ -139,6 +155,7 @@ bool operator==(const AudioSettings& lhs, const AudioSettings& rhs) lhs.p->alertLocationMethod_ == rhs.p->alertLocationMethod_ && lhs.p->alertLatitude_ == rhs.p->alertLatitude_ && lhs.p->alertLongitude_ == rhs.p->alertLongitude_ && + lhs.p->alertCounty_ == rhs.p->alertCounty_ && lhs.p->alertEnabled_ == rhs.p->alertEnabled_); } diff --git a/scwx-qt/source/scwx/qt/settings/audio_settings.hpp b/scwx-qt/source/scwx/qt/settings/audio_settings.hpp index e332cc8d..07deca1c 100644 --- a/scwx-qt/source/scwx/qt/settings/audio_settings.hpp +++ b/scwx-qt/source/scwx/qt/settings/audio_settings.hpp @@ -30,6 +30,7 @@ public: SettingsVariable& alert_location_method() const; SettingsVariable& alert_latitude() const; SettingsVariable& alert_longitude() const; + SettingsVariable& alert_county() const; SettingsVariable& alert_enabled(awips::Phenomenon phenomenon) const; static AudioSettings& Instance(); diff --git a/scwx-qt/source/scwx/qt/types/location_types.cpp b/scwx-qt/source/scwx/qt/types/location_types.cpp index 619e7746..4732eb2e 100644 --- a/scwx-qt/source/scwx/qt/types/location_types.cpp +++ b/scwx-qt/source/scwx/qt/types/location_types.cpp @@ -15,6 +15,7 @@ namespace types static const std::unordered_map locationMethodName_ {{LocationMethod::Fixed, "Fixed"}, {LocationMethod::Track, "Track"}, + {LocationMethod::County, "County"}, {LocationMethod::Unknown, "?"}}; SCWX_GET_ENUM(LocationMethod, GetLocationMethod, locationMethodName_) diff --git a/scwx-qt/source/scwx/qt/types/location_types.hpp b/scwx-qt/source/scwx/qt/types/location_types.hpp index 9a6cca05..c9d9784e 100644 --- a/scwx-qt/source/scwx/qt/types/location_types.hpp +++ b/scwx-qt/source/scwx/qt/types/location_types.hpp @@ -15,10 +15,11 @@ enum class LocationMethod { Fixed, Track, + County, Unknown }; typedef scwx::util:: - Iterator + Iterator LocationMethodIterator; LocationMethod GetLocationMethod(const std::string& name); diff --git a/scwx-qt/source/scwx/qt/ui/settings_dialog.cpp b/scwx-qt/source/scwx/qt/ui/settings_dialog.cpp index 4f983a68..36bef8d5 100644 --- a/scwx-qt/source/scwx/qt/ui/settings_dialog.cpp +++ b/scwx-qt/source/scwx/qt/ui/settings_dialog.cpp @@ -3,6 +3,7 @@ #include #include +#include #include #include #include @@ -18,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -113,6 +115,7 @@ public: explicit SettingsDialogImpl(SettingsDialog* self) : self_ {self}, radarSiteDialog_ {new RadarSiteDialog(self)}, + countyDialog_ {new CountyDialog(self)}, fontDialog_ {new QFontDialog(self)}, fontCategoryModel_ {new QStandardItemModel(self)}, settings_ {std::initializer_list { @@ -131,6 +134,7 @@ public: &alertAudioLocationMethod_, &alertAudioLatitude_, &alertAudioLongitude_, + &alertAudioCounty_, &hoverTextWrap_, &tooltipMethod_, &placefileTextDropShadowEnabled_}} @@ -192,6 +196,7 @@ public: SettingsDialog* self_; RadarSiteDialog* radarSiteDialog_; + CountyDialog* countyDialog_; QFontDialog* fontDialog_; QStandardItemModel* fontCategoryModel_; @@ -228,6 +233,7 @@ public: settings::SettingsInterface alertAudioLocationMethod_ {}; settings::SettingsInterface alertAudioLatitude_ {}; settings::SettingsInterface alertAudioLongitude_ {}; + settings::SettingsInterface alertAudioCounty_ {}; std::unordered_map> alertAudioEnabled_ {}; @@ -826,26 +832,34 @@ void SettingsDialogImpl::SetupPalettesAlertsTab() void SettingsDialogImpl::SetupAudioTab() { - QObject::connect(self_->ui->alertAudioLocationMethodComboBox, - &QComboBox::currentTextChanged, - self_, - [this](const QString& text) - { - types::LocationMethod locationMethod = - types::GetLocationMethod(text.toStdString()); + QObject::connect( + self_->ui->alertAudioLocationMethodComboBox, + &QComboBox::currentTextChanged, + self_, + [this](const QString& text) + { + types::LocationMethod locationMethod = + types::GetLocationMethod(text.toStdString()); - bool coordinateEntryEnabled = - locationMethod == types::LocationMethod::Fixed; + bool coordinateEntryEnabled = + locationMethod == types::LocationMethod::Fixed; + bool countyEntryEnabled = + locationMethod == types::LocationMethod::County; - self_->ui->alertAudioLatitudeSpinBox->setEnabled( - coordinateEntryEnabled); - self_->ui->alertAudioLongitudeSpinBox->setEnabled( - coordinateEntryEnabled); - self_->ui->resetAlertAudioLatitudeButton->setEnabled( - coordinateEntryEnabled); - self_->ui->resetAlertAudioLongitudeButton->setEnabled( - coordinateEntryEnabled); - }); + self_->ui->alertAudioLatitudeSpinBox->setEnabled( + coordinateEntryEnabled); + self_->ui->alertAudioLongitudeSpinBox->setEnabled( + coordinateEntryEnabled); + self_->ui->resetAlertAudioLatitudeButton->setEnabled( + coordinateEntryEnabled); + self_->ui->resetAlertAudioLongitudeButton->setEnabled( + coordinateEntryEnabled); + + self_->ui->alertAudioCountyLineEdit->setEnabled(countyEntryEnabled); + self_->ui->alertAudioCountySelectButton->setEnabled( + countyEntryEnabled); + self_->ui->resetAlertAudioCountyButton->setEnabled(countyEntryEnabled); + }); settings::AudioSettings& audioSettings = settings::AudioSettings::Instance(); @@ -927,6 +941,10 @@ void SettingsDialogImpl::SetupAudioTab() alertAudioLongitude_.SetResetButton( self_->ui->resetAlertAudioLongitudeButton); + alertAudioCounty_.SetSettingsVariable(audioSettings.alert_county()); + alertAudioCounty_.SetEditWidget(self_->ui->alertAudioCountyLineEdit); + alertAudioCounty_.SetResetButton(self_->ui->resetAlertAudioCountyButton); + auto alertAudioLayout = static_cast(self_->ui->alertAudioGroupBox->layout()); @@ -974,6 +992,47 @@ void SettingsDialogImpl::SetupAudioTab() coordinate.longitude()); } }); + + QObject::connect( + self_->ui->alertAudioCountySelectButton, + &QAbstractButton::clicked, + self_, + [this]() + { + std::string countyId = + self_->ui->alertAudioCountyLineEdit->text().toStdString(); + + if (countyId.length() >= 2) + { + countyDialog_->SelectState(countyId.substr(0, 2)); + } + + countyDialog_->show(); + }); + QObject::connect(countyDialog_, + &CountyDialog::accepted, + self_, + [this]() + { + std::string countyId = countyDialog_->county_fips_id(); + QString qCountyId = QString::fromStdString(countyId); + self_->ui->alertAudioCountyLineEdit->setText(qCountyId); + + // setText does not emit the textEdited signal + Q_EMIT self_->ui->alertAudioCountyLineEdit->textEdited( + qCountyId); + }); + QObject::connect(self_->ui->alertAudioCountyLineEdit, + &QLineEdit::textChanged, + self_, + [this](const QString& text) + { + std::string countyName = + config::CountyDatabase::GetCountyName( + text.toStdString()); + self_->ui->alertAudioCountyLabel->setText( + QString::fromStdString(countyName)); + }); } void SettingsDialogImpl::SetupTextTab() diff --git a/scwx-qt/source/scwx/qt/ui/settings_dialog.ui b/scwx-qt/source/scwx/qt/ui/settings_dialog.ui index 681923f5..7dfea913 100644 --- a/scwx-qt/source/scwx/qt/ui/settings_dialog.ui +++ b/scwx-qt/source/scwx/qt/ui/settings_dialog.ui @@ -460,22 +460,6 @@ - - - - 4 - - - -90.000000000000000 - - - 90.000000000000000 - - - 0.000100000000000 - - - @@ -508,22 +492,6 @@ - - - - 4 - - - -180.000000000000000 - - - 180.000000000000000 - - - 0.000100000000000 - - - @@ -535,6 +503,14 @@ + + + + + :/res/icons/font-awesome-6/stop-solid.svg:/res/icons/font-awesome-6/stop-solid.svg + + + @@ -546,9 +522,6 @@ - - - @@ -575,7 +548,46 @@ - + + + + County + + + + + + + 4 + + + -180.000000000000000 + + + 180.000000000000000 + + + 0.000100000000000 + + + + + + + 4 + + + -90.000000000000000 + + + 90.000000000000000 + + + 0.000100000000000 + + + + @@ -585,11 +597,50 @@ - - + + + + + + + ... + - :/res/icons/font-awesome-6/stop-solid.svg:/res/icons/font-awesome-6/stop-solid.svg + :/res/icons/font-awesome-6/rotate-left-solid.svg:/res/icons/font-awesome-6/rotate-left-solid.svg + + + + + + + ... + + + + + + + + 0 + 0 + + + + + + + + + + + + 0 + 0 + + + + true @@ -604,7 +655,7 @@ 20 - 281 + 253 diff --git a/test/data b/test/data index 8a633285..71d18bc6 160000 --- a/test/data +++ b/test/data @@ -1 +1 @@ -Subproject commit 8a633285ecbe8ff7d48631485620a7c7a5257229 +Subproject commit 71d18bc659d5e2b68b57dfaeb20f87cb1f0675f2