CommandPalette.h 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. /*
  2. * Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
  3. * Copyright (c) 2022, the SerenityOS developers.
  4. *
  5. * SPDX-License-Identifier: BSD-2-Clause
  6. */
  7. #pragma once
  8. #include <LibGUI/Dialog.h>
  9. #include <LibGUI/FilteringProxyModel.h>
  10. namespace GUI {
  11. class CommandPalette final : public GUI::Dialog {
  12. C_OBJECT(CommandPalette);
  13. public:
  14. GUI::Action* selected_action() { return m_selected_action; }
  15. GUI::Action const* selected_action() const { return m_selected_action; }
  16. private:
  17. explicit CommandPalette(GUI::Window& parent_window, ScreenPosition screen_position = CenterWithinParent);
  18. virtual ~CommandPalette() override = default;
  19. void collect_actions(GUI::Window& parent_window);
  20. void finish_with_index(GUI::ModelIndex const&);
  21. RefPtr<GUI::Action> m_selected_action;
  22. Vector<NonnullRefPtr<GUI::Action>> m_actions;
  23. RefPtr<GUI::TextBox> m_text_box;
  24. RefPtr<GUI::TableView> m_table_view;
  25. RefPtr<GUI::Model> m_model;
  26. RefPtr<GUI::FilteringProxyModel> m_filter_model;
  27. };
  28. }