summaryrefslogtreecommitdiff
path: root/Userland/Applications
diff options
context:
space:
mode:
authorSam Atkins <atkinssj@serenityos.org>2023-04-03 14:30:22 +0100
committerAndreas Kling <kling@serenityos.org>2023-04-03 16:32:03 +0200
commit5c76b63f79bf380a7eeedac0819605c901ba112d (patch)
treecd699088b275ef28e9fc2237e8f753eac5663c35 /Userland/Applications
parent15532df83da6a8bd91db1b28431e0c14d5cbce05 (diff)
downloadserenity-5c76b63f79bf380a7eeedac0819605c901ba112d.zip
PDFViewer: Add list of recently-opened files
Diffstat (limited to 'Userland/Applications')
-rw-r--r--Userland/Applications/PDFViewer/PDFViewerWidget.cpp8
-rw-r--r--Userland/Applications/PDFViewer/main.cpp1
2 files changed, 9 insertions, 0 deletions
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<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 {};
}
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<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");