mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 21:40:05 +00:00
Radar site selection dialog in settings
This commit is contained in:
parent
9b5b841903
commit
a6974e31a2
2 changed files with 73 additions and 23 deletions
|
|
@ -5,6 +5,7 @@
|
|||
#include <scwx/qt/config/radar_site.hpp>
|
||||
#include <scwx/qt/manager/settings_manager.hpp>
|
||||
#include <scwx/qt/settings/settings_interface.hpp>
|
||||
#include <scwx/qt/ui/radar_site_dialog.hpp>
|
||||
|
||||
#include <format>
|
||||
|
||||
|
|
@ -46,14 +47,22 @@ static const std::array<std::pair<std::string, std::string>, 17>
|
|||
class SettingsDialogImpl
|
||||
{
|
||||
public:
|
||||
explicit SettingsDialogImpl(SettingsDialog* self) : self_ {self} {}
|
||||
explicit SettingsDialogImpl(SettingsDialog* self) :
|
||||
self_ {self}, radarSiteDialog_ {new RadarSiteDialog(self)}
|
||||
{
|
||||
}
|
||||
~SettingsDialogImpl() = default;
|
||||
|
||||
void ConnectSignals();
|
||||
void SetupGeneralTab();
|
||||
void SetupPalettesColorTablesTab();
|
||||
void SetupPalettesAlertsTab();
|
||||
|
||||
SettingsDialog* self_;
|
||||
static std::string
|
||||
RadarSiteLabel(std::shared_ptr<config::RadarSite>& radarSite);
|
||||
|
||||
SettingsDialog* self_;
|
||||
RadarSiteDialog* radarSiteDialog_;
|
||||
|
||||
settings::SettingsInterface<std::string> defaultRadarSite_ {};
|
||||
settings::SettingsInterface<std::vector<std::int64_t>> fontSizes_ {};
|
||||
|
|
@ -82,10 +91,7 @@ SettingsDialog::SettingsDialog(QWidget* parent) :
|
|||
// Palettes > Alerts
|
||||
p->SetupPalettesAlertsTab();
|
||||
|
||||
connect(ui->listWidget,
|
||||
&QListWidget::currentRowChanged,
|
||||
ui->stackedWidget,
|
||||
&QStackedWidget::setCurrentIndex);
|
||||
p->ConnectSignals();
|
||||
}
|
||||
|
||||
SettingsDialog::~SettingsDialog()
|
||||
|
|
@ -93,6 +99,39 @@ SettingsDialog::~SettingsDialog()
|
|||
delete ui;
|
||||
}
|
||||
|
||||
void SettingsDialogImpl::ConnectSignals()
|
||||
{
|
||||
QObject::connect(self_->ui->listWidget,
|
||||
&QListWidget::currentRowChanged,
|
||||
self_->ui->stackedWidget,
|
||||
&QStackedWidget::setCurrentIndex);
|
||||
|
||||
QObject::connect(self_->ui->radarSiteSelectButton,
|
||||
&QAbstractButton::clicked,
|
||||
self_,
|
||||
[this]() { radarSiteDialog_->show(); });
|
||||
|
||||
QObject::connect(radarSiteDialog_,
|
||||
&RadarSiteDialog::accepted,
|
||||
self_,
|
||||
[this]()
|
||||
{
|
||||
std::string id = radarSiteDialog_->radar_site();
|
||||
|
||||
std::shared_ptr<config::RadarSite> radarSite =
|
||||
config::RadarSite::Get(id);
|
||||
|
||||
if (radarSite != nullptr)
|
||||
{
|
||||
self_->ui->radarSiteComboBox->setCurrentText(
|
||||
QString::fromStdString(RadarSiteLabel(radarSite)));
|
||||
}
|
||||
});
|
||||
|
||||
// TODO: HandleMapUpdate for RadarSiteDialog, based on currently selected
|
||||
// radar site
|
||||
}
|
||||
|
||||
void SettingsDialogImpl::SetupGeneralTab()
|
||||
{
|
||||
auto radarSites = config::RadarSite::GetAll();
|
||||
|
|
@ -107,8 +146,7 @@ void SettingsDialogImpl::SetupGeneralTab()
|
|||
// Add sorted radar sites
|
||||
for (std::shared_ptr<config::RadarSite>& radarSite : radarSites)
|
||||
{
|
||||
QString text = QString::fromStdString(
|
||||
std::format("{} ({})", radarSite->id(), radarSite->location_name()));
|
||||
QString text = QString::fromStdString(RadarSiteLabel(radarSite));
|
||||
self_->ui->radarSiteComboBox->addItem(text);
|
||||
}
|
||||
|
||||
|
|
@ -130,8 +168,7 @@ void SettingsDialogImpl::SetupGeneralTab()
|
|||
}
|
||||
|
||||
// Add location details to the radar site
|
||||
return std::format(
|
||||
"{} ({})", radarSite->id(), radarSite->location_name());
|
||||
return RadarSiteLabel(radarSite);
|
||||
});
|
||||
defaultRadarSite_.SetMapToValueFunction(
|
||||
[](const std::string& text) -> std::string
|
||||
|
|
@ -268,6 +305,12 @@ void SettingsDialogImpl::SetupPalettesAlertsTab()
|
|||
}
|
||||
}
|
||||
|
||||
std::string SettingsDialogImpl::RadarSiteLabel(
|
||||
std::shared_ptr<config::RadarSite>& radarSite)
|
||||
{
|
||||
return std::format("{} ({})", radarSite->id(), radarSite->location_name());
|
||||
}
|
||||
|
||||
} // namespace ui
|
||||
} // namespace qt
|
||||
} // namespace scwx
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue