diff options
author | Rodrigo Tobar <rtobar@icrar.org> | 2022-12-17 20:36:54 +0800 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-12-17 19:40:52 +0100 |
commit | d739877807150d7854f81669ed48d4c5616769ba (patch) | |
tree | 0ee2ef6b79590b253d88dc807b04026784e7858e /Userland/Applications/PDFViewer/SidebarWidget.cpp | |
parent | aaa210e6db0a068c8f16643ad56e0b2665449bde (diff) | |
download | serenity-d739877807150d7854f81669ed48d4c5616769ba.zip |
PDFViewer: Inform about selections on Outline view
Selecting an Outline Item from the Outline view informs via callback the
corresponding Destination that has been selected. This will be used to
move the application to the corresponding page/section/etc.
Diffstat (limited to 'Userland/Applications/PDFViewer/SidebarWidget.cpp')
-rw-r--r-- | Userland/Applications/PDFViewer/SidebarWidget.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/Userland/Applications/PDFViewer/SidebarWidget.cpp b/Userland/Applications/PDFViewer/SidebarWidget.cpp index ad97d83cab..35ca3df457 100644 --- a/Userland/Applications/PDFViewer/SidebarWidget.cpp +++ b/Userland/Applications/PDFViewer/SidebarWidget.cpp @@ -5,6 +5,7 @@ */ #include "SidebarWidget.h" +#include "OutlineModel.h" #include <LibGUI/BoxLayout.h> #include <LibGUI/TabWidget.h> @@ -24,6 +25,13 @@ SidebarWidget::SidebarWidget() m_outline_tree_view->set_activates_on_selection(true); m_outline_tree_view->set_should_fill_selected_rows(true); m_outline_tree_view->set_selection_behavior(GUI::AbstractView::SelectionBehavior::SelectRows); + m_outline_tree_view->on_selection_change = [this]() { + auto& selection = m_outline_tree_view->selection(); + if (selection.is_empty()) + return; + auto destination = OutlineModel::get_destination(selection.first()); + on_destination_selected(destination); + }; auto& thumbnails_container = tab_bar.add_tab<GUI::Widget>("Thumbnails"); thumbnails_container.set_layout<GUI::VerticalBoxLayout>(); |