diff --git a/Userland/Libraries/LibGUI/CommandPalette.cpp b/Userland/Libraries/LibGUI/CommandPalette.cpp index 53e9d55f62..8896afaaf7 100644 --- a/Userland/Libraries/LibGUI/CommandPalette.cpp +++ b/Userland/Libraries/LibGUI/CommandPalette.cpp @@ -1,5 +1,6 @@ /* * Copyright (c) 2022, Andreas Kling + * Copyright (c) 2022, Jakob-Niklas See * * SPDX-License-Identifier: BSD-2-Clause */ @@ -11,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -18,6 +20,25 @@ namespace GUI { +class IconOrRadioButtonDelegate final : public GUI::TableCellPaintingDelegate { +public: + virtual ~IconOrRadioButtonDelegate() override { } + + bool should_paint(ModelIndex const& index) override + { + return index.data().is_bool(); + } + + virtual void paint(GUI::Painter& painter, Gfx::IntRect const& cell_rect, Gfx::Palette const& palette, ModelIndex const& index) override + { + auto checked = index.data().as_bool(); + + Gfx::IntRect radio_rect { 0, 0, 12, 12 }; + radio_rect.center_within(cell_rect); + Gfx::StylePainter::paint_radio_button(painter, radio_rect, palette, checked, false); + } +}; + class ActionModel final : public GUI::Model { public: enum Column { @@ -64,6 +85,8 @@ public: case Column::Icon: if (action.icon()) return *action.icon(); + if (action.is_checkable()) + return action.is_checked(); return ""; case Column::Text: return Gfx::parse_ampersand_string(action.text()); @@ -112,6 +135,7 @@ CommandPalette::CommandPalette(GUI::Window& parent_window, ScreenPosition screen m_filter_model = MUST(GUI::FilteringProxyModel::create(*m_model)); m_filter_model->set_filter_term(""); + m_table_view->set_column_painting_delegate(0, make()); m_table_view->set_model(*m_filter_model); m_text_box->on_change = [this] {