include/vcl/toolkit/treelistbox.hxx | 6 +++- vcl/inc/salvtables.hxx | 4 +-- vcl/source/app/salvtables.cxx | 46 ++++++++---------------------------- vcl/source/treelist/iconview.cxx | 3 ++ vcl/source/treelist/treelistbox.cxx | 18 ++++++++++++-- 5 files changed, 36 insertions(+), 41 deletions(-)
New commits: commit 0b92cf674cd44bdd2c2cdf8a5d597d4407e34002 Author: Mike Kaganski <mike.kagan...@collabora.com> AuthorDate: Wed Aug 10 13:05:45 2022 +0300 Commit: Mike Kaganski <mike.kagan...@collabora.com> CommitDate: Thu Aug 11 10:43:42 2022 +0200 jsdialog: dump tooltips for IconView entries This required to move the code calling Help::ShowQuickHelp from weld objects into SvTreeListBox::RequestHelp, and have it only request the tooltip text from those objects. Change-Id: I25c97360bbaac4705830a13aa06e0992b68fffff Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138084 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> diff --git a/include/vcl/toolkit/treelistbox.hxx b/include/vcl/toolkit/treelistbox.hxx index 62bee8ea976e..6ef40eb8d826 100644 --- a/include/vcl/toolkit/treelistbox.hxx +++ b/include/vcl/toolkit/treelistbox.hxx @@ -194,7 +194,7 @@ class VCL_DLLPUBLIC SvTreeListBox Link<SvTreeListBox*,void> aSelectHdl; Link<SvTreeListBox*,void> aDeselectHdl; Link<const CommandEvent&, bool> aPopupMenuHdl; - Link<const HelpEvent&, bool> aTooltipHdl; + Link<SvTreeListEntry*, OUString> aTooltipHdl; Link<svtree_render_args, void> aCustomRenderHdl; Link<svtree_measure_args, Size> aCustomMeasureHdl; @@ -392,6 +392,8 @@ public: SvViewDataItem* GetViewDataItem(SvTreeListEntry const *, SvLBoxItem const *); const SvViewDataItem* GetViewDataItem(const SvTreeListEntry*, const SvLBoxItem*) const; + OUString GetEntryTooltip(SvTreeListEntry* pEntry) const { return aTooltipHdl.Call(pEntry); } + VclPtr<Edit> GetEditWidget() const; // for UITest bool IsInplaceEditingEnabled() const { return bool(nImpFlags & SvTreeListBoxFlags::EDT_ENABLED); } bool IsEditingActive() const { return bool(nImpFlags & SvTreeListBoxFlags::IN_EDT); } @@ -407,7 +409,7 @@ public: void SetExpandingHdl(const Link<SvTreeListBox*,bool>& rNewHdl){aExpandingHdl=rNewHdl;} void SetExpandedHdl(const Link<SvTreeListBox*,void>& rNewHdl){aExpandedHdl=rNewHdl;} void SetPopupMenuHdl(const Link<const CommandEvent&, bool>& rLink) { aPopupMenuHdl = rLink; } - void SetTooltipHdl(const Link<const HelpEvent&, bool>& rLink) { aTooltipHdl = rLink; } + void SetTooltipHdl(const Link<SvTreeListEntry*, OUString>& rLink) { aTooltipHdl = rLink; } void SetCustomRenderHdl(const Link<svtree_render_args, void>& rLink) { aCustomRenderHdl = rLink; } void SetCustomMeasureHdl(const Link<svtree_measure_args, Size>& rLink) { aCustomMeasureHdl = rLink; } diff --git a/vcl/inc/salvtables.hxx b/vcl/inc/salvtables.hxx index 17084200955a..642eabd49990 100644 --- a/vcl/inc/salvtables.hxx +++ b/vcl/inc/salvtables.hxx @@ -1396,7 +1396,7 @@ protected: DECL_LINK(VisibleRangeChangedHdl, SvTreeListBox*, void); DECL_LINK(CompareHdl, const SvSortData&, sal_Int32); DECL_LINK(PopupMenuHdl, const CommandEvent&, bool); - DECL_LINK(TooltipHdl, const HelpEvent&, bool); + DECL_LINK(TooltipHdl, SvTreeListEntry*, OUString); DECL_LINK(CustomRenderHdl, svtree_render_args, void); DECL_LINK(CustomMeasureHdl, svtree_measure_args, Size); @@ -1769,7 +1769,7 @@ private: DECL_LINK(DeSelectHdl, SvTreeListBox*, void); DECL_LINK(DoubleClickHdl, SvTreeListBox*, bool); DECL_LINK(CommandHdl, const CommandEvent&, bool); - DECL_LINK(TooltipHdl, const HelpEvent&, bool); + DECL_LINK(TooltipHdl, SvTreeListEntry*, OUString); DECL_LINK(EntryAccessibleDescriptionHdl, SvTreeListEntry*, OUString); public: diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx index 39713700bd20..3874e76ab79d 100644 --- a/vcl/source/app/salvtables.cxx +++ b/vcl/source/app/salvtables.cxx @@ -5214,29 +5214,17 @@ SalInstanceTreeView::~SalInstanceTreeView() m_xTreeView->SetSelectHdl(Link<SvTreeListBox*, void>()); m_xTreeView->SetDeselectHdl(Link<SvTreeListBox*, void>()); m_xTreeView->SetScrolledHdl(Link<SvTreeListBox*, void>()); - m_xTreeView->SetTooltipHdl(Link<const HelpEvent&, bool>()); + m_xTreeView->SetTooltipHdl({}); m_xTreeView->SetCustomRenderHdl(Link<svtree_render_args, void>()); m_xTreeView->SetCustomMeasureHdl(Link<svtree_measure_args, Size>()); } -IMPL_LINK(SalInstanceTreeView, TooltipHdl, const HelpEvent&, rHEvt, bool) +IMPL_LINK(SalInstanceTreeView, TooltipHdl, SvTreeListEntry*, pEntry, OUString) { - if (notify_events_disabled()) - return false; - Point aPos(m_xTreeView->ScreenToOutputPixel(rHEvt.GetMousePosPixel())); - SvTreeListEntry* pEntry = m_xTreeView->GetEntry(aPos); - if (pEntry) - { - SalInstanceTreeIter aIter(pEntry); - OUString aTooltip = signal_query_tooltip(aIter); - if (aTooltip.isEmpty()) - return false; - Size aSize(m_xTreeView->GetOutputSizePixel().Width(), m_xTreeView->GetEntryHeight()); - tools::Rectangle aScreenRect( - m_xTreeView->OutputToScreenPixel(m_xTreeView->GetEntryPosition(pEntry)), aSize); - Help::ShowQuickHelp(m_xTreeView, aScreenRect, aTooltip); - } - return true; + if (pEntry && !notify_events_disabled()) + return signal_query_tooltip(SalInstanceTreeIter(pEntry)); + + return {}; } IMPL_LINK(SalInstanceTreeView, CustomRenderHdl, svtree_render_args, payload, void) @@ -5590,24 +5578,12 @@ void SalInstanceIconView::insert_separator(int pos, const OUString* /* pId */) pViewData->SetSelectable(false); } -IMPL_LINK(SalInstanceIconView, TooltipHdl, const HelpEvent&, rHEvt, bool) +IMPL_LINK(SalInstanceIconView, TooltipHdl, SvTreeListEntry*, pEntry, OUString) { - if (notify_events_disabled()) - return false; - Point aPos(m_xIconView->ScreenToOutputPixel(rHEvt.GetMousePosPixel())); - SvTreeListEntry* pEntry = m_xIconView->GetEntry(aPos); - if (pEntry) - { - SalInstanceTreeIter aIter(pEntry); - OUString aTooltip = signal_query_tooltip(aIter); - if (aTooltip.isEmpty()) - return false; - Size aSize(m_xIconView->GetOutputSizePixel().Width(), m_xIconView->GetEntryHeight()); - tools::Rectangle aScreenRect( - m_xIconView->OutputToScreenPixel(m_xIconView->GetEntryPosition(pEntry)), aSize); - Help::ShowQuickHelp(m_xIconView, aScreenRect, aTooltip); - } - return true; + if (pEntry && !notify_events_disabled()) + return signal_query_tooltip(SalInstanceTreeIter(pEntry)); + + return {}; } IMPL_LINK(SalInstanceIconView, EntryAccessibleDescriptionHdl, SvTreeListEntry*, pEntry, OUString) diff --git a/vcl/source/treelist/iconview.cxx b/vcl/source/treelist/iconview.cxx index df9dde3ddd87..a997009a0296 100644 --- a/vcl/source/treelist/iconview.cxx +++ b/vcl/source/treelist/iconview.cxx @@ -294,6 +294,9 @@ static void lcl_DumpEntryAndSiblings(tools::JsonWriter& rJsonWriter, SvTreeListE rJsonWriter.put("image", extractPngString(pBmpItem)); } + if (const OUString tooltip = pTabListBox->GetEntryTooltip(pEntry); !tooltip.isEmpty()) + rJsonWriter.put("alt", tooltip); + if (pTabListBox->IsSelected(pEntry)) rJsonWriter.put("selected", "true"); diff --git a/vcl/source/treelist/treelistbox.cxx b/vcl/source/treelist/treelistbox.cxx index e799de53ff31..e2f54e56a6f7 100644 --- a/vcl/source/treelist/treelistbox.cxx +++ b/vcl/source/treelist/treelistbox.cxx @@ -26,6 +26,7 @@ #include <vcl/toolkit/treelistbox.hxx> #include <vcl/accessiblefactory.hxx> #include <com/sun/star/accessibility/AccessibleStateType.hpp> +#include <vcl/help.hxx> #include <vcl/svapp.hxx> #include <vcl/builder.hxx> #include <vcl/toolkit/edit.hxx> @@ -3318,8 +3319,21 @@ void SvTreeListBox::GetLastTab( SvLBoxTabFlags nFlagMask, sal_uInt16& rTabPos ) void SvTreeListBox::RequestHelp( const HelpEvent& rHEvt ) { - if (aTooltipHdl.IsSet() && aTooltipHdl.Call(rHEvt)) - return; + if (aTooltipHdl.IsSet()) + { + const Point pos(ScreenToOutputPixel(rHEvt.GetMousePosPixel())); + if (SvTreeListEntry* entry = GetEntry(pos)) + { + const OUString tooltip = aTooltipHdl.Call(entry); + if (!tooltip.isEmpty()) + { + const Size size(GetOutputSizePixel().Width(), GetEntryHeight()); + tools::Rectangle screenRect(OutputToScreenPixel(GetEntryPosition(entry)), size); + Help::ShowQuickHelp(this, screenRect, tooltip); + return; + } + } + } if( !pImpl->RequestHelp( rHEvt ) ) Control::RequestHelp( rHEvt );