tdf#130857 Set fontwork item tooltips directly
Use the new API introduced in previous commit
Change-Id: I56e8dde0b591073dea7f58190746ca0ba1fd8a4f
Author: Michael Weghorn <m.weghorn@posteo.de>
Date: Tue Dec 16 12:10:48 2025 +0100
tdf#130857 tdf#168594 weld: Introduce weld::IconView::set_item_tooltip_text
to directly set the tooltip text for each of the
items, just like the accessible name (which is using
the same string) is also set directly in
FontWorkGalleryDialog::fillFavorites.
For gtk3/gtk4, add a corresponding column in the
GtkIconView model and set GtkIconView::tooltip-column
accordingly, as described in the above-mentioned commit.
This also gets rid of the need to remember the titles for
the items in a map.
Simplify the loop a bit by using the index and adding 1
once instead of using index+1 and subtracting 1 everywhere
else to get the index again.
The dialog can be triggered using "Insert" -> "Fontwork..."
in Writer.
Change-Id: I0f41a5a4fd13a3296fe9dcd84ea71e7d2d153a97
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195712
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Tested-by: Jenkins
This commit is contained in:
@@ -55,8 +55,6 @@ class SAL_WARN_UNUSED SVXCORE_DLLPUBLIC FontWorkGalleryDialog final : public wel
|
||||
SdrModel* mpDestModel;
|
||||
|
||||
std::vector<Bitmap> maFavoritesHorizontal;
|
||||
// mapping between item ID and item title
|
||||
std::map<OUString, OUString> maIdToTitleMap;
|
||||
|
||||
std::unique_ptr<weld::IconView> maCtlFavorites;
|
||||
std::unique_ptr<weld::Button> mxOKButton;
|
||||
@@ -69,7 +67,6 @@ class SAL_WARN_UNUSED SVXCORE_DLLPUBLIC FontWorkGalleryDialog final : public wel
|
||||
|
||||
DECL_DLLPRIVATE_LINK(DoubleClickFavoriteHdl, weld::IconView&, bool);
|
||||
DECL_DLLPRIVATE_LINK(ClickOKHdl, weld::Button&, void );
|
||||
DECL_DLLPRIVATE_LINK(QueryTooltipHandler, const weld::TreeIter&, OUString);
|
||||
|
||||
public:
|
||||
FontWorkGalleryDialog(weld::Window* pParent, SdrView& rView,
|
||||
|
||||
@@ -73,7 +73,6 @@ FontWorkGalleryDialog::FontWorkGalleryDialog(weld::Window* pParent, SdrView& rSd
|
||||
maCtlFavorites->set_size_request(aSize.Width(), aSize.Height());
|
||||
|
||||
maCtlFavorites->connect_item_activated( LINK( this, FontWorkGalleryDialog, DoubleClickFavoriteHdl ) );
|
||||
maCtlFavorites->connect_query_tooltip(LINK(this, FontWorkGalleryDialog, QueryTooltipHandler));
|
||||
mxOKButton->connect_clicked(LINK(this, FontWorkGalleryDialog, ClickOKHdl));
|
||||
|
||||
initFavorites( GALLERY_THEME_FONTWORK );
|
||||
@@ -133,18 +132,18 @@ void FontWorkGalleryDialog::fillFavorites(sal_uInt16 nThemeId)
|
||||
auto nFavCount = maFavoritesHorizontal.size();
|
||||
|
||||
maCtlFavorites->clear();
|
||||
maIdToTitleMap.clear();
|
||||
|
||||
std::vector<OUString> aTitles;
|
||||
(void)GalleryExplorer::FillObjListTitle(nThemeId, aTitles);
|
||||
assert(aTitles.size() == nFavCount);
|
||||
|
||||
for( size_t nFavorite = 1; nFavorite <= nFavCount; nFavorite++ )
|
||||
for (size_t nIndex = 0; nIndex < nFavCount; nIndex++)
|
||||
{
|
||||
OUString sId = OUString::number(static_cast<sal_uInt16>(nFavorite));
|
||||
maIdToTitleMap.emplace(sId, aTitles.at(nFavorite - 1));
|
||||
maCtlFavorites->insert(-1, nullptr, &sId, &maFavoritesHorizontal[nFavorite - 1], nullptr);
|
||||
maCtlFavorites->set_item_accessible_name(maCtlFavorites->n_children() - 1, aTitles.at(nFavorite -1));
|
||||
OUString sId = OUString::number(static_cast<sal_uInt16>(nIndex + 1));
|
||||
const OUString sTitle = aTitles.at(nIndex);
|
||||
maCtlFavorites->insert(-1, nullptr, &sId, &maFavoritesHorizontal[nIndex], nullptr);
|
||||
maCtlFavorites->set_item_accessible_name(nIndex, sTitle);
|
||||
maCtlFavorites->set_item_tooltip_text(nIndex, sTitle);
|
||||
}
|
||||
|
||||
if (maCtlFavorites->n_children())
|
||||
@@ -285,13 +284,6 @@ IMPL_LINK_NOARG(FontWorkGalleryDialog, DoubleClickFavoriteHdl, weld::IconView&,
|
||||
return true;
|
||||
}
|
||||
|
||||
IMPL_LINK(FontWorkGalleryDialog, QueryTooltipHandler, const weld::TreeIter&, iter, OUString)
|
||||
{
|
||||
const OUString id = maCtlFavorites->get_id(iter);
|
||||
auto it = maIdToTitleMap.find(id);
|
||||
return it != maIdToTitleMap.end() ? it->second : OUString();
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
class FontworkAlignmentWindow final : public WeldToolbarPopup
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
<column type="GdkPixbuf"/>
|
||||
<!-- column-name id -->
|
||||
<column type="gchararray"/>
|
||||
<!-- column-name tooltip -->
|
||||
<column type="gchararray"/>
|
||||
</columns>
|
||||
</object>
|
||||
<object class="GtkDialog" id="FontworkGalleryDialog">
|
||||
@@ -118,6 +120,7 @@
|
||||
<property name="vexpand">True</property>
|
||||
<property name="model">liststore1</property>
|
||||
<property name="pixbuf-column">0</property>
|
||||
<property name="tooltip-column">2</property>
|
||||
<child internal-child="accessible">
|
||||
<object class="AtkObject" id="ctlFavoriteswin-atkobject">
|
||||
<property name="AtkObject::accessible-description" translatable="yes" context="fontworkgallerydialog|extended_tip|ctlFavoriteWin">Select a Fontwork style and click OK to insert the Fontwork into your document. Double-click or Ctrl (Command) + double-click the Fontwork in your document to enter text edit mode and change the text.</property>
|
||||
|
||||
Reference in New Issue
Block a user