mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +00:00
TextEditor: Use LibConfig instead of Core::ConfigFile
This commit is contained in:
parent
3114fe612c
commit
0cd4b8cbb7
Notes:
sideshowbarker
2024-07-18 05:17:00 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/0cd4b8cbb75
4 changed files with 11 additions and 31 deletions
|
@ -15,4 +15,4 @@ set(SOURCES
|
|||
)
|
||||
|
||||
serenity_app(TextEditor ICON app-text-editor)
|
||||
target_link_libraries(TextEditor LibWeb LibMarkdown LibGUI LibShell LibRegex LibDesktop LibCpp LibJS LibSQL LibFileSystemAccessClient)
|
||||
target_link_libraries(TextEditor LibWeb LibMarkdown LibGUI LibShell LibRegex LibDesktop LibCpp LibJS LibSQL LibFileSystemAccessClient LibConfig)
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include <AK/StringBuilder.h>
|
||||
#include <AK/URL.h>
|
||||
#include <Applications/TextEditor/TextEditorWindowGML.h>
|
||||
#include <LibConfig/Client.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCpp/SyntaxHighlighter.h>
|
||||
#include <LibDesktop/Launcher.h>
|
||||
|
@ -46,8 +47,6 @@ MainWidget::MainWidget()
|
|||
{
|
||||
load_from_gml(text_editor_window_gml);
|
||||
|
||||
m_config = open_config_file();
|
||||
|
||||
m_toolbar = *find_descendant_of_type_named<GUI::Toolbar>("toolbar");
|
||||
m_toolbar_container = *find_descendant_of_type_named<GUI::ToolbarContainer>("toolbar_container");
|
||||
|
||||
|
@ -344,15 +343,6 @@ MainWidget::~MainWidget()
|
|||
{
|
||||
}
|
||||
|
||||
static RefPtr<Core::ConfigFile> s_config;
|
||||
|
||||
RefPtr<Core::ConfigFile> MainWidget::open_config_file()
|
||||
{
|
||||
if (!s_config)
|
||||
s_config = Core::ConfigFile::open_for_app("TextEditor", Core::ConfigFile::AllowWriting::Yes);
|
||||
return s_config;
|
||||
}
|
||||
|
||||
Web::OutOfProcessWebView& MainWidget::ensure_web_view()
|
||||
{
|
||||
if (!m_page_view) {
|
||||
|
@ -432,28 +422,25 @@ void MainWidget::initialize_menubar(GUI::Window& window)
|
|||
|
||||
m_layout_toolbar_action = GUI::Action::create_checkable("&Toolbar", [&](auto& action) {
|
||||
action.is_checked() ? m_toolbar_container->set_visible(true) : m_toolbar_container->set_visible(false);
|
||||
m_config->write_bool_entry("Layout", "ShowToolbar", action.is_checked());
|
||||
m_config->sync();
|
||||
Config::write_bool("TextEditor", "Layout", "ShowToolbar", action.is_checked());
|
||||
});
|
||||
auto show_toolbar = m_config->read_bool_entry("Layout", "ShowToolbar", true);
|
||||
auto show_toolbar = Config::read_bool("TextEditor", "Layout", "ShowToolbar", true);
|
||||
m_layout_toolbar_action->set_checked(show_toolbar);
|
||||
m_toolbar_container->set_visible(show_toolbar);
|
||||
|
||||
m_layout_statusbar_action = GUI::Action::create_checkable("&Status Bar", [&](auto& action) {
|
||||
action.is_checked() ? m_statusbar->set_visible(true) : m_statusbar->set_visible(false);
|
||||
m_config->write_bool_entry("Layout", "ShowStatusbar", action.is_checked());
|
||||
m_config->sync();
|
||||
Config::write_bool("TextEditor", "Layout", "ShowStatusbar", action.is_checked());
|
||||
});
|
||||
auto show_statusbar = m_config->read_bool_entry("Layout", "ShowStatusbar", true);
|
||||
auto show_statusbar = Config::read_bool("TextEditor", "Layout", "ShowStatusbar", true);
|
||||
m_layout_statusbar_action->set_checked(show_statusbar);
|
||||
m_statusbar->set_visible(show_statusbar);
|
||||
|
||||
m_layout_ruler_action = GUI::Action::create_checkable("Ruler", [&](auto& action) {
|
||||
action.is_checked() ? m_editor->set_ruler_visible(true) : m_editor->set_ruler_visible(false);
|
||||
m_config->write_bool_entry("Layout", "ShowRuler", action.is_checked());
|
||||
m_config->sync();
|
||||
Config::write_bool("TextEditor", "Layout", "ShowRuler", action.is_checked());
|
||||
});
|
||||
auto show_ruler = m_config->read_bool_entry("Layout", "ShowRuler", true);
|
||||
auto show_ruler = Config::read_bool("TextEditor", "Layout", "ShowRuler", true);
|
||||
m_layout_ruler_action->set_checked(show_ruler);
|
||||
m_editor->set_ruler_visible(show_ruler);
|
||||
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
|
||||
#include <AK/Function.h>
|
||||
#include <AK/LexicalPath.h>
|
||||
#include <LibCore/ConfigFile.h>
|
||||
#include <LibFileSystemAccessClient/Client.h>
|
||||
#include <LibGUI/ActionGroup.h>
|
||||
#include <LibGUI/Application.h>
|
||||
|
@ -43,8 +42,6 @@ public:
|
|||
void update_title();
|
||||
void initialize_menubar(GUI::Window&);
|
||||
|
||||
static RefPtr<Core::ConfigFile> open_config_file();
|
||||
|
||||
private:
|
||||
MainWidget();
|
||||
void set_path(StringView const&);
|
||||
|
@ -126,7 +123,6 @@ private:
|
|||
RefPtr<GUI::Action> m_sql_highlight;
|
||||
|
||||
RefPtr<Web::OutOfProcessWebView> m_page_view;
|
||||
RefPtr<Core::ConfigFile> m_config;
|
||||
|
||||
bool m_auto_detect_preview_mode { false };
|
||||
bool m_use_regex { false };
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include "FileArgument.h"
|
||||
#include "MainWidget.h"
|
||||
#include <LibConfig/Client.h>
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/StandardPaths.h>
|
||||
|
@ -23,6 +24,8 @@ int main(int argc, char** argv)
|
|||
|
||||
auto app = GUI::Application::construct(argc, argv);
|
||||
|
||||
Config::pledge_domains("TextEditor");
|
||||
|
||||
char const* preview_mode = "auto";
|
||||
char const* file_to_edit = nullptr;
|
||||
Core::ArgsParser parser;
|
||||
|
@ -32,7 +35,6 @@ int main(int argc, char** argv)
|
|||
parser.parse(argc, argv);
|
||||
|
||||
String file_to_edit_full_path;
|
||||
auto config_filename = MainWidget::open_config_file()->filename();
|
||||
|
||||
if (file_to_edit) {
|
||||
FileArgument parsed_argument(file_to_edit);
|
||||
|
@ -48,11 +50,6 @@ int main(int argc, char** argv)
|
|||
}
|
||||
}
|
||||
|
||||
if (unveil(config_filename.characters(), "rwc") < 0) {
|
||||
perror("unveil");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (unveil("/res", "r") < 0) {
|
||||
perror("unveil");
|
||||
return 1;
|
||||
|
|
Loading…
Reference in a new issue