From cbb373e135e7bb9dd72a69f5439cad3b5f1d3fdb Mon Sep 17 00:00:00 2001 From: Rodrigo Tobar Date: Wed, 23 Nov 2022 21:21:52 +0800 Subject: [PATCH] PDFViewer: Toggle prev/next page actions when page changes These actions were not updated accordingly when one scrolled through the document, and thus one could accidentally, for example, move to the next page when standing on the last, which caused a crash. This commit fixes that behavior, toggling the actions' enabled status depending on the new page being displayed. --- Userland/Applications/PDFViewer/PDFViewerWidget.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Userland/Applications/PDFViewer/PDFViewerWidget.cpp b/Userland/Applications/PDFViewer/PDFViewerWidget.cpp index 84edea939b..55d88c3b01 100644 --- a/Userland/Applications/PDFViewer/PDFViewerWidget.cpp +++ b/Userland/Applications/PDFViewer/PDFViewerWidget.cpp @@ -37,6 +37,8 @@ PDFViewerWidget::PDFViewerWidget() m_viewer = splitter.add(); m_viewer->on_page_change = [&](auto new_page) { m_page_text_box->set_current_number(new_page + 1, GUI::AllowCallback::No); + m_go_to_prev_page_action->set_enabled(new_page > 0); + m_go_to_next_page_action->set_enabled(new_page < m_viewer->document()->get_page_count() - 1); }; initialize_toolbar(toolbar);