summaryrefslogtreecommitdiff
path: root/Userland/Applications/FontEditor/MainWidget.cpp
diff options
context:
space:
mode:
authorthankyouverycool <66646555+thankyouverycool@users.noreply.github.com>2022-08-14 15:56:54 -0400
committerAndreas Kling <kling@serenityos.org>2022-11-19 15:41:09 +0100
commitc974e644ec42121326e600775a3f1a277e58e5fd (patch)
treeb1776a1405595ca71b4893bdc6c0ec15569b384c /Userland/Applications/FontEditor/MainWidget.cpp
parent61d93092cf5b1ddf64b6cd825921d773d9041980 (diff)
downloadserenity-c974e644ec42121326e600775a3f1a277e58e5fd.zip
FontEditor: Add Layout options to View menu
Like other apps, FontEditor now organizes widget visibility toggles under a View->Layout submenu. The main toolbar and the status bar can now be turned on and off.
Diffstat (limited to 'Userland/Applications/FontEditor/MainWidget.cpp')
-rw-r--r--Userland/Applications/FontEditor/MainWidget.cpp47
1 files changed, 44 insertions, 3 deletions
diff --git a/Userland/Applications/FontEditor/MainWidget.cpp b/Userland/Applications/FontEditor/MainWidget.cpp
index 1f07315813..306aefbdc0 100644
--- a/Userland/Applications/FontEditor/MainWidget.cpp
+++ b/Userland/Applications/FontEditor/MainWidget.cpp
@@ -204,6 +204,24 @@ ErrorOr<void> MainWidget::create_actions()
m_show_unicode_blocks_action->set_checked(show_unicode_blocks);
m_show_unicode_blocks_action->set_status_tip("Show or hide the Unicode block list");
+ bool show_toolbar = Config::read_bool("FontEditor"sv, "Layout"sv, "ShowToolbar"sv, true);
+ set_show_toolbar(show_toolbar);
+ m_show_toolbar_action = GUI::Action::create_checkable("&Toolbar", [&](auto& action) {
+ set_show_toolbar(action.is_checked());
+ Config::write_bool("FontEditor"sv, "Layout"sv, "ShowToolbar"sv, action.is_checked());
+ });
+ m_show_toolbar_action->set_checked(show_toolbar);
+ m_show_toolbar_action->set_status_tip("Show or hide the toolbar");
+
+ bool show_statusbar = Config::read_bool("FontEditor"sv, "Layout"sv, "ShowStatusbar"sv, true);
+ set_show_statusbar(show_statusbar);
+ m_show_statusbar_action = GUI::Action::create_checkable("&Status Bar", [&](auto& action) {
+ set_show_statusbar(action.is_checked());
+ Config::write_bool("FontEditor"sv, "Layout"sv, "ShowStatusbar"sv, action.is_checked());
+ });
+ m_show_statusbar_action->set_checked(show_statusbar);
+ m_show_statusbar_action->set_status_tip("Show or hide the status bar");
+
bool highlight_modifications = Config::read_bool("FontEditor"sv, "Display"sv, "HighlightModifications"sv, true);
set_highlight_modifications(highlight_modifications);
m_highlight_modifications_action = GUI::Action::create_checkable("&Highlight Modifications", { Mod_Ctrl, Key_H }, [&](auto& action) {
@@ -395,6 +413,7 @@ MainWidget::MainWidget()
m_font_metadata_groupbox = find_descendant_of_type_named<GUI::GroupBox>("font_metadata_groupbox");
m_unicode_block_container = find_descendant_of_type_named<GUI::Widget>("unicode_block_container");
+ m_toolbar_container = find_descendant_of_type_named<GUI::ToolbarContainer>("toolbar_container");
m_glyph_map_widget = find_descendant_of_type_named<GUI::GlyphMapWidget>("glyph_map_widget");
m_glyph_editor_widget = find_descendant_of_type_named<GlyphEditorWidget>("glyph_editor_widget");
@@ -656,10 +675,13 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
TRY(go_menu->try_add_action(*m_go_to_glyph_action));
auto view_menu = TRY(window.try_add_menu("&View"));
- TRY(view_menu->try_add_action(*m_open_preview_action));
+ auto layout_menu = TRY(view_menu->try_add_submenu("&Layout"));
+ TRY(layout_menu->try_add_action(*m_show_toolbar_action));
+ TRY(layout_menu->try_add_action(*m_show_statusbar_action));
+ TRY(layout_menu->try_add_action(*m_show_metadata_action));
+ TRY(layout_menu->try_add_action(*m_show_unicode_blocks_action));
TRY(view_menu->try_add_separator());
- TRY(view_menu->try_add_action(*m_show_metadata_action));
- TRY(view_menu->try_add_action(*m_show_unicode_blocks_action));
+ TRY(view_menu->try_add_action(*m_open_preview_action));
TRY(view_menu->try_add_separator());
TRY(view_menu->try_add_action(*m_highlight_modifications_action));
TRY(view_menu->try_add_separator());
@@ -689,6 +711,22 @@ ErrorOr<void> MainWidget::save_file(String const& path)
return {};
}
+void MainWidget::set_show_toolbar(bool show)
+{
+ if (m_toolbar_container->is_visible() == show)
+ return;
+ m_toolbar_container->set_visible(show);
+}
+
+void MainWidget::set_show_statusbar(bool show)
+{
+ if (m_statusbar->is_visible() == show)
+ return;
+ m_statusbar->set_visible(show);
+ if (show)
+ update_statusbar();
+}
+
void MainWidget::set_show_font_metadata(bool show)
{
if (m_font_metadata == show)
@@ -838,6 +876,9 @@ void MainWidget::did_modify_font()
void MainWidget::update_statusbar()
{
+ if (!m_statusbar->is_visible())
+ return;
+
auto glyph = m_glyph_map_widget->active_glyph();
StringBuilder builder;
builder.appendff("U+{:04X} (", glyph);