mirror of
https://github.com/SerenityOS/serenity
synced 2024-10-15 12:23:15 +00:00
PDFViewer: Add list of recently-opened files
This commit is contained in:
parent
15532df83d
commit
5c76b63f79
|
@ -215,6 +215,12 @@ void PDFViewerWidget::initialize_menubar(GUI::Window& window)
|
|||
open_file(response.value().filename(), response.value().release_stream());
|
||||
}));
|
||||
file_menu.add_separator();
|
||||
file_menu.add_recent_files_list([&](auto& action) {
|
||||
auto response = FileSystemAccessClient::Client::the().request_file_read_only_approved(&window, action.text());
|
||||
if (!response.is_error())
|
||||
open_file(response.value().filename(), response.value().release_stream());
|
||||
})
|
||||
.release_value_but_fixme_should_propagate_errors();
|
||||
file_menu.add_action(GUI::CommonActions::make_quit_action([](auto&) {
|
||||
GUI::Application::the()->quit();
|
||||
}));
|
||||
|
@ -407,5 +413,7 @@ PDF::PDFErrorOr<void> PDFViewerWidget::try_open_file(StringView path, NonnullOwn
|
|||
m_sidebar_open = false;
|
||||
}
|
||||
|
||||
GUI::Application::the()->set_most_recently_open_file(TRY(String::from_utf8(path)));
|
||||
|
||||
return {};
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
auto app_icon = GUI::Icon::default_icon("app-pdf-viewer"sv);
|
||||
|
||||
Config::pledge_domain("PDFViewer");
|
||||
app->set_config_domain(TRY("PDFViewer"_string));
|
||||
|
||||
auto window = TRY(GUI::Window::try_create());
|
||||
window->set_title("PDF Viewer");
|
||||
|
|
Loading…
Reference in a new issue