mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 12:38:12 +00:00
LibGUI: Add GActionGroup, a way to group a bunch of GActions.
This can be used to make a bunch of actions mutually exclusive. This patch only implements the exclusivity behavior for buttons.
This commit is contained in:
parent
2ae0333f5d
commit
7083a0104a
9 changed files with 97 additions and 6 deletions
|
@ -2,6 +2,7 @@
|
|||
#include <AK/FileSystemPath.h>
|
||||
#include <LibCore/CUserInfo.h>
|
||||
#include <LibGUI/GAction.h>
|
||||
#include <LibGUI/GActionGroup.h>
|
||||
#include <LibGUI/GApplication.h>
|
||||
#include <LibGUI/GBoxLayout.h>
|
||||
#include <LibGUI/GFileSystemModel.h>
|
||||
|
@ -108,18 +109,21 @@ int main(int argc, char** argv)
|
|||
|
||||
view_as_table_action = GAction::create("Table view", { Mod_Ctrl, KeyCode::Key_L }, GraphicsBitmap::load_from_file("/res/icons/16x16/table-view.png"), [&](const GAction&) {
|
||||
directory_view->set_view_mode(DirectoryView::ViewMode::List);
|
||||
view_as_icons_action->set_checked(false);
|
||||
view_as_table_action->set_checked(true);
|
||||
});
|
||||
view_as_table_action->set_checkable(true);
|
||||
view_as_table_action->set_checked(false);
|
||||
|
||||
view_as_icons_action = GAction::create("Icon view", { Mod_Ctrl, KeyCode::Key_I }, GraphicsBitmap::load_from_file("/res/icons/16x16/icon-view.png"), [&](const GAction&) {
|
||||
directory_view->set_view_mode(DirectoryView::ViewMode::Icon);
|
||||
view_as_table_action->set_checked(false);
|
||||
view_as_icons_action->set_checked(true);
|
||||
});
|
||||
view_as_icons_action->set_checkable(true);
|
||||
|
||||
auto view_type_action_group = make<GActionGroup>();
|
||||
view_type_action_group->set_exclusive(true);
|
||||
view_type_action_group->add_action(*view_as_table_action);
|
||||
view_type_action_group->add_action(*view_as_icons_action);
|
||||
|
||||
view_as_icons_action->set_checked(true);
|
||||
|
||||
auto copy_action = GAction::create("Copy", GraphicsBitmap::load_from_file("/res/icons/16x16/edit-copy.png"), [](const GAction&) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue