mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-08 23:42:53 +03:00
PDFViewer: Hide the rendering diagnostics window by default
You can enable it in the Debug menu and we will remember your choice.
This commit is contained in:
parent
d6ab5c9b7d
commit
a099d0e140
Notes:
sideshowbarker
2024-07-17 05:05:51 +09:00
Author: https://github.com/lanmonster Commit: https://github.com/SerenityOS/serenity/commit/a099d0e140 Pull-request: https://github.com/SerenityOS/serenity/pull/23460 Reviewed-by: https://github.com/nico ✅
@ -48,6 +48,7 @@ PDFViewer::PDFViewer()
|
||||
m_page_view_mode = static_cast<PageViewMode>(Config::read_i32("PDFViewer"sv, "Display"sv, "PageMode"sv, 0));
|
||||
m_rendering_preferences.show_clipping_paths = Config::read_bool("PDFViewer"sv, "Rendering"sv, "ShowClippingPaths"sv, false);
|
||||
m_rendering_preferences.show_images = Config::read_bool("PDFViewer"sv, "Rendering"sv, "ShowImages"sv, true);
|
||||
m_rendering_preferences.show_diagnostics = Config::read_bool("PDFViewer"sv, "Rendering"sv, "ShowDiagnostics"sv, false);
|
||||
m_rendering_preferences.clip_images = Config::read_bool("PDFViewer"sv, "Rendering"sv, "ClipImages"sv, true);
|
||||
m_rendering_preferences.clip_paths = Config::read_bool("PDFViewer"sv, "Rendering"sv, "ClipPaths"sv, true);
|
||||
m_rendering_preferences.clip_text = Config::read_bool("PDFViewer"sv, "Rendering"sv, "ClipText"sv, true);
|
||||
@ -170,6 +171,13 @@ void PDFViewer::set_current_page(u32 current_page)
|
||||
update();
|
||||
}
|
||||
|
||||
void PDFViewer::set_show_rendering_diagnostics(bool show_diagnostics)
|
||||
{
|
||||
m_rendering_preferences.show_diagnostics = show_diagnostics;
|
||||
Config::write_bool("PDFViewer"sv, "Rendering"sv, "ShowDiagnostics"sv, show_diagnostics);
|
||||
update();
|
||||
}
|
||||
|
||||
void PDFViewer::set_show_clipping_paths(bool show_clipping_paths)
|
||||
{
|
||||
m_rendering_preferences.show_clipping_paths = show_clipping_paths;
|
||||
|
@ -62,6 +62,8 @@ public:
|
||||
|
||||
PageViewMode page_view_mode() const { return m_page_view_mode; }
|
||||
void set_page_view_mode(PageViewMode);
|
||||
bool show_rendering_diagnostics() const { return m_rendering_preferences.show_diagnostics; }
|
||||
void set_show_rendering_diagnostics(bool);
|
||||
bool show_clipping_paths() const { return m_rendering_preferences.show_clipping_paths; }
|
||||
void set_show_clipping_paths(bool);
|
||||
bool show_images() const { return m_rendering_preferences.show_images; }
|
||||
|
@ -182,10 +182,10 @@ PDFViewerWidget::PDFViewerWidget()
|
||||
m_viewer->set_current_page(page);
|
||||
};
|
||||
|
||||
auto& v_splitter = h_splitter.add<GUI::VerticalSplitter>();
|
||||
v_splitter.layout()->set_spacing(4);
|
||||
m_vertical_splitter = h_splitter.add<GUI::VerticalSplitter>();
|
||||
m_vertical_splitter->layout()->set_spacing(4);
|
||||
|
||||
m_viewer = v_splitter.add<PDFViewer>();
|
||||
m_viewer = m_vertical_splitter->add<PDFViewer>();
|
||||
m_viewer->on_page_change = [&](auto new_page) {
|
||||
m_page_text_box->set_value(new_page + 1, GUI::AllowCallback::No);
|
||||
m_go_to_prev_page_action->set_enabled(new_page > 0);
|
||||
@ -195,7 +195,7 @@ PDFViewerWidget::PDFViewerWidget()
|
||||
verify_cast<PagedErrorsModel>(m_paged_errors_model.ptr())->add_errors(page, errors);
|
||||
};
|
||||
|
||||
m_errors_tree_view = v_splitter.add<GUI::TreeView>();
|
||||
m_errors_tree_view = GUI::TreeView::construct();
|
||||
m_errors_tree_view->set_preferred_height(10);
|
||||
m_errors_tree_view->column_header().set_visible(true);
|
||||
m_errors_tree_view->set_should_fill_selected_rows(true);
|
||||
@ -203,6 +203,10 @@ PDFViewerWidget::PDFViewerWidget()
|
||||
m_errors_tree_view->set_model(MUST(GUI::SortingProxyModel::create(m_paged_errors_model)));
|
||||
m_errors_tree_view->set_key_column(0);
|
||||
|
||||
if (m_viewer->show_rendering_diagnostics()) {
|
||||
m_vertical_splitter->add_child(*m_errors_tree_view);
|
||||
}
|
||||
|
||||
initialize_toolbar(toolbar);
|
||||
}
|
||||
|
||||
@ -247,6 +251,16 @@ ErrorOr<void> PDFViewerWidget::initialize_menubar(GUI::Window& window)
|
||||
}));
|
||||
|
||||
auto debug_menu = window.add_menu("&Debug"_string);
|
||||
auto toggle_show_diagnostics = GUI::Action::create_checkable("Show Rendering &Diagnostics", [&](auto& action) {
|
||||
if (action.is_checked()) {
|
||||
m_vertical_splitter->add_child(*m_errors_tree_view);
|
||||
} else {
|
||||
m_vertical_splitter->remove_child(*m_errors_tree_view);
|
||||
}
|
||||
m_viewer->set_show_rendering_diagnostics(action.is_checked());
|
||||
});
|
||||
toggle_show_diagnostics->set_checked(m_viewer->show_rendering_diagnostics());
|
||||
debug_menu->add_action(toggle_show_diagnostics);
|
||||
auto toggle_show_clipping_paths = GUI::Action::create_checkable("Show &Clipping Paths", [&](auto& action) {
|
||||
m_viewer->set_show_clipping_paths(action.is_checked());
|
||||
});
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include <LibGUI/ActionGroup.h>
|
||||
#include <LibGUI/CheckBox.h>
|
||||
#include <LibGUI/NumericInput.h>
|
||||
#include <LibGUI/Splitter.h>
|
||||
#include <LibGUI/Widget.h>
|
||||
|
||||
class PDFViewer;
|
||||
@ -39,6 +40,7 @@ private:
|
||||
RefPtr<PDFViewer> m_viewer;
|
||||
RefPtr<SidebarWidget> m_sidebar;
|
||||
NonnullRefPtr<PagedErrorsModel> m_paged_errors_model;
|
||||
RefPtr<GUI::VerticalSplitter> m_vertical_splitter;
|
||||
RefPtr<GUI::TreeView> m_errors_tree_view;
|
||||
RefPtr<GUI::NumericInput> m_page_text_box;
|
||||
RefPtr<GUI::Label> m_total_page_label;
|
||||
|
@ -89,6 +89,7 @@ struct GraphicsState {
|
||||
struct RenderingPreferences {
|
||||
bool show_clipping_paths { false };
|
||||
bool show_images { true };
|
||||
bool show_diagnostics { false };
|
||||
|
||||
bool clip_images { true };
|
||||
bool clip_paths { true };
|
||||
|
Loading…
Reference in New Issue
Block a user