PixelPaint: Add list of recently opened files to the file menu

This commit is contained in:
Tim Ledbetter 2023-03-08 18:56:17 +00:00 committed by Andreas Kling
parent 4accc6a61f
commit 4fd12b6b79
Notes: sideshowbarker 2024-07-17 18:06:52 +09:00
2 changed files with 10 additions and 0 deletions

View file

@ -264,6 +264,14 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
TRY(file_menu->try_add_separator());
TRY(file_menu->add_recent_files_list([&](auto& action) {
auto path = action.text();
auto response = FileSystemAccessClient::Client::the().request_file_read_only_approved(&window, path);
if (response.is_error())
return;
open_image(response.release_value());
}));
m_close_image_action = GUI::Action::create("&Close Image", { Mod_Ctrl, Key_W }, g_icon_bag.close_image, [&](auto&) {
auto* active_widget = m_tab_widget->active_widget();
VERIFY(active_widget);
@ -1174,6 +1182,7 @@ void MainWidget::open_image(FileSystemAccessClient::File file)
editor.set_path(file.filename().to_deprecated_string());
editor.set_unmodified();
m_layer_list_widget->set_image(&image);
GUI::Application::the()->set_most_recently_open_file(file.filename());
}
ErrorOr<void> MainWidget::create_default_image()

View file

@ -25,6 +25,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
auto app = TRY(GUI::Application::try_create(arguments));
Config::pledge_domain("PixelPaint");
app->set_config_domain(TRY(String::from_utf8("PixelPaint"sv)));
StringView image_file;
Core::ArgsParser args_parser;