From 176e9db6cde791fb860e6b84c6edae625e606f59 Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Sun, 21 Jan 2024 06:53:42 -0500 Subject: [PATCH] PDFViewer: Move debug actions from toolbar into a menu This makes it easier to add more entries. Also, debug toggles don't need to be quite as visible as they were on the toolbar :^) --- .../PDFViewer/PDFViewerWidget.cpp | 22 ++++++++++--------- .../Applications/PDFViewer/PDFViewerWidget.h | 2 -- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Userland/Applications/PDFViewer/PDFViewerWidget.cpp b/Userland/Applications/PDFViewer/PDFViewerWidget.cpp index 608f714aa6b..2d1b540c3e7 100644 --- a/Userland/Applications/PDFViewer/PDFViewerWidget.cpp +++ b/Userland/Applications/PDFViewer/PDFViewerWidget.cpp @@ -246,6 +246,18 @@ ErrorOr PDFViewerWidget::initialize_menubar(GUI::Window& window) window.set_fullscreen(!window.is_fullscreen()); })); + auto debug_menu = window.add_menu("&Debug"_string); + auto toggle_show_clipping_paths = GUI::Action::create_checkable("Show &Clipping Paths", [&](auto& action) { + m_viewer->set_show_clipping_paths(action.is_checked()); + }); + toggle_show_clipping_paths->set_checked(m_viewer->show_clipping_paths()); + debug_menu->add_action(toggle_show_clipping_paths); + auto toggle_show_images = GUI::Action::create_checkable("Show &Images", [&](auto& action) { + m_viewer->set_show_images(action.is_checked()); + }); + toggle_show_images->set_checked(m_viewer->show_images()); + debug_menu->add_action(*toggle_show_images); + auto help_menu = window.add_menu("&Help"_string); help_menu->add_action(GUI::CommonActions::make_command_palette_action(&window)); help_menu->add_action(GUI::CommonActions::make_about_action("PDF Viewer"_string, GUI::Icon::default_icon("app-pdf-viewer"sv), &window)); @@ -354,15 +366,6 @@ void PDFViewerWidget::initialize_toolbar(GUI::Toolbar& toolbar) toolbar.add_action(*m_rotate_counterclockwise_action); toolbar.add_action(*m_rotate_clockwise_action); toolbar.add_separator(); - - m_show_clipping_paths = toolbar.add(); - m_show_clipping_paths->set_text("Show clipping paths"_string); - m_show_clipping_paths->set_checked(m_viewer->show_clipping_paths(), GUI::AllowCallback::No); - m_show_clipping_paths->on_checked = [&](auto checked) { m_viewer->set_show_clipping_paths(checked); }; - m_show_images = toolbar.add(); - m_show_images->set_text("Show images"_string); - m_show_images->set_checked(m_viewer->show_images(), GUI::AllowCallback::No); - m_show_images->on_checked = [&](auto checked) { m_viewer->set_show_images(checked); }; } void PDFViewerWidget::open_file(StringView path, NonnullOwnPtr file) @@ -411,7 +414,6 @@ PDF::PDFErrorOr PDFViewerWidget::try_open_file(StringView path, NonnullOwn m_reset_zoom_action->set_enabled(true); m_rotate_counterclockwise_action->set_enabled(true); m_rotate_clockwise_action->set_enabled(true); - m_show_clipping_paths->set_checked(m_viewer->show_clipping_paths(), GUI::AllowCallback::No); if (document->outline()) { auto outline = document->outline(); diff --git a/Userland/Applications/PDFViewer/PDFViewerWidget.h b/Userland/Applications/PDFViewer/PDFViewerWidget.h index b19a8eb5d61..70fafaa7001 100644 --- a/Userland/Applications/PDFViewer/PDFViewerWidget.h +++ b/Userland/Applications/PDFViewer/PDFViewerWidget.h @@ -53,8 +53,6 @@ private: GUI::ActionGroup m_page_view_action_group; RefPtr m_page_view_mode_single; RefPtr m_page_view_mode_multiple; - RefPtr m_show_clipping_paths; - RefPtr m_show_images; bool m_sidebar_open { false }; ByteBuffer m_buffer;