diff options
author | Andreas Kling <awesomekling@gmail.com> | 2020-01-08 20:45:43 +0100 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2020-01-08 21:12:40 +0100 |
commit | 7ba7d88fbaf691e96adfef2043aae3d3e45e11eb (patch) | |
tree | 0fa128bdbdc14197fbe759a3fba91920c1b2fe44 /Applications/SystemMonitor | |
parent | 463ed77024a5a494c27130a157240d445b0ff922 (diff) | |
download | serenity-7ba7d88fbaf691e96adfef2043aae3d3e45e11eb.zip |
SystemMonitor: Put the Frequency menu items in an action group
This makes them look like radio buttons in the menu, which is a very
nice increase in polish. :^)
Diffstat (limited to 'Applications/SystemMonitor')
-rw-r--r-- | Applications/SystemMonitor/main.cpp | 36 |
1 files changed, 21 insertions, 15 deletions
diff --git a/Applications/SystemMonitor/main.cpp b/Applications/SystemMonitor/main.cpp index 47d4a153a1..7d4bda62ab 100644 --- a/Applications/SystemMonitor/main.cpp +++ b/Applications/SystemMonitor/main.cpp @@ -11,6 +11,7 @@ #include <LibDraw/PNGLoader.h> #include <LibGUI/GAboutDialog.h> #include <LibGUI/GAction.h> +#include <LibGUI/GActionGroup.h> #include <LibGUI/GApplication.h> #include <LibGUI/GBoxLayout.h> #include <LibGUI/GGroupBox.h> @@ -138,21 +139,26 @@ int main(int argc, char** argv) }; auto frequency_menu = GMenu::construct("Frequency"); - frequency_menu->add_action(GAction::create("0.25 sec", [&](auto&) { - refresh_timer->restart(250); - })); - frequency_menu->add_action(GAction::create("0.5 sec", [&](auto&) { - refresh_timer->restart(500); - })); - frequency_menu->add_action(GAction::create("1 sec", [&](auto&) { - refresh_timer->restart(1000); - })); - frequency_menu->add_action(GAction::create("3 sec", [&](auto&) { - refresh_timer->restart(3000); - })); - frequency_menu->add_action(GAction::create("5 sec", [&](auto&) { - refresh_timer->restart(5000); - })); + GActionGroup frequency_action_group; + frequency_action_group.set_exclusive(true); + + auto make_frequency_action = [&](auto& title, int interval, bool checked = false) { + auto action = GAction::create(title, [&refresh_timer, interval](auto& action) { + 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); + }; + + make_frequency_action("0.25 sec", 250); + make_frequency_action("0.5 sec", 500); + make_frequency_action("1 sec", 1000, true); + make_frequency_action("3 sec", 3000); + make_frequency_action("5 sec", 5000); + menubar->add_menu(move(frequency_menu)); auto help_menu = GMenu::construct("Help"); |