mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 17:47:43 +00:00
PDFViewer: Add list of recently-opened files
This commit is contained in:
parent
15532df83d
commit
5c76b63f79
2 changed files with 9 additions and 0 deletions
|
@ -215,6 +215,12 @@ void PDFViewerWidget::initialize_menubar(GUI::Window& window)
|
||||||
open_file(response.value().filename(), response.value().release_stream());
|
open_file(response.value().filename(), response.value().release_stream());
|
||||||
}));
|
}));
|
||||||
file_menu.add_separator();
|
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&) {
|
file_menu.add_action(GUI::CommonActions::make_quit_action([](auto&) {
|
||||||
GUI::Application::the()->quit();
|
GUI::Application::the()->quit();
|
||||||
}));
|
}));
|
||||||
|
@ -407,5 +413,7 @@ PDF::PDFErrorOr<void> PDFViewerWidget::try_open_file(StringView path, NonnullOwn
|
||||||
m_sidebar_open = false;
|
m_sidebar_open = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GUI::Application::the()->set_most_recently_open_file(TRY(String::from_utf8(path)));
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
auto app_icon = GUI::Icon::default_icon("app-pdf-viewer"sv);
|
auto app_icon = GUI::Icon::default_icon("app-pdf-viewer"sv);
|
||||||
|
|
||||||
Config::pledge_domain("PDFViewer");
|
Config::pledge_domain("PDFViewer");
|
||||||
|
app->set_config_domain(TRY("PDFViewer"_string));
|
||||||
|
|
||||||
auto window = TRY(GUI::Window::try_create());
|
auto window = TRY(GUI::Window::try_create());
|
||||||
window->set_title("PDF Viewer");
|
window->set_title("PDF Viewer");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue