summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorKarol Kosek <krkk@serenityos.org>2023-01-09 21:28:05 +0100
committerSam Atkins <atkinssj@gmail.com>2023-01-10 22:15:23 +0000
commitd4367f42ba53c4359fbf7286fd53c9ac1eed1994 (patch)
tree80e945d5e96f1ce2f9a3756789b543a02ca21bd3 /Userland
parent7826cb25563a1df5653c7391477cbad0ade787c0 (diff)
downloadserenity-d4367f42ba53c4359fbf7286fd53c9ac1eed1994.zip
PDFViewer: Port to Core::Stream::File
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Applications/PDFViewer/PDFViewerWidget.cpp14
-rw-r--r--Userland/Applications/PDFViewer/PDFViewerWidget.h4
-rw-r--r--Userland/Applications/PDFViewer/main.cpp4
3 files changed, 11 insertions, 11 deletions
diff --git a/Userland/Applications/PDFViewer/PDFViewerWidget.cpp b/Userland/Applications/PDFViewer/PDFViewerWidget.cpp
index 6be1475080..d0e5063341 100644
--- a/Userland/Applications/PDFViewer/PDFViewerWidget.cpp
+++ b/Userland/Applications/PDFViewer/PDFViewerWidget.cpp
@@ -211,9 +211,9 @@ void PDFViewerWidget::initialize_menubar(GUI::Window& window)
{
auto& file_menu = window.add_menu("&File");
file_menu.add_action(GUI::CommonActions::make_open_action([&](auto&) {
- auto response = FileSystemAccessClient::Client::the().try_open_file_deprecated(&window);
+ auto response = FileSystemAccessClient::Client::the().open_file(&window);
if (!response.is_error())
- open_file(*response.value());
+ open_file(response.value().filename(), response.value().release_stream());
}));
file_menu.add_separator();
file_menu.add_action(GUI::CommonActions::make_quit_action([](auto&) {
@@ -349,9 +349,9 @@ void PDFViewerWidget::initialize_toolbar(GUI::Toolbar& toolbar)
m_show_images->on_checked = [&](auto checked) { m_viewer->set_show_images(checked); };
}
-void PDFViewerWidget::open_file(Core::File& file)
+void PDFViewerWidget::open_file(StringView path, NonnullOwnPtr<Core::Stream::File> file)
{
- auto maybe_error = try_open_file(file);
+ auto maybe_error = try_open_file(path, move(file));
if (maybe_error.is_error()) {
auto error = maybe_error.release_error();
warnln("{}", error.message());
@@ -360,11 +360,11 @@ void PDFViewerWidget::open_file(Core::File& file)
}
}
-PDF::PDFErrorOr<void> PDFViewerWidget::try_open_file(Core::File& file)
+PDF::PDFErrorOr<void> PDFViewerWidget::try_open_file(StringView path, NonnullOwnPtr<Core::Stream::File> file)
{
- window()->set_title(DeprecatedString::formatted("{} - PDF Viewer", file.filename()));
+ window()->set_title(DeprecatedString::formatted("{} - PDF Viewer", path));
- m_buffer = file.read_all();
+ m_buffer = TRY(file->read_until_eof());
auto document = TRY(PDF::Document::create(m_buffer));
if (auto sh = document->security_handler(); sh && !sh->has_user_password()) {
diff --git a/Userland/Applications/PDFViewer/PDFViewerWidget.h b/Userland/Applications/PDFViewer/PDFViewerWidget.h
index 785896abe4..cd1171f259 100644
--- a/Userland/Applications/PDFViewer/PDFViewerWidget.h
+++ b/Userland/Applications/PDFViewer/PDFViewerWidget.h
@@ -26,13 +26,13 @@ public:
~PDFViewerWidget() override = default;
void initialize_menubar(GUI::Window&);
- void open_file(Core::File&);
+ void open_file(StringView path, NonnullOwnPtr<Core::Stream::File> file);
private:
PDFViewerWidget();
void initialize_toolbar(GUI::Toolbar&);
- PDF::PDFErrorOr<void> try_open_file(Core::File&);
+ PDF::PDFErrorOr<void> try_open_file(StringView path, NonnullOwnPtr<Core::Stream::File> file);
RefPtr<PDFViewer> m_viewer;
RefPtr<SidebarWidget> m_sidebar;
diff --git a/Userland/Applications/PDFViewer/main.cpp b/Userland/Applications/PDFViewer/main.cpp
index ba799e8820..748ea0a7e8 100644
--- a/Userland/Applications/PDFViewer/main.cpp
+++ b/Userland/Applications/PDFViewer/main.cpp
@@ -47,10 +47,10 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
window->set_icon(app_icon.bitmap_for_size(16));
if (file_path) {
- auto response = FileSystemAccessClient::Client::the().try_request_file_read_only_approved_deprecated(window, file_path);
+ auto response = FileSystemAccessClient::Client::the().request_file_read_only_approved(window, file_path);
if (response.is_error())
return 1;
- pdf_viewer_widget->open_file(*response.value());
+ pdf_viewer_widget->open_file(response.value().filename(), response.value().release_stream());
}
return app->exec();