1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-29 17:25:10 +00:00

TextEditor: Put fonts in exclusive action group

This commit is contained in:
thankyouverycool 2020-08-16 12:54:11 -04:00 committed by Andreas Kling
parent 4a57cbc98f
commit 15cb4207fc
2 changed files with 10 additions and 2 deletions

View file

@ -429,12 +429,18 @@ TextEditorWidget::TextEditorWidget()
view_menu.add_action(*m_html_preview_action);
view_menu.add_separator();
font_actions.set_exclusive(true);
auto& font_menu = view_menu.add_submenu("Font");
GUI::FontDatabase::the().for_each_fixed_width_font([&](const StringView& font_name) {
font_menu.add_action(GUI::Action::create(font_name, [this](const GUI::Action& action) {
auto action = GUI::Action::create_checkable(font_name, [&](auto& action) {
m_editor->set_font(GUI::FontDatabase::the().get_by_name(action.text()));
m_editor->update();
}));
});
if (m_editor->font().name() == font_name)
action->set_checked(true);
font_actions.add_action(*action);
font_menu.add_action(*action);
});
syntax_actions.set_exclusive(true);