1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 03:07:43 +00:00

PDFViewer: Add page mode option

This commit is contained in:
Matthew Olsson 2022-03-28 21:19:45 -07:00 committed by Andreas Kling
parent c39718ca81
commit 091c2cfdca
6 changed files with 54 additions and 11 deletions

View file

@ -7,6 +7,7 @@
#include "PDFViewer.h"
#include <AK/Array.h>
#include <LibConfig/Client.h>
#include <LibGUI/Action.h>
#include <LibGUI/MessageBox.h>
#include <LibGUI/Painter.h>
@ -41,6 +42,8 @@ PDFViewer::PDFViewer()
set_scrollbars_enabled(true);
start_timer(30'000);
m_page_view_mode = static_cast<PageViewMode>(Config::read_i32("PDFViewer", "Display", "PageMode", 0));
}
void PDFViewer::set_document(RefPtr<PDF::Document> document)
@ -211,6 +214,13 @@ void PDFViewer::rotate(int degrees)
update();
}
void PDFViewer::set_page_view_mode(PageViewMode mode)
{
m_page_view_mode = mode;
Config::write_i32("PDFViewer", "Display", "PageMode", static_cast<i32>(mode));
update();
}
PDF::PDFErrorOr<NonnullRefPtr<Gfx::Bitmap>> PDFViewer::render_page(const PDF::Page& page)
{
auto zoom_scale_factor = static_cast<float>(zoom_levels[m_zoom_level]) / 100.0f;