include/sfx2/sidebar/TabBar.hxx           |    4 ++--
 sfx2/source/sidebar/SidebarController.cxx |    5 +++++
 sfx2/source/sidebar/TabBar.cxx            |   15 +++++++++------
 3 files changed, 16 insertions(+), 8 deletions(-)

New commits:
commit 2318ce7f71110beca1d89dc9fd33e6d3a98ede1e
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Wed Jun 19 13:08:34 2024 +0200
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Thu Jun 27 16:43:18 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/+/169250
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/include/sfx2/sidebar/TabBar.hxx b/include/sfx2/sidebar/TabBar.hxx
index 6f922c34ea01..9a9613239689 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;
     std::unique_ptr<svt::AcceleratorExecute> mpAccel;
 };
diff --git a/sfx2/source/sidebar/SidebarController.cxx 
b/sfx2/source/sidebar/SidebarController.cxx
index ce02e434833c..ae55e76cd830 100644
--- a/sfx2/source/sidebar/SidebarController.cxx
+++ b/sfx2/source/sidebar/SidebarController.cxx
@@ -1049,6 +1049,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 35b3c80444a6..0a305e744a15 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("submenu");
     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));
-
 #ifdef DEBUG
     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("toggle", item->msDeckId == rsDeckId);
+    UpdateMenus();
 }
 
 void TabBar::RemoveDeckHighlight()
 {
     for (auto const& item : maItems)
         item->mxButton->set_item_active("toggle", false);
+    UpdateMenus();
 }
 
 void TabBar::DataChanged(const DataChangedEvent& rDataChangedEvent)
 {
     SetBackground(Theme::GetColor(Theme::Color_TabBarBackground));
     UpdateButtonIcons();
+    UpdateMenus();
 
     InterimItemWindow::DataChanged(rDataChangedEvent);
 }
@@ -310,6 +314,7 @@ void TabBar::ToggleHideFlag (const sal_Int32 nIndex)
         xDeckDescriptor->maContextList.ToggleVisibilityForContext(
             aContext, xDeckDescriptor->mbIsEnabled );
     }
+    UpdateMenus();
 }
 
 void TabBar::RestoreHideFlags()
@@ -325,6 +330,7 @@ void TabBar::RestoreHideFlags()
 
         }
     }
+    UpdateMenus();
 }
 
 void TabBar::UpdateFocusManager(FocusManager& rFocusManager)
@@ -339,11 +345,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);

Reply via email to