From 483db9334e47d140333eef48e3b957e45456e2b1 Mon Sep 17 00:00:00 2001 From: Karol Kosek Date: Wed, 25 Aug 2021 22:34:22 +0200 Subject: [PATCH] ThemeEditor: Use preview_palette from the PreviewWidget Prior this change, when you opened a file using the brand new Open action and tried to change the Color Role or save it, then it would just go back to the startup palette. --- Userland/Applications/ThemeEditor/main.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Userland/Applications/ThemeEditor/main.cpp b/Userland/Applications/ThemeEditor/main.cpp index 56f181d5e5..d285787d78 100644 --- a/Userland/Applications/ThemeEditor/main.cpp +++ b/Userland/Applications/ThemeEditor/main.cpp @@ -115,13 +115,14 @@ int main(int argc, char** argv) combo_box.set_model(adopt_ref(*new ColorRoleModel(color_roles))); combo_box.on_change = [&](auto&, auto& index) { auto role = index.model()->data(index, GUI::ModelRole::Custom).to_color_role(); - color_input.set_color(preview_palette.color(role)); + color_input.set_color(preview_widget.preview_palette().color(role)); }; combo_box.set_selected_index((size_t)Gfx::ColorRole::Window - 1); color_input.on_change = [&] { auto role = combo_box.model()->index(combo_box.selected_index()).data(GUI::ModelRole::Custom).to_color_role(); + auto preview_palette = preview_widget.preview_palette(); preview_palette.set_color(role, color_input.color()); preview_widget.set_preview_palette(preview_palette); }; @@ -137,7 +138,7 @@ int main(int argc, char** argv) auto theme = Core::ConfigFile::open(*result.chosen_file, *result.fd); for (auto role : color_roles) { - theme->write_entry("Colors", to_string(role), preview_palette.color(role).to_string()); + theme->write_entry("Colors", to_string(role), preview_widget.preview_palette().color(role).to_string()); } theme->sync();