mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-21 23:20:20 +00:00
PixelPaint: Add list of recently opened files to the file menu
This commit is contained in:
parent
4accc6a61f
commit
4fd12b6b79
Notes:
sideshowbarker
2024-07-17 18:06:52 +09:00
Author: https://github.com/tcl3 Commit: https://github.com/SerenityOS/serenity/commit/4fd12b6b79 Pull-request: https://github.com/SerenityOS/serenity/pull/17771 Reviewed-by: https://github.com/nico ✅
2 changed files with 10 additions and 0 deletions
|
@ -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()
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue