summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibGUI/CommandPalette.h
blob: 5e1853c7ab17ec38de85275a53a276c8c3179331 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/*
 * Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
 * Copyright (c) 2022, the SerenityOS developers.
 *
 * 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 = default;

    void collect_actions(GUI::Window& parent_window);
    void finish_with_index(GUI::ModelIndex const&);

    RefPtr<GUI::Action> m_selected_action;
    Vector<NonnullRefPtr<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;
};

}