diff --git a/Userland/Applications/HexEditor/CMakeLists.txt b/Userland/Applications/HexEditor/CMakeLists.txt index 18bad55a26..8de66fdfea 100644 --- a/Userland/Applications/HexEditor/CMakeLists.txt +++ b/Userland/Applications/HexEditor/CMakeLists.txt @@ -20,4 +20,4 @@ set(SOURCES ) serenity_app(HexEditor ICON app-hex-editor) -target_link_libraries(HexEditor LibGUI) +target_link_libraries(HexEditor LibGUI LibConfig) diff --git a/Userland/Applications/HexEditor/HexEditorWidget.cpp b/Userland/Applications/HexEditor/HexEditorWidget.cpp index 495e898eb1..0e76e78223 100644 --- a/Userland/Applications/HexEditor/HexEditorWidget.cpp +++ b/Userland/Applications/HexEditor/HexEditorWidget.cpp @@ -1,5 +1,6 @@ /* * Copyright (c) 2018-2020, Andreas Kling + * Copyright (c) 2021, Mustafa Quraish * * SPDX-License-Identifier: BSD-2-Clause */ @@ -11,7 +12,7 @@ #include #include #include -#include +#include #include #include #include @@ -35,8 +36,6 @@ HexEditorWidget::HexEditorWidget() { load_from_gml(hex_editor_window_gml); - m_config = Core::ConfigFile::open_for_app("HexEditor", Core::ConfigFile::AllowWriting::Yes); - 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"); @@ -185,8 +184,7 @@ 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(); + Config::write_bool("HexEditor", "Layout", "ShowToolbar", action.is_checked()); }); m_layout_search_results_action = GUI::Action::create_checkable("&Search Results", [&](auto& action) { @@ -279,14 +277,14 @@ void HexEditorWidget::initialize_menubar(GUI::Window& window) auto& view_menu = window.add_menu("&View"); - auto show_toolbar = m_config->read_bool_entry("Layout", "ShowToolbar", true); + auto show_toolbar = Config::read_bool("HexEditor", "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); view_menu.add_action(*m_layout_search_results_action); view_menu.add_separator(); - auto bytes_per_row = m_config->read_num_entry("Layout", "BytesPerRow", 16); + auto bytes_per_row = Config::read_i32("HexEditor", "Layout", "BytesPerRow", 16); m_editor->set_bytes_per_row(bytes_per_row); m_editor->update(); @@ -296,8 +294,7 @@ void HexEditorWidget::initialize_menubar(GUI::Window& window) 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(); + Config::write_i32("HexEditor", "Layout", "BytesPerRow", i); }); m_bytes_per_row_actions.add_action(action); bytes_per_row_menu.add_action(action); diff --git a/Userland/Applications/HexEditor/HexEditorWidget.h b/Userland/Applications/HexEditor/HexEditorWidget.h index 55baa42ecf..28e338df30 100644 --- a/Userland/Applications/HexEditor/HexEditorWidget.h +++ b/Userland/Applications/HexEditor/HexEditorWidget.h @@ -33,8 +33,6 @@ private: virtual void drop_event(GUI::DropEvent&) override; - RefPtr m_config; - RefPtr m_editor; String m_path; String m_name; diff --git a/Userland/Applications/HexEditor/main.cpp b/Userland/Applications/HexEditor/main.cpp index 7ec1c22359..46d0074023 100644 --- a/Userland/Applications/HexEditor/main.cpp +++ b/Userland/Applications/HexEditor/main.cpp @@ -5,6 +5,7 @@ */ #include "HexEditorWidget.h" +#include #include #include #include @@ -19,6 +20,8 @@ int main(int argc, char** argv) auto app = GUI::Application::construct(argc, argv); + Config::pledge_domains("HexEditor"); + if (pledge("stdio recvfd sendfd rpath cpath wpath thread", nullptr) < 0) { perror("pledge"); return 1;