From b2dbcfefb00e8ecf2295818b0ba19ce132ae6002 Mon Sep 17 00:00:00 2001 From: Dan Paulat Date: Wed, 21 Dec 2022 00:24:33 -0600 Subject: [PATCH] Add color table settings interface --- scwx-qt/source/scwx/qt/ui/settings_dialog.cpp | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/scwx-qt/source/scwx/qt/ui/settings_dialog.cpp b/scwx-qt/source/scwx/qt/ui/settings_dialog.cpp index 60250cfe..0761bddc 100644 --- a/scwx-qt/source/scwx/qt/ui/settings_dialog.cpp +++ b/scwx-qt/source/scwx/qt/ui/settings_dialog.cpp @@ -60,6 +60,9 @@ public: settings::SettingsInterface gridHeight_ {}; settings::SettingsInterface mapboxApiKey_ {}; settings::SettingsInterface debugEnabled_ {}; + + std::unordered_map> + colorTables_ {}; }; SettingsDialog::SettingsDialog(QWidget* parent) : @@ -165,6 +168,9 @@ void SettingsDialogImpl::SetupGeneralTab() void SettingsDialogImpl::SetupPalettesColorTablesTab() { + settings::PaletteSettings& paletteSettings = + manager::SettingsManager::palette_settings(); + // Palettes > Color Tables QGridLayout* colorTableLayout = reinterpret_cast(self_->ui->colorTableContents->layout()); @@ -172,6 +178,7 @@ void SettingsDialogImpl::SetupPalettesColorTablesTab() int colorTableRow = 0; for (auto& colorTableType : kColorTableTypes_) { + QLineEdit* lineEdit = new QLineEdit(self_); QToolButton* resetButton = new QToolButton(self_); resetButton->setIcon( @@ -180,10 +187,21 @@ void SettingsDialogImpl::SetupPalettesColorTablesTab() colorTableLayout->addWidget( new QLabel(colorTableType.second.c_str(), self_), colorTableRow, 0); - colorTableLayout->addWidget(new QLineEdit(self_), colorTableRow, 1); + colorTableLayout->addWidget(lineEdit, colorTableRow, 1); colorTableLayout->addWidget(new QToolButton(self_), colorTableRow, 2); colorTableLayout->addWidget(resetButton, colorTableRow, 3); ++colorTableRow; + + // Create settings interface + auto result = colorTables_.emplace( + colorTableType.first, settings::SettingsInterface {}); + auto& pair = *result.first; + auto& colorTable = pair.second; + + colorTable.SetSettingsVariable( + paletteSettings.palette(colorTableType.first)); + colorTable.SetEditWidget(lineEdit); + colorTable.SetResetButton(resetButton); } }