diff --git a/Userland/Libraries/LibGUI/Action.h b/Userland/Libraries/LibGUI/Action.h index c62cdbb044..398983d99e 100644 --- a/Userland/Libraries/LibGUI/Action.h +++ b/Userland/Libraries/LibGUI/Action.h @@ -52,6 +52,7 @@ NonnullRefPtr make_zoom_out_action(Function, Core::Object NonnullRefPtr make_reset_zoom_action(Function, Core::Object* parent = nullptr); NonnullRefPtr make_rotate_clockwise_action(Function, Core::Object* parent = nullptr); NonnullRefPtr make_rotate_counterclockwise_action(Function, Core::Object* parent = nullptr); +NonnullRefPtr make_command_palette_action(Window* window = nullptr); }; diff --git a/Userland/Libraries/LibGUI/CommonActions.cpp b/Userland/Libraries/LibGUI/CommonActions.cpp index 4d5caf31b5..9af53e8690 100644 --- a/Userland/Libraries/LibGUI/CommonActions.cpp +++ b/Userland/Libraries/LibGUI/CommonActions.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include namespace GUI { @@ -197,6 +198,22 @@ NonnullRefPtr make_rotate_counterclockwise_action(Function make_command_palette_action(Window* window) +{ + auto action = Action::create("&Commands...", { Mod_Ctrl | Mod_Shift, Key_A }, MUST(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/find.png"sv)), [=](auto&) { + auto command_palette = CommandPalette::construct(*window); + command_palette->set_window_mode(GUI::WindowMode::CaptureInput); + if (command_palette->exec() != GUI::Dialog::ExecResult::OK) + return; + auto* action = command_palette->selected_action(); + VERIFY(action); + action->flash_menubar_menu(*window); + action->activate(); + }); + action->set_status_tip("Open the command palette"); + return action; +} + } }