mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 19:10:06 +00:00
Removing old alert palette configuration from settings dialog
This commit is contained in:
parent
d039fef4f1
commit
2d8c3c8175
2 changed files with 1 additions and 207 deletions
|
|
@ -182,7 +182,6 @@ public:
|
||||||
void SetupTextTab();
|
void SetupTextTab();
|
||||||
void SetupHotkeysTab();
|
void SetupHotkeysTab();
|
||||||
|
|
||||||
void ShowColorDialog(QLineEdit* lineEdit);
|
|
||||||
void UpdateRadarDialogLocation(const std::string& id);
|
void UpdateRadarDialogLocation(const std::string& id);
|
||||||
void UpdateAlertRadarDialogLocation(const std::string& id);
|
void UpdateAlertRadarDialogLocation(const std::string& id);
|
||||||
|
|
||||||
|
|
@ -204,8 +203,7 @@ public:
|
||||||
const std::string& value,
|
const std::string& value,
|
||||||
QLabel* imageLabel);
|
QLabel* imageLabel);
|
||||||
static std::string
|
static std::string
|
||||||
RadarSiteLabel(std::shared_ptr<config::RadarSite>& radarSite);
|
RadarSiteLabel(std::shared_ptr<config::RadarSite>& radarSite);
|
||||||
static void SetBackgroundColor(const std::string& value, QFrame* frame);
|
|
||||||
|
|
||||||
SettingsDialog* self_;
|
SettingsDialog* self_;
|
||||||
RadarSiteDialog* radarSiteDialog_;
|
RadarSiteDialog* radarSiteDialog_;
|
||||||
|
|
@ -254,12 +252,6 @@ public:
|
||||||
|
|
||||||
std::unordered_map<std::string, settings::SettingsInterface<std::string>>
|
std::unordered_map<std::string, settings::SettingsInterface<std::string>>
|
||||||
colorTables_ {};
|
colorTables_ {};
|
||||||
std::unordered_map<awips::Phenomenon,
|
|
||||||
settings::SettingsInterface<std::string>>
|
|
||||||
activeAlertColors_ {};
|
|
||||||
std::unordered_map<awips::Phenomenon,
|
|
||||||
settings::SettingsInterface<std::string>>
|
|
||||||
inactiveAlertColors_ {};
|
|
||||||
|
|
||||||
settings::SettingsInterface<std::string> alertAudioSoundFile_ {};
|
settings::SettingsInterface<std::string> alertAudioSoundFile_ {};
|
||||||
settings::SettingsInterface<std::string> alertAudioLocationMethod_ {};
|
settings::SettingsInterface<std::string> alertAudioLocationMethod_ {};
|
||||||
|
|
@ -804,9 +796,6 @@ void SettingsDialogImpl::SetupPalettesColorTablesTab()
|
||||||
|
|
||||||
void SettingsDialogImpl::SetupPalettesAlertsTab()
|
void SettingsDialogImpl::SetupPalettesAlertsTab()
|
||||||
{
|
{
|
||||||
settings::PaletteSettings& paletteSettings =
|
|
||||||
settings::PaletteSettings::Instance();
|
|
||||||
|
|
||||||
// Palettes > Alerts
|
// Palettes > Alerts
|
||||||
QVBoxLayout* layout = new QVBoxLayout(self_->ui->alertsPalette);
|
QVBoxLayout* layout = new QVBoxLayout(self_->ui->alertsPalette);
|
||||||
|
|
||||||
|
|
@ -815,119 +804,6 @@ void SettingsDialogImpl::SetupPalettesAlertsTab()
|
||||||
layout->addWidget(alertPaletteSettingsWidget_);
|
layout->addWidget(alertPaletteSettingsWidget_);
|
||||||
|
|
||||||
settingsPages_.push_back(alertPaletteSettingsWidget_);
|
settingsPages_.push_back(alertPaletteSettingsWidget_);
|
||||||
|
|
||||||
// Palettes > Old Alerts
|
|
||||||
QGridLayout* alertsLayout =
|
|
||||||
reinterpret_cast<QGridLayout*>(self_->ui->alertsFrame->layout());
|
|
||||||
|
|
||||||
QLabel* phenomenonLabel = new QLabel(QObject::tr("Phenomenon"), self_);
|
|
||||||
QLabel* activeLabel = new QLabel(QObject::tr("Active"), self_);
|
|
||||||
QLabel* inactiveLabel = new QLabel(QObject::tr("Inactive"), self_);
|
|
||||||
|
|
||||||
QFont boldFont;
|
|
||||||
boldFont.setBold(true);
|
|
||||||
phenomenonLabel->setFont(boldFont);
|
|
||||||
activeLabel->setFont(boldFont);
|
|
||||||
inactiveLabel->setFont(boldFont);
|
|
||||||
|
|
||||||
alertsLayout->addWidget(phenomenonLabel, 0, 0);
|
|
||||||
alertsLayout->addWidget(activeLabel, 0, 1, 1, 4);
|
|
||||||
alertsLayout->addWidget(inactiveLabel, 0, 5, 1, 4);
|
|
||||||
|
|
||||||
auto& alertPhenomena = settings::PaletteSettings::alert_phenomena();
|
|
||||||
|
|
||||||
activeAlertColors_.reserve(alertPhenomena.size());
|
|
||||||
inactiveAlertColors_.reserve(alertPhenomena.size());
|
|
||||||
|
|
||||||
int alertsRow = 1;
|
|
||||||
for (auto& phenomenon : alertPhenomena)
|
|
||||||
{
|
|
||||||
QFrame* activeFrame = new QFrame(self_);
|
|
||||||
QFrame* inactiveFrame = new QFrame(self_);
|
|
||||||
|
|
||||||
QLineEdit* activeEdit = new QLineEdit(self_);
|
|
||||||
QLineEdit* inactiveEdit = new QLineEdit(self_);
|
|
||||||
|
|
||||||
QToolButton* activeButton = new QToolButton(self_);
|
|
||||||
QToolButton* inactiveButton = new QToolButton(self_);
|
|
||||||
QToolButton* activeResetButton = new QToolButton(self_);
|
|
||||||
QToolButton* inactiveResetButton = new QToolButton(self_);
|
|
||||||
|
|
||||||
activeFrame->setMinimumHeight(24);
|
|
||||||
activeFrame->setMinimumWidth(24);
|
|
||||||
activeFrame->setFrameShape(QFrame::Shape::Box);
|
|
||||||
activeFrame->setFrameShadow(QFrame::Shadow::Plain);
|
|
||||||
inactiveFrame->setMinimumHeight(24);
|
|
||||||
inactiveFrame->setMinimumWidth(24);
|
|
||||||
inactiveFrame->setFrameShape(QFrame::Shape::Box);
|
|
||||||
inactiveFrame->setFrameShadow(QFrame::Shadow::Plain);
|
|
||||||
|
|
||||||
activeButton->setIcon(
|
|
||||||
QIcon {":/res/icons/font-awesome-6/palette-solid.svg"});
|
|
||||||
inactiveButton->setIcon(
|
|
||||||
QIcon {":/res/icons/font-awesome-6/palette-solid.svg"});
|
|
||||||
activeResetButton->setIcon(
|
|
||||||
QIcon {":/res/icons/font-awesome-6/rotate-left-solid.svg"});
|
|
||||||
inactiveResetButton->setIcon(
|
|
||||||
QIcon {":/res/icons/font-awesome-6/rotate-left-solid.svg"});
|
|
||||||
|
|
||||||
alertsLayout->addWidget(
|
|
||||||
new QLabel(QObject::tr(awips::GetPhenomenonText(phenomenon).c_str()),
|
|
||||||
self_),
|
|
||||||
alertsRow,
|
|
||||||
0);
|
|
||||||
alertsLayout->addWidget(activeFrame, alertsRow, 1);
|
|
||||||
alertsLayout->addWidget(activeEdit, alertsRow, 2);
|
|
||||||
alertsLayout->addWidget(activeButton, alertsRow, 3);
|
|
||||||
alertsLayout->addWidget(activeResetButton, alertsRow, 4);
|
|
||||||
alertsLayout->addWidget(inactiveFrame, alertsRow, 5);
|
|
||||||
alertsLayout->addWidget(inactiveEdit, alertsRow, 6);
|
|
||||||
alertsLayout->addWidget(inactiveButton, alertsRow, 7);
|
|
||||||
alertsLayout->addWidget(inactiveResetButton, alertsRow, 8);
|
|
||||||
++alertsRow;
|
|
||||||
|
|
||||||
// Create settings interface
|
|
||||||
auto activeResult = activeAlertColors_.emplace(
|
|
||||||
phenomenon, settings::SettingsInterface<std::string> {});
|
|
||||||
auto inactiveResult = inactiveAlertColors_.emplace(
|
|
||||||
phenomenon, settings::SettingsInterface<std::string> {});
|
|
||||||
auto& activeColor = activeResult.first->second;
|
|
||||||
auto& inactiveColor = inactiveResult.first->second;
|
|
||||||
|
|
||||||
// Add to settings list
|
|
||||||
settings_.push_back(&activeColor);
|
|
||||||
settings_.push_back(&inactiveColor);
|
|
||||||
|
|
||||||
auto& activeSetting = paletteSettings.alert_color(phenomenon, true);
|
|
||||||
auto& inactiveSetting = paletteSettings.alert_color(phenomenon, false);
|
|
||||||
|
|
||||||
activeColor.SetSettingsVariable(activeSetting);
|
|
||||||
activeColor.SetEditWidget(activeEdit);
|
|
||||||
activeColor.SetResetButton(activeResetButton);
|
|
||||||
|
|
||||||
inactiveColor.SetSettingsVariable(inactiveSetting);
|
|
||||||
inactiveColor.SetEditWidget(inactiveEdit);
|
|
||||||
inactiveColor.SetResetButton(inactiveResetButton);
|
|
||||||
|
|
||||||
SetBackgroundColor(activeSetting.GetValue(), activeFrame);
|
|
||||||
SetBackgroundColor(inactiveSetting.GetValue(), inactiveFrame);
|
|
||||||
|
|
||||||
activeSetting.RegisterValueStagedCallback(
|
|
||||||
[activeFrame](const std::string& value)
|
|
||||||
{ SetBackgroundColor(value, activeFrame); });
|
|
||||||
inactiveSetting.RegisterValueStagedCallback(
|
|
||||||
[inactiveFrame](const std::string& value)
|
|
||||||
{ SetBackgroundColor(value, inactiveFrame); });
|
|
||||||
|
|
||||||
QObject::connect(activeButton,
|
|
||||||
&QAbstractButton::clicked,
|
|
||||||
self_,
|
|
||||||
[=, this]() { ShowColorDialog(activeEdit); });
|
|
||||||
QObject::connect(inactiveButton,
|
|
||||||
&QAbstractButton::clicked,
|
|
||||||
self_,
|
|
||||||
[=, this]() { ShowColorDialog(inactiveEdit); });
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingsDialogImpl::SetupUnitsTab()
|
void SettingsDialogImpl::SetupUnitsTab()
|
||||||
|
|
@ -1382,44 +1258,6 @@ void SettingsDialogImpl::LoadColorTablePreview(const std::string& key,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingsDialogImpl::ShowColorDialog(QLineEdit* lineEdit)
|
|
||||||
{
|
|
||||||
QColorDialog* dialog = new QColorDialog(self_);
|
|
||||||
|
|
||||||
dialog->setAttribute(Qt::WA_DeleteOnClose);
|
|
||||||
dialog->setOption(QColorDialog::ColorDialogOption::ShowAlphaChannel);
|
|
||||||
|
|
||||||
QColor initialColor(lineEdit->text());
|
|
||||||
if (initialColor.isValid())
|
|
||||||
{
|
|
||||||
dialog->setCurrentColor(initialColor);
|
|
||||||
}
|
|
||||||
|
|
||||||
QObject::connect(
|
|
||||||
dialog,
|
|
||||||
&QColorDialog::colorSelected,
|
|
||||||
self_,
|
|
||||||
[lineEdit](const QColor& color)
|
|
||||||
{
|
|
||||||
QString colorName = color.name(QColor::NameFormat::HexArgb);
|
|
||||||
|
|
||||||
logger_->info("Selected color: {}", colorName.toStdString());
|
|
||||||
lineEdit->setText(colorName);
|
|
||||||
|
|
||||||
// setText does not emit the textEdited signal
|
|
||||||
Q_EMIT lineEdit->textEdited(colorName);
|
|
||||||
});
|
|
||||||
|
|
||||||
dialog->open();
|
|
||||||
}
|
|
||||||
|
|
||||||
void SettingsDialogImpl::SetBackgroundColor(const std::string& value,
|
|
||||||
QFrame* frame)
|
|
||||||
{
|
|
||||||
frame->setStyleSheet(
|
|
||||||
QString::fromStdString(fmt::format("background-color: {}", value)));
|
|
||||||
}
|
|
||||||
|
|
||||||
void SettingsDialogImpl::UpdateRadarDialogLocation(const std::string& id)
|
void SettingsDialogImpl::UpdateRadarDialogLocation(const std::string& id)
|
||||||
{
|
{
|
||||||
std::shared_ptr<config::RadarSite> radarSite = config::RadarSite::Get(id);
|
std::shared_ptr<config::RadarSite> radarSite = config::RadarSite::Get(id);
|
||||||
|
|
|
||||||
|
|
@ -639,50 +639,6 @@
|
||||||
<string>Alerts</string>
|
<string>Alerts</string>
|
||||||
</attribute>
|
</attribute>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QWidget" name="tab_2">
|
|
||||||
<attribute name="title">
|
|
||||||
<string>Old Alerts</string>
|
|
||||||
</attribute>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
|
||||||
<item>
|
|
||||||
<widget class="QFrame" name="alertsFrame">
|
|
||||||
<property name="frameShape">
|
|
||||||
<enum>QFrame::Shape::StyledPanel</enum>
|
|
||||||
</property>
|
|
||||||
<property name="frameShadow">
|
|
||||||
<enum>QFrame::Shadow::Raised</enum>
|
|
||||||
</property>
|
|
||||||
<layout class="QGridLayout" name="gridLayout_5">
|
|
||||||
<property name="leftMargin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="topMargin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="rightMargin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="bottomMargin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer name="verticalSpacer_2">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Orientation::Vertical</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>20</width>
|
|
||||||
<height>239</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue