mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 10:48:11 +00:00
LibGUI: Add a universally available "command palette" to GUI programs
You can now press Ctrl+Shift+A in any LibGUI application and we'll give you a command palette dialog where you can search for context-relevant actions by name (via the keyboard.) The set of actions is currently the same one you'd access via keyboard shortcuts. In the future, we'll probably want to add APIs to allow richer integrations with this feature.
This commit is contained in:
parent
e0b60d56a5
commit
3e7e52c5f0
6 changed files with 235 additions and 1 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2018-2022, Andreas Kling <kling@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -10,6 +10,7 @@
|
|||
#include <LibCore/MimeData.h>
|
||||
#include <LibGUI/Action.h>
|
||||
#include <LibGUI/Application.h>
|
||||
#include <LibGUI/CommandPalette.h>
|
||||
#include <LibGUI/Desktop.h>
|
||||
#include <LibGUI/DisplayLink.h>
|
||||
#include <LibGUI/DragOperation.h>
|
||||
|
@ -194,6 +195,17 @@ void WindowServerConnection::key_down(i32 window_id, u32 code_point, u32 key, u3
|
|||
key_event->m_code_point = emoji_code_point;
|
||||
}
|
||||
|
||||
// FIXME: This shortcut should be configurable.
|
||||
if (modifiers == (Mod_Ctrl | Mod_Shift) && key == Key_A) {
|
||||
auto command_palette = CommandPalette::construct(*window);
|
||||
if (command_palette->exec() != GUI::Dialog::ExecOK)
|
||||
return;
|
||||
auto* action = command_palette->selected_action();
|
||||
VERIFY(action);
|
||||
action->activate();
|
||||
return;
|
||||
}
|
||||
|
||||
Core::EventLoop::current().post_event(*window, move(key_event));
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue