Skip to content

Commit

Permalink
LibGUI: Don't show the command palette action in the command palette
Browse files Browse the repository at this point in the history
  • Loading branch information
demostanis authored and linusg committed Oct 25, 2022
1 parent 28c1d70 commit eb8c2bd
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions Userland/Libraries/LibGUI/CommandPalette.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,13 +247,17 @@ void CommandPalette::collect_actions(GUI::Window& parent_window)
});
};

Function<bool(GUI::Action*)> should_show_action = [&](GUI::Action* action) {
return action && action->is_enabled() && action->shortcut() != Shortcut(Mod_Ctrl | Mod_Shift, Key_A);
};

Function<void(Menu&)> collect_actions_from_menu = [&](Menu& menu) {
for (auto menu_item : menu.items()) {
if (menu_item.submenu())
collect_actions_from_menu(*menu_item.submenu());

auto const* action = menu_item.action();
if (action && action->is_enabled())
auto* action = menu_item.action();
if (should_show_action(action))
actions.set(*action);
}
};
Expand All @@ -271,7 +275,7 @@ void CommandPalette::collect_actions(GUI::Window& parent_window)

if (!parent_window.is_modal()) {
for (auto const& it : GUI::Application::the()->global_shortcut_actions({})) {
if (it.value->is_enabled())
if (should_show_action(it.value))
actions.set(*it.value);
}
}
Expand Down

0 comments on commit eb8c2bd

Please sign in to comment.