1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 04:27:44 +00:00

TextEditor: Switch to using GUI::FontPicker for picking editor font :^)

This commit is contained in:
Andreas Kling 2020-12-30 18:04:55 +01:00
parent 8fe1643c4b
commit 6cec7a2da6
2 changed files with 11 additions and 17 deletions

View file

@ -41,6 +41,7 @@
#include <LibGUI/Button.h>
#include <LibGUI/CppSyntaxHighlighter.h>
#include <LibGUI/FilePicker.h>
#include <LibGUI/FontPicker.h>
#include <LibGUI/GMLSyntaxHighlighter.h>
#include <LibGUI/INISyntaxHighlighter.h>
#include <LibGUI/JSSyntaxHighlighter.h>
@ -55,7 +56,6 @@
#include <LibGUI/ToolBar.h>
#include <LibGUI/ToolBarContainer.h>
#include <LibGfx/Font.h>
#include <LibGfx/FontDatabase.h>
#include <LibMarkdown/Document.h>
#include <LibWeb/OutOfProcessWebView.h>
#include <string.h>
@ -412,6 +412,16 @@ TextEditorWidget::TextEditorWidget()
m_preview_actions.set_exclusive(true);
auto& view_menu = menubar->add_menu("View");
view_menu.add_action(GUI::Action::create("Editor font...", Gfx::Bitmap::load_from_file("/res/icons/16x16/app-font-editor.png"),
[&](auto&) {
auto picker = GUI::FontPicker::construct(window(), &m_editor->font(), true);
if (picker->exec() == GUI::Dialog::ExecOK) {
dbgln("setting font {}", picker->font()->qualified_name());
m_editor->set_font(picker->font());
}
}));
view_menu.add_separator();
view_menu.add_action(*m_line_wrapping_setting_action);
view_menu.add_separator();
view_menu.add_action(*m_no_preview_action);
@ -419,20 +429,6 @@ 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");
Gfx::FontDatabase::the().for_each_fixed_width_font([&](const Gfx::Font& font) {
auto action = GUI::Action::create_checkable(font.qualified_name(), [&](auto&) {
m_editor->set_font(font);
m_editor->update();
});
if (m_editor->font().qualified_name() == font.qualified_name())
action->set_checked(true);
font_actions.add_action(*action);
font_menu.add_action(*action);
});
syntax_actions.set_exclusive(true);
auto& syntax_menu = view_menu.add_submenu("Syntax");

View file

@ -113,8 +113,6 @@ private:
RefPtr<Web::OutOfProcessWebView> m_page_view;
GUI::ActionGroup font_actions;
bool m_document_dirty { false };
bool m_document_opening { false };
bool m_auto_detect_preview_mode { false };