From 705cee528a803b1671d16eeaf222d3318708500b Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Tue, 21 Apr 2020 17:19:27 +0200 Subject: 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. --- Applications/SystemMonitor/main.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'Applications/SystemMonitor') diff --git a/Applications/SystemMonitor/main.cpp b/Applications/SystemMonitor/main.cpp index eefd7a4980..ca2a27afce 100644 --- a/Applications/SystemMonitor/main.cpp +++ b/Applications/SystemMonitor/main.cpp @@ -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); -- cgit v1.2.3