summaryrefslogtreecommitdiff
path: root/Applications
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-12-30 18:04:55 +0100
committerAndreas Kling <kling@serenityos.org>2020-12-30 20:37:51 +0100
commit6cec7a2da6ea02535d40733a02a7ca0be28d238e (patch)
treec899d1cfc9d12cbf5bf7ba75570ef7f179eb9dd1 /Applications
parent8fe1643c4bbec97286791233e979a6d0b9d4747a (diff)
downloadserenity-6cec7a2da6ea02535d40733a02a7ca0be28d238e.zip
TextEditor: Switch to using GUI::FontPicker for picking editor font :^)
Diffstat (limited to 'Applications')
-rw-r--r--Applications/TextEditor/TextEditorWidget.cpp26
-rw-r--r--Applications/TextEditor/TextEditorWidget.h2
2 files changed, 11 insertions, 17 deletions
diff --git a/Applications/TextEditor/TextEditorWidget.cpp b/Applications/TextEditor/TextEditorWidget.cpp
index 53d1ae80bb..31d0c7b097 100644
--- a/Applications/TextEditor/TextEditorWidget.cpp
+++ b/Applications/TextEditor/TextEditorWidget.cpp
@@ -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");
diff --git a/Applications/TextEditor/TextEditorWidget.h b/Applications/TextEditor/TextEditorWidget.h
index 3320096f50..2794b22244 100644
--- a/Applications/TextEditor/TextEditorWidget.h
+++ b/Applications/TextEditor/TextEditorWidget.h
@@ -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 };