summaryrefslogtreecommitdiff
path: root/sfx2
diff options
context:
space:
mode:
authorMichael Weghorn <m.weghorn@posteo.de>2024-06-17 14:45:34 +0200
committerAndras Timar <andras.timar@collabora.com>2024-06-29 19:00:54 +0200
commit125abd614cc926317e02214357051908a01c7511 (patch)
treeda587f2199ac035fd9500868054078197a3acf5a /sfx2
parent3a1b07f6d3a011e61db8dbb75eacee1cdc871378 (diff)
tdf#159835 sfx2: Simplify TabBar::OnToolboxClicked
Now that the logic from `SidebarController::PopulatePopupMenus` has been moved here in Change-Id: I8236f2467239e6a2f485d468656e961478eeb09c Author: Michael Weghorn <m.weghorn@posteo.de> Date: Mon Jun 17 13:35:12 2024 +0200 tdf#159835 sfx2: Move logic to populate sidebar menus to TabBar as well, simplify `TabBar::OnToolboxClicked`: No longer use one loop to build a vector of entries and another to process these, but use a single loop for that instead. Drop the now unused `DeckMenuData` class. Change-Id: I884f3b70bb4d85b9a52421e9de6042cda80cfa0b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169006 Reviewed-by: Michael Weghorn <m.weghorn@posteo.de> Tested-by: Jenkins (cherry picked from commit ca364f8f16f0c64589d15e7bc44fe6eaebe8f5b2) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169246 Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'sfx2')
-rw-r--r--sfx2/source/sidebar/TabBar.cxx48
1 files changed, 20 insertions, 28 deletions
diff --git a/sfx2/source/sidebar/TabBar.cxx b/sfx2/source/sidebar/TabBar.cxx
index b764964012c0..a8afd1d4769d 100644
--- a/sfx2/source/sidebar/TabBar.cxx
+++ b/sfx2/source/sidebar/TabBar.cxx
@@ -344,23 +344,6 @@ IMPL_LINK_NOARG(TabBar, OnToolboxClicked, weld::Toggleable&, void)
if (!mxMenuButton->get_active())
return;
- std::vector<DeckMenuData> aMenuData;
-
- for (auto const& item : maItems)
- {
- std::shared_ptr<DeckDescriptor> xDeckDescriptor = mrParentSidebarController.GetResourceManager()->GetDeckDescriptor(item->msDeckId);
-
- if (!xDeckDescriptor)
- continue;
-
- DeckMenuData aData;
- aData.msDisplayName = xDeckDescriptor->msTitle;
- aData.mbIsCurrentDeck = item->mxButton->get_item_active("toggle");
- aData.mbIsActive = !item->mbIsHidden;
- aData.mbIsEnabled = item->mxButton->get_sensitive();
- aMenuData.push_back(aData);
- }
-
for (int i = mxMainMenu->n_children() - 1; i >= 0; --i)
{
OUString sIdent = mxMainMenu->get_id(i);
@@ -377,30 +360,39 @@ IMPL_LINK_NOARG(TabBar, OnToolboxClicked, weld::Toggleable&, void)
// Add one entry for every tool panel element to individually make
// them visible or hide them.
sal_Int32 nIndex (0);
- for (const auto& rItem : aMenuData)
+ for (auto const& rItem : maItems)
{
+ std::shared_ptr<DeckDescriptor> xDeckDescriptor
+ = mrParentSidebarController.GetResourceManager()->GetDeckDescriptor(rItem->msDeckId);
+
+ if (!xDeckDescriptor)
+ continue;
+
+ const OUString sDisplayName = xDeckDescriptor->msTitle;
OUString sIdent("select" + OUString::number(nIndex));
- mxMainMenu->insert(nIndex, sIdent, rItem.msDisplayName,
- nullptr, nullptr, nullptr, TRISTATE_FALSE);
- mxMainMenu->set_active(sIdent, rItem.mbIsCurrentDeck);
- mxMainMenu->set_sensitive(sIdent, rItem.mbIsEnabled && rItem.mbIsActive);
+ const bool bCurrentDeck = rItem->mxButton->get_item_active(u"toggle"_ustr);
+ const bool bActive = !rItem->mbIsHidden;
+ const bool bEnabled = rItem->mxButton->get_sensitive();
+ mxMainMenu->insert(nIndex, sIdent, sDisplayName, nullptr, nullptr, nullptr, TRISTATE_FALSE);
+ mxMainMenu->set_active(sIdent, bCurrentDeck);
+ mxMainMenu->set_sensitive(sIdent, bEnabled && bActive);
if (!comphelper::LibreOfficeKit::isActive())
{
- if (rItem.mbIsCurrentDeck)
+ if (bCurrentDeck)
{
// Don't allow the currently visible deck to be disabled.
OUString sSubIdent("nocustomize" + OUString::number(nIndex));
- mxSubMenu->insert(nIndex, sSubIdent, rItem.msDisplayName,
- nullptr, nullptr, nullptr, TRISTATE_FALSE);
+ mxSubMenu->insert(nIndex, sSubIdent, sDisplayName, nullptr, nullptr, nullptr,
+ TRISTATE_FALSE);
mxSubMenu->set_active(sSubIdent, true);
}
else
{
OUString sSubIdent("customize" + OUString::number(nIndex));
- mxSubMenu->insert(nIndex, sSubIdent, rItem.msDisplayName,
- nullptr, nullptr, nullptr, TRISTATE_TRUE);
- mxSubMenu->set_active(sSubIdent, rItem.mbIsEnabled && rItem.mbIsActive);
+ mxSubMenu->insert(nIndex, sSubIdent, sDisplayName, nullptr, nullptr, nullptr,
+ TRISTATE_TRUE);
+ mxSubMenu->set_active(sSubIdent, bEnabled && bActive);
}
}