framework/source/uielement/menubarmanager.cxx | 36 +++++++++++--------------- 1 file changed, 16 insertions(+), 20 deletions(-)
New commits: commit 4b19e22d713d13f768d5bfd67da49844e62e0bb9 Author: Michael Weghorn <[email protected]> AuthorDate: Wed Oct 23 16:09:04 2024 +0200 Commit: Michael Weghorn <[email protected]> CommitDate: Thu Oct 24 09:08:11 2024 +0200 framework: Move var declaration close to use, drop another one Move variable/code from the beginning of MenuBarManager::Activate to where they're actually used, to increase readability. Change-Id: I885c6039fd77a023204b60bfc8ef97089d98716a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175508 Reviewed-by: Michael Weghorn <[email protected]> Tested-by: Jenkins diff --git a/framework/source/uielement/menubarmanager.cxx b/framework/source/uielement/menubarmanager.cxx index 3b228ff82c9e..014c226e2d47 100644 --- a/framework/source/uielement/menubarmanager.cxx +++ b/framework/source/uielement/menubarmanager.cxx @@ -560,8 +560,6 @@ IMPL_LINK( MenuBarManager, Activate, Menu *, pMenu, bool ) bool bDontHide = officecfg::Office::Common::View::Menu::DontHideDisabledEntry::get(); const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings(); bool bShowMenuImages = rSettings.GetUseImagesInMenus(); - bool bShowShortcuts = m_bHasMenuBar || rSettings.GetContextMenuShortcuts(); - bool bHasDisabledEntries = SvtCommandOptions().HasEntriesDisabled(); SolarMutexGuard g; @@ -605,6 +603,7 @@ IMPL_LINK( MenuBarManager, Activate, Menu *, pMenu, bool ) } // Try to set accelerator keys + bool bShowShortcuts = m_bHasMenuBar || rSettings.GetContextMenuShortcuts(); if ( bShowShortcuts ) RetrieveShortcuts( m_aMenuItemHandlerVector ); for (auto const& menuItemHandler : m_aMenuItemHandlerVector) @@ -650,7 +649,7 @@ IMPL_LINK( MenuBarManager, Activate, Menu *, pMenu, bool ) m_xURLTransformer->parseStrict( aTargetURL ); - if ( bHasDisabledEntries ) + if (SvtCommandOptions().HasEntriesDisabled()) { if ( aCmdOptions.LookupDisabled( aTargetURL.Path )) pMenu->HideItem( menuItemHandler->nItemId ); commit ca2900e6ed3de60ed143e6189a301132047b5b59 Author: Michael Weghorn <[email protected]> AuthorDate: Wed Oct 23 16:04:40 2024 +0200 Commit: Michael Weghorn <[email protected]> CommitDate: Thu Oct 24 09:08:03 2024 +0200 framework: Drop extra scope for setting accelerator keys This is in preparation of deduplicating code in an upcoming commit. (Use `git show --ignore-space-change` to see the "actual change" more clearly.) Change-Id: Ibc9b8d8f77c2b2182c359a287eb604a92ed9c4e2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175507 Tested-by: Jenkins Reviewed-by: Michael Weghorn <[email protected]> diff --git a/framework/source/uielement/menubarmanager.cxx b/framework/source/uielement/menubarmanager.cxx index 53fbf41aad41..3b228ff82c9e 100644 --- a/framework/source/uielement/menubarmanager.cxx +++ b/framework/source/uielement/menubarmanager.cxx @@ -605,26 +605,23 @@ IMPL_LINK( MenuBarManager, Activate, Menu *, pMenu, bool ) } // Try to set accelerator keys + if ( bShowShortcuts ) + RetrieveShortcuts( m_aMenuItemHandlerVector ); + for (auto const& menuItemHandler : m_aMenuItemHandlerVector) { - if ( bShowShortcuts ) - RetrieveShortcuts( m_aMenuItemHandlerVector ); - - for (auto const& menuItemHandler : m_aMenuItemHandlerVector) + if ( !bShowShortcuts ) { - if ( !bShowShortcuts ) - { - pMenu->SetAccelKey( menuItemHandler->nItemId, vcl::KeyCode() ); - } - else if ( menuItemHandler->aMenuItemURL == aCmdHelpIndex ) - { - // Set key code, workaround for hard-coded shortcut F1 mapped to .uno:HelpIndex - // Only non-popup menu items can have a short-cut - vcl::KeyCode aKeyCode( KEY_F1 ); - pMenu->SetAccelKey( menuItemHandler->nItemId, aKeyCode ); - } - else if ( pMenu->GetPopupMenu( menuItemHandler->nItemId ) == nullptr ) - pMenu->SetAccelKey( menuItemHandler->nItemId, menuItemHandler->aKeyCode ); + pMenu->SetAccelKey( menuItemHandler->nItemId, vcl::KeyCode() ); + } + else if ( menuItemHandler->aMenuItemURL == aCmdHelpIndex ) + { + // Set key code, workaround for hard-coded shortcut F1 mapped to .uno:HelpIndex + // Only non-popup menu items can have a short-cut + vcl::KeyCode aKeyCode( KEY_F1 ); + pMenu->SetAccelKey( menuItemHandler->nItemId, aKeyCode ); } + else if ( pMenu->GetPopupMenu( menuItemHandler->nItemId ) == nullptr ) + pMenu->SetAccelKey( menuItemHandler->nItemId, menuItemHandler->aKeyCode ); } URL aTargetURL;
