tdf#171142 Quickfind page separator entries should not receive focus

* Makes clicking on a page separator entry select the next entry in the
finds list.

 * Makes up/down arrow key movements skip over page separator entries.

 * Makes movements that result in selecting a page separator entry
select the next entry in the finds list. Movements that can do this are
the page up/down and home keys.

Change-Id: Ibde0807ecea85ab7bd8497b3759642d18234c8dd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/202503
Tested-by: Jenkins
Reviewed-by: Jim Raykowski <raykowj@gmail.com>
This commit is contained in:
Jim Raykowski
2026-03-25 23:28:05 +01:00
parent 8a5f3cc219
commit 44a0fa54b8
2 changed files with 41 additions and 12 deletions
+1 -1
View File
@@ -78,7 +78,7 @@ private:
DECL_LINK(SearchFindsListRender, weld::TreeView::render_args, void);
DECL_LINK(SearchFindsListSelectionChangedHandler, weld::TreeView&, void);
DECL_LINK(SearchFindsListRowActivatedHandler, weld::TreeView&, bool);
DECL_LINK(SearchFindsListMousePressHandler, const MouseEvent&, bool);
DECL_LINK(SearchFindsListKeyPressHandler, const KeyEvent&, bool);
DECL_LINK(SearchOptionsToolbarClickedHandler, const OUString&, void);
DECL_LINK(FindAndReplaceToolbarClickedHandler, const OUString&, void);
DECL_LINK(SimilarityCheckButtonToggledHandler, weld::Toggleable&, void);
+40 -11
View File
@@ -194,8 +194,8 @@ QuickFindPanel::QuickFindPanel(weld::Widget* pParent, const uno::Reference<frame
LINK(this, QuickFindPanel, SearchFindsListSelectionChangedHandler));
m_xSearchFindsList->connect_row_activated(
LINK(this, QuickFindPanel, SearchFindsListRowActivatedHandler));
m_xSearchFindsList->connect_mouse_press(
LINK(this, QuickFindPanel, SearchFindsListMousePressHandler));
m_xSearchFindsList->connect_key_press(
LINK(this, QuickFindPanel, SearchFindsListKeyPressHandler));
}
// tdf#162580 related: When upgrading from Find toolbar search to advanced Find and Replace
@@ -275,13 +275,40 @@ IMPL_LINK_NOARG(QuickFindPanel, SearchComboBoxActivateHandler, weld::ComboBox&,
return true;
}
IMPL_LINK(QuickFindPanel, SearchFindsListMousePressHandler, const MouseEvent&, rMEvt, bool)
IMPL_LINK(QuickFindPanel, SearchFindsListKeyPressHandler, const KeyEvent&, rKeyEvt, bool)
{
if (std::unique_ptr<weld::TreeIter> xEntry
= m_xSearchFindsList->get_dest_row_at_pos(rMEvt.GetPosPixel(), false, false))
vcl::KeyCode aCode = rKeyEvt.GetKeyCode();
sal_uInt16 nCode = aCode.GetCode();
if (nCode == KEY_DOWN)
{
return m_xSearchFindsList->get_id(*xEntry)[0] == '-';
if (std::unique_ptr<weld::TreeIter> xEntry = m_xSearchFindsList->get_cursor();
xEntry && m_xSearchFindsList->iter_next(*xEntry)
&& m_xSearchFindsList->get_id(*xEntry)[0] == '-'
&& m_xSearchFindsList->iter_next(*xEntry))
{
m_xSearchFindsList->set_cursor(*xEntry);
SearchFindsListSelectionChangedHandler(*m_xSearchFindsList);
return true;
}
}
else if (nCode == KEY_UP)
{
if (std::unique_ptr<weld::TreeIter> xEntry = m_xSearchFindsList->get_cursor();
xEntry && m_xSearchFindsList->iter_previous(*xEntry)
&& m_xSearchFindsList->get_id(*xEntry)[0] == '-')
{
if (m_xSearchFindsList->iter_previous(*xEntry))
{
m_xSearchFindsList->set_cursor(*xEntry);
SearchFindsListSelectionChangedHandler(*m_xSearchFindsList);
}
else
m_xSearchFindsList->scroll_to_row(0);
return true;
}
}
return false;
}
@@ -417,7 +444,13 @@ IMPL_LINK_NOARG(QuickFindPanel, SearchFindsListSelectionChangedHandler, weld::Tr
// check for page number entry
if (sId[0] == '-')
return;
{
int nRow = m_xSearchFindsList->get_selected_index();
(void)m_xSearchFindsList->iter_next(*xEntry);
m_xSearchFindsList->set_cursor(*xEntry);
m_xSearchFindsList->scroll_to_row(nRow);
sId = m_xSearchFindsList->get_id(*xEntry);
}
std::unique_ptr<SwPaM>& rxPaM = m_vPaMs[sId.toUInt64()];
@@ -463,10 +496,6 @@ IMPL_LINK_NOARG(QuickFindPanel, SearchFindsListRowActivatedHandler, weld::TreeVi
if (!xEntry)
return false;
// check for page number entry
if (m_xSearchFindsList->get_id(*xEntry)[0] == '-')
return false;
m_pWrtShell->GetView().GetEditWin().GrabFocus();
return true;
}