From b6d035aa05df71c7b71cda40517da789fe4b86c3 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Tue, 21 Apr 2020 17:50:20 +0200 Subject: SystemMenu: Make the system theme menu items checkable (and exclusive) --- Applications/SystemMenu/main.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'Applications') diff --git a/Applications/SystemMenu/main.cpp b/Applications/SystemMenu/main.cpp index 7dccf8a8a0..98ff7a0565 100644 --- a/Applications/SystemMenu/main.cpp +++ b/Applications/SystemMenu/main.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -64,6 +65,7 @@ Color g_menu_selection_color; Vector g_themes; RefPtr g_themes_menu; +GUI::ActionGroup g_themes_group; static NonnullRefPtr build_system_menu(); @@ -167,6 +169,8 @@ NonnullRefPtr build_system_menu() system_menu->add_separator(); + g_themes_group.set_exclusive(true); + g_themes_group.set_unchecking_allowed(false); g_themes_menu = GUI::Menu::construct("Themes"); system_menu->add_submenu(*g_themes_menu); @@ -184,12 +188,14 @@ NonnullRefPtr build_system_menu() { int theme_identifier = 0; for (auto& theme : g_themes) { - g_themes_menu->add_action(GUI::Action::create(theme.name, [theme_identifier](auto&) { + auto action = GUI::Action::create_checkable(theme.name, [theme_identifier](auto&) { auto& theme = g_themes[theme_identifier]; dbg() << "Theme switched to " << theme.name << " at path " << theme.path; auto response = GUI::WindowServerConnection::the().send_sync(theme.path, theme.name); ASSERT(response->success()); - })); + }); + g_themes_group.add_action(action); + g_themes_menu->add_action(action); ++theme_identifier; } } -- cgit v1.2.3