From 45085122eea5cd43c88cfb7e542d6b22e69168b3 Mon Sep 17 00:00:00 2001 From: Marcus Nilsson Date: Mon, 27 Dec 2021 13:41:01 +0100 Subject: [PATCH] PDFViewer: Fix sidebar toggle logic The open_outline_action logic was backwards resulting in it being closed on the first click and opened on the second, and opposite if document->outline() was true. There was also a collision with the Ctrl+O shortcut for opening a document, this changes it to Ctrl+S instead. This commit also changes the wording to 'Toogle' instead of 'Open/Close' since the text wasn't updated as expected, and lastly, add a View menu with the action. --- Userland/Applications/PDFViewer/PDFViewerWidget.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Userland/Applications/PDFViewer/PDFViewerWidget.cpp b/Userland/Applications/PDFViewer/PDFViewerWidget.cpp index 7e6b13c78f..aac25ba043 100644 --- a/Userland/Applications/PDFViewer/PDFViewerWidget.cpp +++ b/Userland/Applications/PDFViewer/PDFViewerWidget.cpp @@ -56,6 +56,9 @@ void PDFViewerWidget::initialize_menubar(GUI::Window& window) GUI::Application::the()->quit(); })); + auto& view_menu = window.add_menu("&View"); + view_menu.add_action(*m_toggle_sidebar_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)); } @@ -66,10 +69,9 @@ void PDFViewerWidget::create_toolbar() auto& toolbar = toolbar_container.add(); auto open_outline_action = GUI::Action::create( - "Open &Sidebar", { Mod_Ctrl, Key_O }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/sidebar.png").release_value_but_fixme_should_propagate_errors(), [&](auto& action) { + "Toggle &Sidebar", { Mod_Ctrl, Key_S }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/sidebar.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) { m_sidebar_open = !m_sidebar_open; - m_sidebar->set_fixed_width(m_sidebar_open ? 0 : 200); - action.set_text(m_sidebar_open ? "Open &Sidebar" : "Close &Sidebar"); + m_sidebar->set_fixed_width(m_sidebar_open ? 200 : 0); }, nullptr); open_outline_action->set_enabled(false);