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/SoundPlayer | |
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/SoundPlayer')
-rw-r--r-- | Applications/SoundPlayer/main.cpp | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/Applications/SoundPlayer/main.cpp b/Applications/SoundPlayer/main.cpp index c2ad025f34..e5477d0296 100644 --- a/Applications/SoundPlayer/main.cpp +++ b/Applications/SoundPlayer/main.cpp @@ -74,11 +74,9 @@ int main(int argc, char** argv) player.manager().play(); } - auto hide_scope = GUI::Action::create("Hide scope", { Mod_Ctrl, Key_H }, [&](GUI::Action& action) { - action.set_checked(!action.is_checked()); + auto hide_scope = GUI::Action::create_checkable("Hide scope", { Mod_Ctrl, Key_H }, [&](auto& action) { player.hide_scope(action.is_checked()); }); - hide_scope->set_checkable(true); app_menu.add_action(GUI::CommonActions::make_open_action([&](auto&) { Optional<String> path = GUI::FilePicker::get_open_filepath("Open wav file..."); |