diff options
author | thankyouverycool <66646555+thankyouverycool@users.noreply.github.com> | 2020-08-16 12:54:11 -0400 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-08-16 19:39:06 +0200 |
commit | 15cb4207fc5797f7a9027d788bf962411a1200bd (patch) | |
tree | 3c4c6b521d268a493fb6ce1958305b17b46bc24d | |
parent | 4a57cbc98f70e4365470fa6f6c50fea1cfcf0dfb (diff) | |
download | serenity-15cb4207fc5797f7a9027d788bf962411a1200bd.zip |
TextEditor: Put fonts in exclusive action group
-rw-r--r-- | Applications/TextEditor/TextEditorWidget.cpp | 10 | ||||
-rw-r--r-- | Applications/TextEditor/TextEditorWidget.h | 2 |
2 files changed, 10 insertions, 2 deletions
diff --git a/Applications/TextEditor/TextEditorWidget.cpp b/Applications/TextEditor/TextEditorWidget.cpp index 3847685388..6745f270a9 100644 --- a/Applications/TextEditor/TextEditorWidget.cpp +++ b/Applications/TextEditor/TextEditorWidget.cpp @@ -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); diff --git a/Applications/TextEditor/TextEditorWidget.h b/Applications/TextEditor/TextEditorWidget.h index 92bf25bd47..856ca15e11 100644 --- a/Applications/TextEditor/TextEditorWidget.h +++ b/Applications/TextEditor/TextEditorWidget.h @@ -106,6 +106,8 @@ private: RefPtr<Web::PageView> m_page_view; + GUI::ActionGroup font_actions; + bool m_document_dirty { false }; bool m_document_opening { false }; bool m_auto_detect_preview_mode { false }; |