diff --git a/Userland/Applications/HexEditor/HexEditorWidget.cpp b/Userland/Applications/HexEditor/HexEditorWidget.cpp index ba99de4200..5af21b9191 100644 --- a/Userland/Applications/HexEditor/HexEditorWidget.cpp +++ b/Userland/Applications/HexEditor/HexEditorWidget.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -32,6 +33,9 @@ REGISTER_WIDGET(HexEditor, HexEditor); HexEditorWidget::HexEditorWidget() { load_from_gml(hex_editor_window_gml); + + m_config = Core::ConfigFile::get_for_app("HexEditor"); + m_toolbar = *find_descendant_of_type_named("toolbar"); m_toolbar_container = *find_descendant_of_type_named("toolbar_container"); m_editor = *find_descendant_of_type_named("editor"); @@ -148,6 +152,8 @@ HexEditorWidget::HexEditorWidget() m_layout_toolbar_action = GUI::Action::create_checkable("&Toolbar", [&](auto& action) { m_toolbar_container->set_visible(action.is_checked()); + m_config->write_bool_entry("Layout", "ShowToolbar", action.is_checked()); + m_config->sync(); }); m_toolbar->add_action(*m_new_action); @@ -220,18 +226,29 @@ void HexEditorWidget::initialize_menubar(GUI::Menubar& menubar) edit_menu.add_action(*m_goto_offset_action); auto& view_menu = menubar.add_menu("&View"); + + auto show_toolbar = m_config->read_bool_entry("Layout", "ShowToolbar", true); + m_layout_toolbar_action->set_checked(show_toolbar); + m_toolbar_container->set_visible(show_toolbar); + view_menu.add_action(*m_layout_toolbar_action); - m_layout_toolbar_action->set_checked(true); + + auto bytes_per_row = m_config->read_num_entry("Layout", "BytesPerRow", 16); + m_editor->set_bytes_per_row(bytes_per_row); + m_editor->update(); + m_bytes_per_row_actions.set_exclusive(true); auto& bytes_per_row_menu = view_menu.add_submenu("Bytes per &Row"); for (int i = 8; i <= 32; i += 8) { auto action = GUI::Action::create_checkable(String::number(i), [this, i](auto&) { m_editor->set_bytes_per_row(i); m_editor->update(); + m_config->write_num_entry("Layout", "BytesPerRow", i); + m_config->sync(); }); m_bytes_per_row_actions.add_action(action); bytes_per_row_menu.add_action(action); - if (i == 16) + if (i == bytes_per_row) action->set_checked(true); } diff --git a/Userland/Applications/HexEditor/HexEditorWidget.h b/Userland/Applications/HexEditor/HexEditorWidget.h index 6d0b8d1ee9..7344f276a2 100644 --- a/Userland/Applications/HexEditor/HexEditorWidget.h +++ b/Userland/Applications/HexEditor/HexEditorWidget.h @@ -30,6 +30,8 @@ private: void set_path(const LexicalPath& file); void update_title(); + RefPtr m_config; + RefPtr m_editor; String m_path; String m_name;