Skip to content

Commit

Permalink
PDFViewer: Add list of recently-opened files
Browse files Browse the repository at this point in the history
  • Loading branch information
AtkinsSJ authored and awesomekling committed Apr 3, 2023
1 parent 15532df commit 5c76b63
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Userland/Applications/PDFViewer/PDFViewerWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}));
Expand Down Expand Up @@ -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 {};
}
1 change: 1 addition & 0 deletions Userland/Applications/PDFViewer/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit 5c76b63

Please sign in to comment.