1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 08:58:11 +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

@ -200,11 +200,9 @@ int main(int argc, char** argv)
frequency_action_group.set_exclusive(true);
auto make_frequency_action = [&](auto& title, int interval, bool checked = false) {
auto action = GUI::Action::create(title, [&refresh_timer, interval](auto& action) {
auto action = GUI::Action::create_checkable(title, [&refresh_timer, interval](auto&) {
refresh_timer.restart(interval);
action.set_checked(true);
});
action->set_checkable(true);
action->set_checked(checked);
frequency_action_group.add_action(*action);
frequency_menu.add_action(*action);