1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-17 16:05:07 +00:00
serenity/Userland/Libraries/LibGUI/CommandPalette.h
Andreas Kling 3e7e52c5f0 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.
2022-01-27 23:26:06 +01:00

37 lines
971 B
C++

/*
* Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <LibGUI/Dialog.h>
#include <LibGUI/FilteringProxyModel.h>
namespace GUI {
class CommandPalette final : public GUI::Dialog {
C_OBJECT(CommandPalette);
public:
GUI::Action* selected_action() { return m_selected_action; }
GUI::Action const* selected_action() const { return m_selected_action; }
private:
explicit CommandPalette(GUI::Window& parent_window, ScreenPosition screen_position = CenterWithinParent);
virtual ~CommandPalette() override;
void collect_actions(GUI::Window& parent_window);
void finish_with_index(GUI::ModelIndex const&);
RefPtr<GUI::Action> m_selected_action;
NonnullRefPtrVector<GUI::Action> m_actions;
RefPtr<GUI::TextBox> m_text_box;
RefPtr<GUI::TableView> m_table_view;
RefPtr<GUI::Model> m_model;
RefPtr<GUI::FilteringProxyModel> m_filter_model;
};
}