1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-28 01:25:09 +00:00

LibGUI: Make it easier to create checkable GUI::Actions

This patch adds GUI::Action::create_checkable() helpers that work just
like the existing create() helpers, but the actions become checkable(!)

Clients are no longer required to manage the checked state of their
actions manually, but instead they will be checked/unchecked as needed
by GUI::Action itself before the activation hook is fired.
This commit is contained in:
Andreas Kling 2020-04-21 17:19:27 +02:00
parent 1032ae0140
commit 705cee528a
18 changed files with 135 additions and 158 deletions

View file

@ -165,27 +165,21 @@ void MultiView::set_column_hidden(int column_index, bool hidden)
void MultiView::build_actions()
{
m_view_as_table_action = Action::create(
m_view_as_table_action = Action::create_checkable(
"Table view", Gfx::Bitmap::load_from_file("/res/icons/16x16/table-view.png"), [this](auto&) {
set_view_mode(ViewMode::List);
m_view_as_table_action->set_checked(true);
});
m_view_as_table_action->set_checkable(true);
m_view_as_icons_action = Action::create(
m_view_as_icons_action = Action::create_checkable(
"Icon view", Gfx::Bitmap::load_from_file("/res/icons/16x16/icon-view.png"), [this](auto&) {
set_view_mode(ViewMode::Icon);
m_view_as_icons_action->set_checked(true);
});
m_view_as_icons_action->set_checkable(true);
#ifdef MULTIVIEW_WITH_COLUMNSVIEW
m_view_as_columns_action = Action::create(
m_view_as_columns_action = Action::create_checkable(
"Columns view", Gfx::Bitmap::load_from_file("/res/icons/16x16/columns-view.png"), [this](auto&) {
set_view_mode(ViewMode::Columns);
m_view_as_columns_action->set_checked(true);
});
m_view_as_columns_action->set_checkable(true);
#endif
m_view_type_action_group = make<ActionGroup>();