include/sfx2/sidebar/TabBar.hxx | 5 ++--- sfx2/source/sidebar/SidebarController.cxx | 5 +++++ sfx2/source/sidebar/TabBar.cxx | 19 ++++++++++--------- vcl/source/window/dockwin.cxx | 2 ++ 4 files changed, 19 insertions(+), 12 deletions(-)
New commits: commit f556e99ce3d6a73ac13559ba3eeefe2d59bc6231 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Wed Jun 19 13:08:34 2024 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Thu Jun 20 09:27:31 2024 +0200 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.wegh...@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.wegh...@posteo.de> (cherry picked from commit daed96f0818b1baae5de8b74b866009d7d89f853) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169142 diff --git a/include/sfx2/sidebar/TabBar.hxx b/include/sfx2/sidebar/TabBar.hxx index 7591aeff7bf6..8778c9bd2e21 100644 --- a/include/sfx2/sidebar/TabBar.hxx +++ b/include/sfx2/sidebar/TabBar.hxx @@ -73,6 +73,8 @@ public: /// Enables/Disables the menu button. Used by LoKit. void EnableMenuButton(const bool bEnable); + void UpdateMenus(); + virtual FactoryFunction GetUITestFactory() const override; private: css::uno::Reference<css::frame::XFrame> mxFrame; @@ -111,8 +113,6 @@ private: css::uno::Reference<css::graphic::XGraphic> GetItemImage(const DeckDescriptor& rDeskDescriptor) const; void UpdateButtonIcons(); - DECL_LINK(OnToolboxClicked, weld::Toggleable&, void); - SidebarController& mrParentSidebarController; }; 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); commit aa0a3b8dc53b1a9a14995351b1a024478c8f0bc8 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Wed Jun 19 12:54:22 2024 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Thu Jun 20 09:27:24 2024 +0200 tdf#159835 vcl: Notify when floating window toggled Notify listeners using an `VclEventId::WindowToggleFloating` event when the floating mode was toggled in `DockingWindow::SetFloatingMode`. This will be used in upcoming commit Change-Id: I9a7e341e88d2de5f34e8f85ebada3ff2ebf6b47d Author: Michael Weghorn <m.wegh...@posteo.de> Date: Tue Jun 18 13:41:03 2024 +0200 tdf#159835 sfx2: Keep sidebar menu up to date to react to that toggling. Change-Id: I5286ab727c30d4dd4bbc3cf5d42f19ff649b39f5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169195 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> (cherry picked from commit c2c6a5d32f8c536ab816630583f986860202c4a9) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169141 diff --git a/vcl/source/window/dockwin.cxx b/vcl/source/window/dockwin.cxx index ed31cc356f44..a4c216b443af 100644 --- a/vcl/source/window/dockwin.cxx +++ b/vcl/source/window/dockwin.cxx @@ -789,6 +789,8 @@ void DockingWindow::SetFloatingMode( bool bFloatMode ) if (bVisible) Show(); + + CallEventListeners(VclEventId::WindowToggleFloating); } void DockingWindow::SetFloatStyle( WinBits nStyle ) commit cd04b6738669b795895b81d64f399f309615b616 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Tue Jun 18 13:21:40 2024 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Thu Jun 20 09:27:17 2024 +0200 tdf#159835 sfx2 Connect SidebarController menu handlers earlier Instead of connecting the SidebarController handlers for handling activation of `TabBar` menu items every time in `TabBar::OnToolboxClicked` (which is the handler that gets called when clicking the menu button), do so once in the `TabBar` ctor. This also ensures that the handlers are connected before the menu shows for the first time, which is no longer true for the previous approach since commit f075fa01cb4f74185f13eb0a8d7f84cf1f47af49 Author: Michael Weghorn <m.wegh...@posteo.de> Date: Tue Aug 22 10:26:32 2023 +0200 tdf#141101 tdf#101886 a11y: Restore previous focus on col/line popup close Now, clicking on the sidebar menu and selecting the "Undock" entry works to undock the first time, not only when opening the menu for the second time. Populating all menu entries before the menu gets opened for the first time still needs to be implemented separately. Change-Id: I7e5d5e511c2ce2c7304e8f88676970d76e6319df Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169193 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> (cherry picked from commit 504e5501fce3f53d15b53f344c20e4404ff8f3db) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169140 diff --git a/include/sfx2/sidebar/TabBar.hxx b/include/sfx2/sidebar/TabBar.hxx index bc2b2a4e4d04..7591aeff7bf6 100644 --- a/include/sfx2/sidebar/TabBar.hxx +++ b/include/sfx2/sidebar/TabBar.hxx @@ -106,7 +106,6 @@ private: typedef ::std::vector<std::unique_ptr<Item>> ItemContainer; ItemContainer maItems; const ::std::function<void (const OUString& rsDeckId)> maDeckActivationFunctor; - PopupMenuSignalConnectFunction maPopupMenuSignalConnectFunction; void CreateTabItem(weld::Toolbar& rButton, const DeckDescriptor& rDeckDescriptor); css::uno::Reference<css::graphic::XGraphic> GetItemImage(const DeckDescriptor& rDeskDescriptor) const; diff --git a/sfx2/source/sidebar/TabBar.cxx b/sfx2/source/sidebar/TabBar.cxx index d9608e36d49f..af086c2610b5 100644 --- a/sfx2/source/sidebar/TabBar.cxx +++ b/sfx2/source/sidebar/TabBar.cxx @@ -57,7 +57,6 @@ TabBar::TabBar(vcl::Window* pParentWindow, , mxContents(mxAuxBuilder->weld_widget(u"TabBarContents"_ustr)) , mxMeasureBox(mxAuxBuilder->weld_widget(u"measure"_ustr)) , maDeckActivationFunctor(std::move(aDeckActivationFunctor)) - , maPopupMenuSignalConnectFunction(std::move(aPopupMenuSignalConnectFunction)) , mrParentSidebarController(rParentSidebarController) { set_id(u"TabBar"_ustr); // for uitest @@ -72,6 +71,7 @@ TabBar::TabBar(vcl::Window* pParentWindow, mxMenuButton = mxAuxBuilder->weld_menu_button(u"menubutton"_ustr); mxMainMenu = mxAuxBuilder->weld_menu(u"mainmenu"_ustr); mxSubMenu = mxAuxBuilder->weld_menu(u"submenu"_ustr); + aPopupMenuSignalConnectFunction(*mxMainMenu, *mxSubMenu); gDefaultWidth = m_xContainer->get_preferred_size().Width(); @@ -405,8 +405,6 @@ IMPL_LINK_NOARG(TabBar, OnToolboxClicked, weld::Toggleable&, void) // No Restore or Customize options for LoKit. mxMainMenu->set_visible(u"customization"_ustr, !comphelper::LibreOfficeKit::isActive()); - - maPopupMenuSignalConnectFunction(*mxMainMenu, *mxSubMenu); } void TabBar::EnableMenuButton(const bool bEnable)