diff options
author | Andreas Kling <kling@serenityos.org> | 2020-04-21 17:19:27 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-04-21 17:21:28 +0200 |
commit | 705cee528a803b1671d16eeaf222d3318708500b (patch) | |
tree | a80dc8135ed1a15fddd4c26c0e52fd2c241820e7 /Applications/FileManager | |
parent | 1032ae014053ccf5482b78465f02554165212ba9 (diff) | |
download | serenity-705cee528a803b1671d16eeaf222d3318708500b.zip |
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.
Diffstat (limited to 'Applications/FileManager')
-rw-r--r-- | Applications/FileManager/main.cpp | 15 |
1 files changed, 3 insertions, 12 deletions
diff --git a/Applications/FileManager/main.cpp b/Applications/FileManager/main.cpp index c37b8d3deb..d0c1044c14 100644 --- a/Applications/FileManager/main.cpp +++ b/Applications/FileManager/main.cpp @@ -283,38 +283,29 @@ int run_in_windowed_mode(RefPtr<Core::ConfigFile> config, String initial_locatio RefPtr<GUI::Action> view_as_icons_action; RefPtr<GUI::Action> view_as_columns_action; - view_as_table_action = GUI::Action::create( + view_as_table_action = GUI::Action::create_checkable( "Table view", { Mod_Ctrl, KeyCode::Key_L }, Gfx::Bitmap::load_from_file("/res/icons/16x16/table-view.png"), [&](const GUI::Action&) { directory_view.set_view_mode(DirectoryView::ViewMode::List); - view_as_table_action->set_checked(true); - config->write_entry("DirectoryView", "ViewMode", "List"); config->sync(); }, window); - view_as_table_action->set_checkable(true); - view_as_icons_action = GUI::Action::create( + view_as_icons_action = GUI::Action::create_checkable( "Icon view", { Mod_Ctrl, KeyCode::Key_I }, Gfx::Bitmap::load_from_file("/res/icons/16x16/icon-view.png"), [&](const GUI::Action&) { directory_view.set_view_mode(DirectoryView::ViewMode::Icon); - view_as_icons_action->set_checked(true); - config->write_entry("DirectoryView", "ViewMode", "Icon"); config->sync(); }, window); - view_as_icons_action->set_checkable(true); - view_as_columns_action = GUI::Action::create( + view_as_columns_action = GUI::Action::create_checkable( "Columns view", Gfx::Bitmap::load_from_file("/res/icons/16x16/columns-view.png"), [&](const GUI::Action&) { directory_view.set_view_mode(DirectoryView::ViewMode::Columns); - view_as_columns_action->set_checked(true); - config->write_entry("DirectoryView", "ViewMode", "Columns"); config->sync(); }, window); - view_as_columns_action->set_checkable(true); auto view_type_action_group = make<GUI::ActionGroup>(); view_type_action_group->set_exclusive(true); |