mirror of
https://github.com/RGBCube/serenity
synced 2025-07-10 05:47:34 +00:00
PDFViewer: Add zoom in/out/reset menu actions
Make PDFViewer::zoom_in() & ::zoom_out() public and add menu and toolbar actions. Also add an action for zoom reset.
This commit is contained in:
parent
45085122ee
commit
3af71c406d
4 changed files with 50 additions and 8 deletions
|
@ -58,6 +58,10 @@ void PDFViewerWidget::initialize_menubar(GUI::Window& window)
|
|||
|
||||
auto& view_menu = window.add_menu("&View");
|
||||
view_menu.add_action(*m_toggle_sidebar_action);
|
||||
view_menu.add_separator();
|
||||
view_menu.add_action(*m_zoom_in_action);
|
||||
view_menu.add_action(*m_zoom_out_action);
|
||||
view_menu.add_action(*m_reset_zoom_action);
|
||||
|
||||
auto& help_menu = window.add_menu("&Help");
|
||||
help_menu.add_action(GUI::CommonActions::make_about_action("PDF Viewer", GUI::Icon::default_icon("app-pdf-viewer"), &window));
|
||||
|
@ -111,6 +115,28 @@ void PDFViewerWidget::create_toolbar()
|
|||
};
|
||||
|
||||
m_total_page_label = toolbar.add<GUI::Label>();
|
||||
m_total_page_label->set_fixed_width(30);
|
||||
toolbar.add_separator();
|
||||
|
||||
m_zoom_in_action = GUI::CommonActions::make_zoom_in_action([&](auto&) {
|
||||
m_viewer->zoom_in();
|
||||
});
|
||||
|
||||
m_zoom_out_action = GUI::CommonActions::make_zoom_out_action([&](auto&) {
|
||||
m_viewer->zoom_out();
|
||||
});
|
||||
|
||||
m_reset_zoom_action = GUI::CommonActions::make_reset_zoom_action([&](auto&) {
|
||||
m_viewer->reset_zoom();
|
||||
});
|
||||
|
||||
m_zoom_in_action->set_enabled(false);
|
||||
m_zoom_out_action->set_enabled(false);
|
||||
m_reset_zoom_action->set_enabled(false);
|
||||
|
||||
toolbar.add_action(*m_zoom_in_action);
|
||||
toolbar.add_action(*m_zoom_out_action);
|
||||
toolbar.add_action(*m_reset_zoom_action);
|
||||
}
|
||||
|
||||
void PDFViewerWidget::open_file(int fd, String const& path)
|
||||
|
@ -131,7 +157,6 @@ void PDFViewerWidget::open_file(int fd, String const& path)
|
|||
|
||||
m_viewer->set_document(document);
|
||||
m_total_page_label->set_text(String::formatted("of {}", document->get_page_count()));
|
||||
m_total_page_label->set_fixed_width(30);
|
||||
|
||||
m_page_text_box->set_enabled(true);
|
||||
m_page_text_box->set_current_number(1, false);
|
||||
|
@ -139,6 +164,9 @@ void PDFViewerWidget::open_file(int fd, String const& path)
|
|||
m_go_to_prev_page_action->set_enabled(false);
|
||||
m_go_to_next_page_action->set_enabled(document->get_page_count() > 1);
|
||||
m_toggle_sidebar_action->set_enabled(true);
|
||||
m_zoom_in_action->set_enabled(true);
|
||||
m_zoom_out_action->set_enabled(true);
|
||||
m_reset_zoom_action->set_enabled(true);
|
||||
|
||||
if (document->outline()) {
|
||||
auto outline = document->outline();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue