From 5c76b63f79bf380a7eeedac0819605c901ba112d Mon Sep 17 00:00:00 2001 From: Sam Atkins Date: Mon, 3 Apr 2023 14:30:22 +0100 Subject: [PATCH] PDFViewer: Add list of recently-opened files --- Userland/Applications/PDFViewer/PDFViewerWidget.cpp | 8 ++++++++ Userland/Applications/PDFViewer/main.cpp | 1 + 2 files changed, 9 insertions(+) diff --git a/Userland/Applications/PDFViewer/PDFViewerWidget.cpp b/Userland/Applications/PDFViewer/PDFViewerWidget.cpp index d2ebec6cd4..3a11e3c32a 100644 --- a/Userland/Applications/PDFViewer/PDFViewerWidget.cpp +++ b/Userland/Applications/PDFViewer/PDFViewerWidget.cpp @@ -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 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 {}; } diff --git a/Userland/Applications/PDFViewer/main.cpp b/Userland/Applications/PDFViewer/main.cpp index 71c0545a51..6f0fbf529c 100644 --- a/Userland/Applications/PDFViewer/main.cpp +++ b/Userland/Applications/PDFViewer/main.cpp @@ -27,6 +27,7 @@ ErrorOr 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");