diff --git a/scwx-qt/source/scwx/qt/ui/settings_dialog.cpp b/scwx-qt/source/scwx/qt/ui/settings_dialog.cpp index 9cc80abf..e0996855 100644 --- a/scwx-qt/source/scwx/qt/ui/settings_dialog.cpp +++ b/scwx-qt/source/scwx/qt/ui/settings_dialog.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -102,6 +103,7 @@ public: explicit SettingsDialogImpl(SettingsDialog* self) : self_ {self}, radarSiteDialog_ {new RadarSiteDialog(self)}, + gpsSourceDialog_ {new SerialPortDialog(self)}, countyDialog_ {new CountyDialog(self)}, fontDialog_ {new QFontDialog(self)}, fontCategoryModel_ {new QStandardItemModel(self)}, @@ -193,10 +195,11 @@ public: RadarSiteLabel(std::shared_ptr& radarSite); static void SetBackgroundColor(const std::string& value, QFrame* frame); - SettingsDialog* self_; - RadarSiteDialog* radarSiteDialog_; - CountyDialog* countyDialog_; - QFontDialog* fontDialog_; + SettingsDialog* self_; + RadarSiteDialog* radarSiteDialog_; + SerialPortDialog* gpsSourceDialog_; + CountyDialog* countyDialog_; + QFontDialog* fontDialog_; QStandardItemModel* fontCategoryModel_; @@ -332,6 +335,32 @@ void SettingsDialogImpl::ConnectSignals() } }); + QObject::connect(self_->ui->gpsSourceSelectButton, + &QAbstractButton::clicked, + self_, + [this]() { gpsSourceDialog_->show(); }); + + QObject::connect(gpsSourceDialog_, + &SerialPortDialog::accepted, + self_, + [this]() + { + std::string serialPort = gpsSourceDialog_->serial_port(); + int baudRate = gpsSourceDialog_->baud_rate(); + + if (!serialPort.empty() && serialPort != "?") + { + std::string source = + fmt::format("serial:{}", serialPort); + nmeaSource_.StageValue(source); + } + + if (baudRate > 0) + { + self_->ui->nmeaBaudRateSpinBox->setValue(baudRate); + } + }); + // Update the Radar Site dialog "map" location with the currently selected // radar site auto& defaultRadarSite = *defaultRadarSite_.GetSettingsVariable(); @@ -559,6 +588,25 @@ void SettingsDialogImpl::SetupGeneralTab() types::GetDefaultTimeZoneName); defaultTimeZone_.SetResetButton(self_->ui->resetDefaultTimeZoneButton); + QObject::connect( + self_->ui->positioningPluginComboBox, + &QComboBox::currentTextChanged, + self_, + [this](const QString& text) + { + types::PositioningPlugin positioningPlugin = + types::GetPositioningPlugin(text.toStdString()); + + bool gpsSourceEnabled = + positioningPlugin == types::PositioningPlugin::Nmea; + + self_->ui->nmeaSourceLineEdit->setEnabled(gpsSourceEnabled); + self_->ui->gpsSourceSelectButton->setEnabled(gpsSourceEnabled); + self_->ui->nmeaBaudRateSpinBox->setEnabled(gpsSourceEnabled); + self_->ui->resetNmeaSourceButton->setEnabled(gpsSourceEnabled); + self_->ui->resetNmeaBaudRateButton->setEnabled(gpsSourceEnabled); + }); + positioningPlugin_.SetSettingsVariable(generalSettings.positioning_plugin()); SCWX_SETTINGS_COMBO_BOX(positioningPlugin_, self_->ui->positioningPluginComboBox, diff --git a/scwx-qt/source/scwx/qt/ui/settings_dialog.ui b/scwx-qt/source/scwx/qt/ui/settings_dialog.ui index 4364ba58..fe0efa6e 100644 --- a/scwx-qt/source/scwx/qt/ui/settings_dialog.ui +++ b/scwx-qt/source/scwx/qt/ui/settings_dialog.ui @@ -159,6 +159,48 @@ 0 + + + + MapTiler API Key + + + + + + + ... + + + + :/res/icons/font-awesome-6/rotate-left-solid.svg:/res/icons/font-awesome-6/rotate-left-solid.svg + + + + + + + + + + Default Time Zone + + + + + + + ... + + + + :/res/icons/font-awesome-6/rotate-left-solid.svg:/res/icons/font-awesome-6/rotate-left-solid.svg + + + + + + @@ -170,8 +212,18 @@ - - + + + + Map Provider + + + + + + + + ... @@ -181,21 +233,51 @@ - - + + + + + + + + - Clock Format + ... - - - - NMEA Source + + + + QLineEdit::EchoMode::Password - + + + + GPS Plugin + + + + + + + GPS Baud Rate + + + + + + + + + + ... + + + + ... @@ -206,10 +288,47 @@ - - + + - Mapbox API Key + Grid Width + + + + + + + + + + + + + + + + GPS Source + + + + + + + + + + Default Radar Site + + + + + + + ... + + + + :/res/icons/font-awesome-6/rotate-left-solid.svg:/res/icons/font-awesome-6/rotate-left-solid.svg @@ -220,84 +339,24 @@ - - + + ... + + + :/res/icons/font-awesome-6/rotate-left-solid.svg:/res/icons/font-awesome-6/rotate-left-solid.svg + - - - Warnings Provider - - - - - - - - - - Grid Width - - - - - - - - - - Default Alert Action - - - - - - - Default Time Zone - - - - - - - NMEA Baud Rate - - - - - - - - - - MapTiler API Key - - - - - - - Theme - - - - - - - Default Radar Site - - - @@ -309,83 +368,27 @@ - - - - - + + - ... - - - - :/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 + Clock Format - - - - - - - ... - - - - :/res/icons/font-awesome-6/rotate-left-solid.svg:/res/icons/font-awesome-6/rotate-left-solid.svg - - - - - - - ... - - - - :/res/icons/font-awesome-6/rotate-left-solid.svg:/res/icons/font-awesome-6/rotate-left-solid.svg - - - - - + + QLineEdit::EchoMode::Password - - - - - - - ... - - - - :/res/icons/font-awesome-6/rotate-left-solid.svg:/res/icons/font-awesome-6/rotate-left-solid.svg - - - - - - @@ -397,7 +400,45 @@ - + + + + ... + + + + :/res/icons/font-awesome-6/rotate-left-solid.svg:/res/icons/font-awesome-6/rotate-left-solid.svg + + + + + + + + + + Warnings Provider + + + + + + + 1 + + + 999999999 + + + + + + + Default Alert Action + + + + ... @@ -408,41 +449,7 @@ - - - - Map Provider - - - - - - - QLineEdit::EchoMode::Password - - - - - - - Positioning Plugin - - - - - - - - - - 1 - - - 999999999 - - - - + ... @@ -453,8 +460,8 @@ - - + + ... @@ -464,8 +471,8 @@ - - + + ...