diff --git a/Userland/Applications/ThemeEditor/CMakeLists.txt b/Userland/Applications/ThemeEditor/CMakeLists.txt index 95ee3c629c..7541f8a1fd 100644 --- a/Userland/Applications/ThemeEditor/CMakeLists.txt +++ b/Userland/Applications/ThemeEditor/CMakeLists.txt @@ -28,4 +28,4 @@ set(GENERATED_SOURCES ) serenity_app(ThemeEditor ICON app-theme-editor) -target_link_libraries(ThemeEditor PRIVATE LibCore LibGfx LibGUI LibFileSystem LibFileSystemAccessClient LibIPC LibMain) +target_link_libraries(ThemeEditor PRIVATE LibConfig LibCore LibGfx LibGUI LibFileSystem LibFileSystemAccessClient LibIPC LibMain) diff --git a/Userland/Applications/ThemeEditor/MainWidget.cpp b/Userland/Applications/ThemeEditor/MainWidget.cpp index 209a69eaaa..eb014389b4 100644 --- a/Userland/Applications/ThemeEditor/MainWidget.cpp +++ b/Userland/Applications/ThemeEditor/MainWidget.cpp @@ -285,8 +285,21 @@ ErrorOr MainWidget::initialize_menubar(GUI::Window& window) return; save_to_file(result.value().filename(), result.value().release_stream()); }))); - TRY(file_menu->try_add_separator()); + + TRY(file_menu->add_recent_files_list([&](auto& action) { + if (request_close() == GUI::Window::CloseRequestDecision::StayOpen) + return; + auto response = FileSystemAccessClient::Client::the().request_file_read_only_approved(&window, action.text()); + if (response.is_error()) + return; + auto load_from_file_result = load_from_file(response.value().filename(), response.value().release_stream()); + if (load_from_file_result.is_error()) { + GUI::MessageBox::show_error(&window, DeprecatedString::formatted("Can't open file named {}: {}", response.value().filename(), load_from_file_result.error())); + return; + } + })); + TRY(file_menu->try_add_action(GUI::CommonActions::make_quit_action([&](auto&) { if (request_close() == GUI::Window::CloseRequestDecision::Close) GUI::Application::the()->quit(); @@ -362,6 +375,7 @@ void MainWidget::save_to_file(String const& filename, NonnullOwnPtr m_last_modified_time = MonotonicTime::now(); set_path(filename.to_deprecated_string()); window()->set_modified(false); + GUI::Application::the()->set_most_recently_open_file(filename); } } @@ -657,6 +671,7 @@ ErrorOr MainWidget::load_from_file(String const& filename, NonnullOwnPtrset_modified(false); + GUI::Application::the()->set_most_recently_open_file(filename); return {}; } diff --git a/Userland/Applications/ThemeEditor/main.cpp b/Userland/Applications/ThemeEditor/main.cpp index c6cdd086da..cb83ef118e 100644 --- a/Userland/Applications/ThemeEditor/main.cpp +++ b/Userland/Applications/ThemeEditor/main.cpp @@ -9,6 +9,7 @@ */ #include "MainWidget.h" +#include #include #include #include @@ -27,6 +28,9 @@ ErrorOr serenity_main(Main::Arguments arguments) auto app = TRY(GUI::Application::create(arguments)); + Config::pledge_domain("ThemeEditor"); + app->set_config_domain(TRY("ThemeEditor"_string)); + StringView file_to_edit; Core::ArgsParser parser;