diff options
author | Sam Atkins <atkinssj@serenityos.org> | 2022-04-29 11:39:31 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-04-29 20:06:39 +0200 |
commit | eb76751a763d01a10c526384d62f39c5953a0588 (patch) | |
tree | d64df2a73c8bc51c209f2472c38bab9566db134f /Userland/Applications/ThemeEditor | |
parent | 6c572006a307c06abce828d5093d17ca5f513217 (diff) | |
download | serenity-eb76751a763d01a10c526384d62f39c5953a0588.zip |
ThemeEditor: Stop firing unnecessary change callbacks
We only need to fire these callbacks when we want to change the palette.
So, when setting widget values to match a palette that has just been
loaded, or to show the value of the role selected in a ComboBox, we can
skip the callbacks. This saves some work, and means we can reliably use
on_palette_change to know when the palette has actually been modified.
Diffstat (limited to 'Userland/Applications/ThemeEditor')
-rw-r--r-- | Userland/Applications/ThemeEditor/main.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/Userland/Applications/ThemeEditor/main.cpp b/Userland/Applications/ThemeEditor/main.cpp index b54da37d10..cfa088baee 100644 --- a/Userland/Applications/ThemeEditor/main.cpp +++ b/Userland/Applications/ThemeEditor/main.cpp @@ -180,7 +180,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) color_combo_box.set_model(TRY(RoleModel<Gfx::ColorRole>::try_create(color_roles))); color_combo_box.on_change = [&](auto&, auto& index) { auto role = index.model()->data(index, GUI::ModelRole::Custom).to_color_role(); - color_input.set_color(preview_widget.preview_palette().color(role)); + color_input.set_color(preview_widget.preview_palette().color(role), GUI::AllowCallback::No); }; color_combo_box.set_selected_index((size_t)Gfx::ColorRole::Window - 1); @@ -190,7 +190,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) preview_palette.set_color(role, color_input.color()); preview_widget.set_preview_palette(preview_palette); }; - color_input.set_color(startup_preview_palette.color(Gfx::ColorRole::Window)); + color_input.set_color(startup_preview_palette.color(Gfx::ColorRole::Window), GUI::AllowCallback::No); alignment_combo_box.set_model(TRY(RoleModel<Gfx::AlignmentRole>::try_create(alignment_roles))); alignment_combo_box.on_change = [&](auto&, auto& index) { @@ -201,7 +201,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) alignment_input.set_only_allow_values_from_model(true); alignment_input.set_model(TRY(AlignmentModel::try_create())); - alignment_input.set_selected_index((size_t)startup_preview_palette.alignment(Gfx::AlignmentRole::TitleAlignment)); + alignment_input.set_selected_index((size_t)startup_preview_palette.alignment(Gfx::AlignmentRole::TitleAlignment), GUI::AllowCallback::No); alignment_input.on_change = [&](auto&, auto& index) { auto role = alignment_combo_box.model()->index(alignment_combo_box.selected_index()).data(GUI::ModelRole::Custom).to_alignment_role(); auto preview_palette = preview_widget.preview_palette(); @@ -243,7 +243,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) path_combo_box.set_model(TRY(RoleModel<Gfx::PathRole>::try_create(path_roles))); path_combo_box.on_change = [&](auto&, auto& index) { auto role = index.model()->data(index, GUI::ModelRole::Custom).to_path_role(); - path_input.set_text(preview_widget.preview_palette().path(role)); + path_input.set_text(preview_widget.preview_palette().path(role), GUI::AllowCallback::No); }; path_combo_box.set_selected_index((size_t)Gfx::PathRole::TitleButtonIcons - 1); @@ -253,7 +253,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) preview_palette.set_path(role, path_input.text()); preview_widget.set_preview_palette(preview_palette); }; - path_input.set_text(startup_preview_palette.path(Gfx::PathRole::TitleButtonIcons)); + path_input.set_text(startup_preview_palette.path(Gfx::PathRole::TitleButtonIcons), GUI::AllowCallback::No); path_picker_button.on_click = [&](auto) { auto role = path_combo_box.model()->index(path_combo_box.selected_index()).data(GUI::ModelRole::Custom).to_path_role(); @@ -283,7 +283,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) update_window_title(); auto selected_color_role = color_combo_box.model()->index(color_combo_box.selected_index()).data(GUI::ModelRole::Custom).to_color_role(); - color_input.set_color(preview_widget.preview_palette().color(selected_color_role)); + color_input.set_color(preview_widget.preview_palette().color(selected_color_role), GUI::AllowCallback::No); auto selected_flag_role = flag_combo_box.model()->index(flag_combo_box.selected_index()).data(GUI::ModelRole::Custom).to_flag_role(); flag_input.set_checked(preview_widget.preview_palette().flag(selected_flag_role), GUI::AllowCallback::No); @@ -292,7 +292,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) metric_input.set_value(preview_widget.preview_palette().metric(selected_metric_role), GUI::AllowCallback::No); auto selected_path_role = path_combo_box.model()->index(path_combo_box.selected_index()).data(GUI::ModelRole::Custom).to_path_role(); - path_input.set_text(preview_widget.preview_palette().path(selected_path_role)); + path_input.set_text(preview_widget.preview_palette().path(selected_path_role), GUI::AllowCallback::No); }; auto save_to_result = [&](auto const& response) { |