mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-05 08:06: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:
@@ -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>();
|
||||
|
||||
Reference in New Issue
Block a user