diff options
author | Andreas Kling <awesomekling@gmail.com> | 2020-01-08 20:56:11 +0100 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2020-01-08 21:12:40 +0100 |
commit | 53e204dfb0fcd8f3be1c403c0eba24ec949735f5 (patch) | |
tree | 5465a03fb180437d9a1a95735994df65af53884b /Applications/Terminal/main.cpp | |
parent | 7ba7d88fbaf691e96adfef2043aae3d3e45e11eb (diff) | |
download | serenity-53e204dfb0fcd8f3be1c403c0eba24ec949735f5.zip |
Terminal: Put the Font menu items in an action group :^)
Diffstat (limited to 'Applications/Terminal/main.cpp')
-rw-r--r-- | Applications/Terminal/main.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/Applications/Terminal/main.cpp b/Applications/Terminal/main.cpp index 235a48e286..7cea2de4f1 100644 --- a/Applications/Terminal/main.cpp +++ b/Applications/Terminal/main.cpp @@ -4,6 +4,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/GFontDatabase.h> @@ -223,16 +224,25 @@ int main(int argc, char** argv) edit_menu->add_action(terminal->paste_action()); menubar->add_menu(move(edit_menu)); + + GActionGroup font_action_group; + font_action_group.set_exclusive(true); auto font_menu = GMenu::construct("Font"); GFontDatabase::the().for_each_fixed_width_font([&](const StringView& font_name) { - font_menu->add_action(GAction::create(font_name, [&](const GAction& action) { + auto action = GAction::create(font_name, [&](GAction& action) { + action.set_checked(true); terminal->set_font(GFontDatabase::the().get_by_name(action.text())); auto metadata = GFontDatabase::the().get_metadata_by_name(action.text()); ASSERT(metadata.has_value()); config->write_entry("Text", "Font", metadata.value().path); config->sync(); terminal->force_repaint(); - })); + }); + font_action_group.add_action(*action); + action->set_checkable(true); + if (terminal->font().name() == font_name) + action->set_checked(true); + font_menu->add_action(*action); }); menubar->add_menu(move(font_menu)); |