From a79c0c4c395fd5e7490db1d682fc5d2853fa652d Mon Sep 17 00:00:00 2001 From: Laurent Balland Date: Sat, 12 Sep 2026 15:32:28 +0200 Subject: [PATCH] tdf#171207 Add a button to list sheets The list of sheets is already available via right clic on any activated button in the navigation bar. However, it is somehow hidden for the user. This change added (for LTR and RTL UI) a hamburger button which show the list with a simple left click. Change-Id: Ic21b1e4d345a10bf86f2e97d1f7749bbcacc7a6e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/210677 Tested-by: Jenkins Reviewed-by: Laurent Balland Reviewed-by: Heiko Tietze --- include/svtools/strings.hrc | 2 ++ include/svtools/tabbar.hxx | 1 + solenv/sanitizers/ui/svt.suppr | 2 ++ svtools/source/control/tabbar.cxx | 20 +++++++++++-- svtools/uiconfig/ui/tabbuttons.ui | 35 +++++++++++++++++++---- svtools/uiconfig/ui/tabbuttonsmirrored.ui | 25 ++++++++++++++++ 6 files changed, 78 insertions(+), 7 deletions(-) diff --git a/include/svtools/strings.hrc b/include/svtools/strings.hrc index 0e0c8b9eaf27..01872d011753 100644 --- a/include/svtools/strings.hrc +++ b/include/svtools/strings.hrc @@ -181,12 +181,14 @@ #define STR_SVT_FONTMAP_STYLENOTAVAILABLE NC_("STR_SVT_FONTMAP_STYLENOTAVAILABLE", "This font style will be simulated or the closest matching style will be used.") #define STR_SVT_FONTMAP_NOTAVAILABLE NC_("STR_SVT_FONTMAP_NOTAVAILABLE", "This font has not been installed. The closest available font will be used.") +#define STR_TABBAR_PUSHBUTTON_SHEETSLIST NC_("STR_TABBAR_PUSHBUTTON_SHEETSLIST", "List of Sheets") #define STR_TABBAR_PUSHBUTTON_MOVET0HOME NC_("STR_TABBAR_PUSHBUTTON_MOVET0HOME", "Move To Home") #define STR_TABBAR_PUSHBUTTON_MOVELEFT NC_("STR_TABBAR_PUSHBUTTON_MOVELEFT", "Move Left") #define STR_TABBAR_PUSHBUTTON_MOVERIGHT NC_("STR_TABBAR_PUSHBUTTON_MOVERIGHT", "Move Right") #define STR_TABBAR_PUSHBUTTON_MOVETOEND NC_("STR_TABBAR_PUSHBUTTON_MOVETOEND", "Move To End") #define STR_TABBAR_PUSHBUTTON_ADDTAB NC_("STR_TABBAR_PUSHBUTTON_ADDTAB", "Add") +#define STR_TABBAR_HINT_SHEETSLIST_SHEETS NC_("STR_TABBAR_HINT_SHEETSLIST_SHEETS", "Show the list of all non-hidden sheets") #define STR_TABBAR_HINT_MOVETOHOME_SHEETS NC_("STR_TABBAR_HINT_MOVETOHOME_SHEETS", "Scroll to first sheet") #define STR_TABBAR_HINT_MOVELEFT_SHEETS NC_("STR_TABBAR_HINT_MOVELEFT_SHEETS", "Scroll to previous sheet") #define STR_TABBAR_HINT_MOVERIGHT_SHEETS NC_("STR_TABBAR_HINT_MOVERIGHT_SHEETS", "Scroll to next sheet") diff --git a/include/svtools/tabbar.hxx b/include/svtools/tabbar.hxx index 8d220b3aecc2..28f9fef099f7 100644 --- a/include/svtools/tabbar.hxx +++ b/include/svtools/tabbar.hxx @@ -366,6 +366,7 @@ private: DECL_DLLPRIVATE_LINK(ImplClickHdl, weld::Button&, void); DECL_DLLPRIVATE_LINK(ImplAddClickHandler, weld::Button&, void); + DECL_DLLPRIVATE_LINK(ImplListClickHandler, weld::Button&, void); DECL_DLLPRIVATE_LINK(MousePressHdl, const MouseEvent&, bool); DECL_DLLPRIVATE_LINK(ContextMenuHdl, const CommandEvent&, void); diff --git a/solenv/sanitizers/ui/svt.suppr b/solenv/sanitizers/ui/svt.suppr index 04fbd9e0db29..bfd567eada9d 100644 --- a/solenv/sanitizers/ui/svt.suppr +++ b/solenv/sanitizers/ui/svt.suppr @@ -25,11 +25,13 @@ svtools/uiconfig/ui/restartdialog.ui://GtkLabel[@id='reason_skia'] orphan-label svtools/uiconfig/ui/restartdialog.ui://GtkLabel[@id='label'] orphan-label svtools/uiconfig/ui/spinfieldcontrol.ui://GtkSpinButton[@id='spinbutton'] no-labelled-by svtools/uiconfig/ui/tabbaredit.ui://GtkEntry[@id='entry'] no-labelled-by +svtools/uiconfig/ui/tabbuttons.ui://GtkButton[@id='list'] button-no-label svtools/uiconfig/ui/tabbuttons.ui://GtkButton[@id='first'] button-no-label svtools/uiconfig/ui/tabbuttons.ui://GtkButton[@id='next'] button-no-label svtools/uiconfig/ui/tabbuttons.ui://GtkButton[@id='prev'] button-no-label svtools/uiconfig/ui/tabbuttons.ui://GtkButton[@id='last'] button-no-label svtools/uiconfig/ui/tabbuttons.ui://GtkButton[@id='add'] button-no-label +svtools/uiconfig/ui/tabbuttonsmirrored.ui://GtkButton[@id='list'] button-no-label svtools/uiconfig/ui/tabbuttonsmirrored.ui://GtkButton[@id='first'] button-no-label svtools/uiconfig/ui/tabbuttonsmirrored.ui://GtkButton[@id='next'] button-no-label svtools/uiconfig/ui/tabbuttonsmirrored.ui://GtkButton[@id='prev'] button-no-label diff --git a/svtools/source/control/tabbar.cxx b/svtools/source/control/tabbar.cxx index 94bed1616552..303e3d6f54f0 100644 --- a/svtools/source/control/tabbar.cxx +++ b/svtools/source/control/tabbar.cxx @@ -440,6 +440,7 @@ namespace { class TabButtons final : public InterimItemWindow { public: + std::unique_ptr m_xListButton; std::unique_ptr m_xFirstButton; std::unique_ptr m_xPrevButton; std::unique_ptr m_xNextButton; @@ -454,6 +455,7 @@ public: pParent->IsMirrored() ? u"svt/ui/tabbuttonsmirrored.ui"_ustr : u"svt/ui/tabbuttons.ui"_ustr, u"TabButtons"_ustr) + , m_xListButton(m_xBuilder->weld_button(u"list"_ustr)) , m_xFirstButton(m_xBuilder->weld_button(u"first"_ustr)) , m_xPrevButton(m_xBuilder->weld_button(u"prev"_ustr)) , m_xNextButton(m_xBuilder->weld_button(u"next"_ustr)) @@ -464,6 +466,7 @@ public: SetPaintTransparent(false); SetBackground(rStyleSettings.GetFaceColor()); + m_xListButton->set_accessible_name(SvtResId(STR_TABBAR_PUSHBUTTON_SHEETSLIST)); m_xFirstButton->set_accessible_name(SvtResId(STR_TABBAR_PUSHBUTTON_MOVET0HOME)); m_xPrevButton->set_accessible_name(SvtResId(STR_TABBAR_PUSHBUTTON_MOVELEFT)); m_xNextButton->set_accessible_name(SvtResId(STR_TABBAR_PUSHBUTTON_MOVERIGHT)); @@ -472,6 +475,7 @@ public: if (bSheets) { + m_xListButton->set_tooltip_text(SvtResId(STR_TABBAR_HINT_SHEETSLIST_SHEETS)); m_xFirstButton->set_tooltip_text(SvtResId(STR_TABBAR_HINT_MOVETOHOME_SHEETS)); m_xPrevButton->set_tooltip_text(SvtResId(STR_TABBAR_HINT_MOVELEFT_SHEETS)); m_xNextButton->set_tooltip_text(SvtResId(STR_TABBAR_HINT_MOVERIGHT_SHEETS)); @@ -484,6 +488,7 @@ public: { if (m_xFirstButton->get_preferred_size() == Size(nHeight, nHeight)) return; + m_xListButton->set_size_request(nHeight, nHeight); m_xFirstButton->set_size_request(nHeight, nHeight); m_xPrevButton->set_size_request(nHeight, nHeight); m_xNextButton->set_size_request(nHeight, nHeight); @@ -502,6 +507,7 @@ public: m_xNextButton.reset(); m_xPrevButton.reset(); m_xFirstButton.reset(); + m_xListButton.reset(); InterimItemWindow::dispose(); } }; @@ -785,6 +791,11 @@ IMPL_LINK(TabBar, MousePressHdl, const MouseEvent&, rMouseEvent, bool) return false; } +IMPL_LINK_NOARG( TabBar, ImplListClickHandler, weld::Button&, void ) +{ + maScrollAreaContextHdl.Call( CommandEvent( Point( 0, 0 ), CommandEventId::ContextMenu, true ) ); +} + void TabBar::ImplInitControls() { if (mnWinStyle & WB_SIZEABLE) @@ -803,6 +814,7 @@ void TabBar::ImplInitControls() mpImpl->mxButtonBox.disposeAndReset(VclPtr::Create(this, mbSheets)); Link aContextLink = LINK( this, TabBar, ContextMenuHdl ); + Link aBtnContextLink = LINK(this, TabBar, MousePressHdl); if (mnWinStyle & WB_INSERTTAB) { @@ -810,6 +822,11 @@ void TabBar::ImplInitControls() mpImpl->mxButtonBox->m_xAddRepeater = std::make_shared( *mpImpl->mxButtonBox->m_xAddButton, aLink, aContextLink); mpImpl->mxButtonBox->m_xAddButton->show(); + + aLink = LINK( this, TabBar, ImplListClickHandler ); + mpImpl->mxButtonBox->m_xListButton->connect_clicked( aLink ); + mpImpl->mxButtonBox->m_xListButton->connect_mouse_press( aBtnContextLink ); + mpImpl->mxButtonBox->m_xListButton->show(); } Link aLink = LINK( this, TabBar, ImplClickHdl ); @@ -826,8 +843,6 @@ void TabBar::ImplInitControls() if (mnWinStyle & WB_SCROLL) { - Link aBtnContextLink = LINK(this, TabBar, MousePressHdl); - mpImpl->mxButtonBox->m_xFirstButton->connect_clicked(aLink); mpImpl->mxButtonBox->m_xFirstButton->connect_mouse_press(aBtnContextLink); mpImpl->mxButtonBox->m_xFirstButton->show(); @@ -1447,6 +1462,7 @@ void TabBar::StateChanged(StateChangedType nType) mpImpl->mpSizer->EnableRTL(bIsRTLEnabled); if (mpImpl->mxButtonBox) { + mpImpl->mxButtonBox->m_xListButton->set_direction(bIsRTLEnabled); mpImpl->mxButtonBox->m_xFirstButton->set_direction(bIsRTLEnabled); mpImpl->mxButtonBox->m_xPrevButton->set_direction(bIsRTLEnabled); mpImpl->mxButtonBox->m_xNextButton->set_direction(bIsRTLEnabled); diff --git a/svtools/uiconfig/ui/tabbuttons.ui b/svtools/uiconfig/ui/tabbuttons.ui index 316813491abe..3c3ea58f0f94 100644 --- a/svtools/uiconfig/ui/tabbuttons.ui +++ b/svtools/uiconfig/ui/tabbuttons.ui @@ -32,6 +32,12 @@ go-last 1 + + True + False + open-menu-symbolic + 1 + True False @@ -39,6 +45,25 @@ 6 True True + + + True + False + True + True + image6 + none + True + + + + False + True + 0 + + True @@ -55,7 +80,7 @@ False True - 0 + 1 @@ -74,7 +99,7 @@ False True - 1 + 2 @@ -93,7 +118,7 @@ False True - 2 + 3 @@ -112,7 +137,7 @@ False True - 3 + 4 @@ -132,7 +157,7 @@ False True - 4 + 5 diff --git a/svtools/uiconfig/ui/tabbuttonsmirrored.ui b/svtools/uiconfig/ui/tabbuttonsmirrored.ui index 61e70d1e906e..56350792355d 100644 --- a/svtools/uiconfig/ui/tabbuttonsmirrored.ui +++ b/svtools/uiconfig/ui/tabbuttonsmirrored.ui @@ -32,6 +32,12 @@ go-last 1 + + True + False + open-menu-symbolic + 1 + True False @@ -135,5 +141,24 @@ 4 + + + True + False + True + True + image6 + none + True + + + + False + True + 5 + +