mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 21:52:45 +00:00 
			
		
		
		
	HexEditor: Use LibConfig instead of Core::ConfigFile
This commit is contained in:
		
							parent
							
								
									7b62113db7
								
							
						
					
					
						commit
						22a1035f1b
					
				
					 4 changed files with 10 additions and 12 deletions
				
			
		|  | @ -20,4 +20,4 @@ set(SOURCES | |||
| ) | ||||
| 
 | ||||
| serenity_app(HexEditor ICON app-hex-editor) | ||||
| target_link_libraries(HexEditor LibGUI) | ||||
| target_link_libraries(HexEditor LibGUI LibConfig) | ||||
|  |  | |||
|  | @ -1,5 +1,6 @@ | |||
| /*
 | ||||
|  * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org> | ||||
|  * Copyright (c) 2021, Mustafa Quraish <mustafa@cs.toronto.edu> | ||||
|  * | ||||
|  * SPDX-License-Identifier: BSD-2-Clause | ||||
|  */ | ||||
|  | @ -11,7 +12,7 @@ | |||
| #include <AK/Optional.h> | ||||
| #include <AK/StringBuilder.h> | ||||
| #include <Applications/HexEditor/HexEditorWindowGML.h> | ||||
| #include <LibCore/ConfigFile.h> | ||||
| #include <LibConfig/Client.h> | ||||
| #include <LibCore/File.h> | ||||
| #include <LibGUI/Action.h> | ||||
| #include <LibGUI/BoxLayout.h> | ||||
|  | @ -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<GUI::Toolbar>("toolbar"); | ||||
|     m_toolbar_container = *find_descendant_of_type_named<GUI::ToolbarContainer>("toolbar_container"); | ||||
|     m_editor = *find_descendant_of_type_named<HexEditor>("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); | ||||
|  |  | |||
|  | @ -33,8 +33,6 @@ private: | |||
| 
 | ||||
|     virtual void drop_event(GUI::DropEvent&) override; | ||||
| 
 | ||||
|     RefPtr<Core::ConfigFile> m_config; | ||||
| 
 | ||||
|     RefPtr<HexEditor> m_editor; | ||||
|     String m_path; | ||||
|     String m_name; | ||||
|  |  | |||
|  | @ -5,6 +5,7 @@ | |||
|  */ | ||||
| 
 | ||||
| #include "HexEditorWidget.h" | ||||
| #include <LibConfig/Client.h> | ||||
| #include <LibGUI/Icon.h> | ||||
| #include <LibGUI/Menubar.h> | ||||
| #include <stdio.h> | ||||
|  | @ -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; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Mustafa Quraish
						Mustafa Quraish