diff options
author | Michael Weghorn <m.weghorn@posteo.de> | 2024-06-19 13:08:34 +0200 |
---|---|---|
committer | Michael Weghorn <m.weghorn@posteo.de> | 2024-06-20 05:51:59 +0200 |
commit | daed96f0818b1baae5de8b74b866009d7d89f853 (patch) | |
tree | 8c46a1947575169d363766515bdf9a0d5a51512f /sfx2 | |
parent | c2c6a5d32f8c536ab816630583f986860202c4a9 (diff) |
tdf#159835 sfx2: Keep sidebar menu up to date
No longer update the menu for the menu button
in the sidebar in the handler that gets called
when the button gets clicked, but continually
keep the menu up to date instead.
This ensures that the menu is up-to-date when
it gets shown. Updating the menu in the button handler
is too late since
commit f075fa01cb4f74185f13eb0a8d7f84cf1f47af49
Author: Michael Weghorn <m.weghorn@posteo.de>
Date: Tue Aug 22 10:26:32 2023 +0200
tdf#141101 tdf#101886 a11y: Restore previous focus on col/line popup close
, as the handler is now no more called before the menu
gets shown.
Do the update in method `TabBar::UpdateMenus` instead
and call that one whenever items change or the
sidebar gets docked/undocked, as menu entries
are shown for the items and for (un)docking.
This makes the menu show all entries again
when opened the first time after starting Writer,
which was no longer the case after the
above-mentioned commmit.
Change-Id: I9a7e341e88d2de5f34e8f85ebada3ff2ebf6b47d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169196
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/source/sidebar/SidebarController.cxx | 5 | ||||
-rw-r--r-- | sfx2/source/sidebar/TabBar.cxx | 15 |
2 files changed, 14 insertions, 6 deletions
diff --git a/sfx2/source/sidebar/SidebarController.cxx b/sfx2/source/sidebar/SidebarController.cxx index 2ebfebe6ab81..bdca4a89055c 100644 --- a/sfx2/source/sidebar/SidebarController.cxx +++ b/sfx2/source/sidebar/SidebarController.cxx @@ -1075,6 +1075,11 @@ IMPL_LINK(SidebarController, WindowEventHandler, VclWindowEvent&, rEvent, void) maContextChangeUpdate.RequestCall(); break; + case VclEventId::WindowToggleFloating: + // make sure the appropriate "Dock" or "Undock" menu entry is shown + mpTabBar->UpdateMenus(); + break; + case VclEventId::ObjectDying: dispose(); break; diff --git a/sfx2/source/sidebar/TabBar.cxx b/sfx2/source/sidebar/TabBar.cxx index af086c2610b5..76669adc5798 100644 --- a/sfx2/source/sidebar/TabBar.cxx +++ b/sfx2/source/sidebar/TabBar.cxx @@ -73,6 +73,8 @@ TabBar::TabBar(vcl::Window* pParentWindow, mxSubMenu = mxAuxBuilder->weld_menu(u"submenu"_ustr); aPopupMenuSignalConnectFunction(*mxMainMenu, *mxSubMenu); + UpdateMenus(); + gDefaultWidth = m_xContainer->get_preferred_size().Width(); // we have this widget just so we can measure best width for static TabBar::GetDefaultWidth @@ -80,8 +82,6 @@ TabBar::TabBar(vcl::Window* pParentWindow, SetBackground(Wallpaper(Theme::GetColor(Theme::Color_TabBarBackground))); - mxMenuButton->connect_toggled(LINK(this, TabBar, OnToolboxClicked)); - #if OSL_DEBUG_LEVEL >= 2 SetText(OUString("TabBar")); #endif @@ -147,6 +147,7 @@ void TabBar::SetDecks(const ResourceManager::DeckContextDescriptorContainer& rDe } UpdateButtonIcons(); + UpdateMenus(); } void TabBar::UpdateButtonIcons() @@ -164,18 +165,21 @@ void TabBar::HighlightDeck(std::u16string_view rsDeckId) { for (auto const& item : maItems) item->mxButton->set_item_active(u"toggle"_ustr, item->msDeckId == rsDeckId); + UpdateMenus(); } void TabBar::RemoveDeckHighlight() { for (auto const& item : maItems) item->mxButton->set_item_active(u"toggle"_ustr, false); + UpdateMenus(); } void TabBar::DataChanged(const DataChangedEvent& rDataChangedEvent) { SetBackground(Theme::GetColor(Theme::Color_TabBarBackground)); UpdateButtonIcons(); + UpdateMenus(); InterimItemWindow::DataChanged(rDataChangedEvent); } @@ -300,6 +304,7 @@ void TabBar::ToggleHideFlag (const sal_Int32 nIndex) xDeckDescriptor->maContextList.ToggleVisibilityForContext( aContext, xDeckDescriptor->mbIsEnabled ); } + UpdateMenus(); } void TabBar::RestoreHideFlags() @@ -315,6 +320,7 @@ void TabBar::RestoreHideFlags() } } + UpdateMenus(); } void TabBar::UpdateFocusManager(FocusManager& rFocusManager) @@ -329,11 +335,8 @@ void TabBar::UpdateFocusManager(FocusManager& rFocusManager) rFocusManager.SetButtons(aButtons); } -IMPL_LINK_NOARG(TabBar, OnToolboxClicked, weld::Toggleable&, void) +void TabBar::UpdateMenus() { - if (!mxMenuButton->get_active()) - return; - for (int i = mxMainMenu->n_children() - 1; i >= 0; --i) { OUString sIdent = mxMainMenu->get_id(i); |