tdf#130163 Show undock or dock menu item in toolbar menu

This patch removes toolbar menu item 'Dock Toolbar' enable state and
shows 'Undock Toolbar' menu item when toolbar is docked and 'Dock
Toolbar' menu item when toolbar is undocked. It also sets the
accelerator key displayed for these items to Shift+Ctrl+F10

Change-Id: I0e4673529438c42452026602785857066ea7874a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/85673
Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
Jim Raykowski 2019-12-21 14:54:28 -09:00 committed by Noel Grandin
parent 08313c42ab
commit 0fb4f2107d
4 changed files with 40 additions and 7 deletions

View file

@ -22,10 +22,11 @@
#define MENUITEM_TOOLBAR_VISIBLEBUTTON 1
#define MENUITEM_TOOLBAR_CUSTOMIZETOOLBAR 2
#define MENUITEM_TOOLBAR_DOCKTOOLBAR 3
#define MENUITEM_TOOLBAR_DOCKALLTOOLBAR 4
#define MENUITEM_TOOLBAR_LOCKTOOLBARPOSITION 5
#define MENUITEM_TOOLBAR_CLOSE 6
#define MENUITEM_TOOLBAR_UNDOCKTOOLBAR 3
#define MENUITEM_TOOLBAR_DOCKTOOLBAR 4
#define MENUITEM_TOOLBAR_DOCKALLTOOLBAR 5
#define MENUITEM_TOOLBAR_LOCKTOOLBARPOSITION 6
#define MENUITEM_TOOLBAR_CLOSE 7
#endif

View file

@ -27,6 +27,7 @@
#define STR_CLOSEDOC_ANDRETURN NC_("STR_CLOSEDOC_ANDRETURN", "~Close & Return to " )
#define STR_TOOLBAR_VISIBLE_BUTTONS NC_("STR_TOOLBAR_VISIBLE_BUTTONS", "Visible ~Buttons")
#define STR_TOOLBAR_CUSTOMIZE_TOOLBAR NC_("STR_TOOLBAR_CUSTOMIZE_TOOLBAR", "~Customize Toolbar...")
#define STR_TOOLBAR_UNDOCK_TOOLBAR NC_("STR_TOOLBAR_UNDOCK_TOOLBAR", "U~ndock Toolbar" )
#define STR_TOOLBAR_DOCK_TOOLBAR NC_("STR_TOOLBAR_DOCK_TOOLBAR", "~Dock Toolbar" )
#define STR_TOOLBAR_DOCK_ALL_TOOLBARS NC_("STR_TOOLBAR_DOCK_ALL_TOOLBARS", "Dock ~All Toolbars" )
#define STR_TOOLBAR_LOCK_TOOLBAR NC_("STR_TOOLBAR_LOCK_TOOLBAR", "~Lock Toolbar Position" )

View file

@ -94,6 +94,7 @@ class ToolBarManager : public ToolbarManager_Base
enum ExecuteCommand
{
EXEC_CMD_CLOSETOOLBAR,
EXEC_CMD_UNDOCKTOOLBAR,
EXEC_CMD_DOCKTOOLBAR,
EXEC_CMD_DOCKALLTOOLBARS
};

View file

@ -1447,8 +1447,22 @@ void ToolBarManager::AddCustomizeMenuItems(ToolBox const * pToolBar)
nGroupLen = pMenu->GetItemCount();
}
if (MenuItemAllowed(MENUITEM_TOOLBAR_DOCKTOOLBAR))
pMenu->InsertItem(MENUITEM_TOOLBAR_DOCKTOOLBAR, FwkResId(STR_TOOLBAR_DOCK_TOOLBAR));
if (pToolBar->IsFloatingMode())
{
if (MenuItemAllowed(MENUITEM_TOOLBAR_DOCKTOOLBAR))
{
pMenu->InsertItem(MENUITEM_TOOLBAR_DOCKTOOLBAR, FwkResId(STR_TOOLBAR_DOCK_TOOLBAR));
pMenu->SetAccelKey(MENUITEM_TOOLBAR_DOCKTOOLBAR, vcl::KeyCode(KEY_F10, true, true, false, false));
}
}
else
{
if (MenuItemAllowed(MENUITEM_TOOLBAR_UNDOCKTOOLBAR))
{
pMenu->InsertItem(MENUITEM_TOOLBAR_UNDOCKTOOLBAR, FwkResId(STR_TOOLBAR_UNDOCK_TOOLBAR));
pMenu->SetAccelKey(MENUITEM_TOOLBAR_UNDOCKTOOLBAR, vcl::KeyCode(KEY_F10, true, true, false, false));
}
}
if (MenuItemAllowed(MENUITEM_TOOLBAR_DOCKALLTOOLBAR))
pMenu->InsertItem(MENUITEM_TOOLBAR_DOCKALLTOOLBAR, FwkResId(STR_TOOLBAR_DOCK_ALL_TOOLBARS));
@ -1475,7 +1489,6 @@ void ToolBarManager::AddCustomizeMenuItems(ToolBox const * pToolBar)
if ( !bIsFloating )
{
pMenu->EnableItem(MENUITEM_TOOLBAR_DOCKTOOLBAR, false);
pMenu->EnableItem(MENUITEM_TOOLBAR_DOCKALLTOOLBAR, false);
Reference< XDockableWindow > xDockable( VCLUnoHelper::GetInterface( m_pToolBar ), UNO_QUERY );
if( xDockable.is() )
@ -1647,6 +1660,18 @@ IMPL_LINK( ToolBarManager, MenuSelect, Menu*, pMenu, bool )
break;
}
case MENUITEM_TOOLBAR_UNDOCKTOOLBAR:
{
ExecuteInfo* pExecuteInfo = new ExecuteInfo;
pExecuteInfo->aToolbarResName = m_aResourceName;
pExecuteInfo->nCmd = EXEC_CMD_UNDOCKTOOLBAR;
pExecuteInfo->xLayoutManager = getLayoutManagerFromFrame( m_xFrame );
Application::PostUserEvent( LINK(nullptr, ToolBarManager, ExecuteHdl_Impl), pExecuteInfo );
break;
}
case MENUITEM_TOOLBAR_DOCKTOOLBAR:
{
ExecuteInfo* pExecuteInfo = new ExecuteInfo;
@ -1883,6 +1908,11 @@ IMPL_STATIC_LINK( ToolBarManager, ExecuteHdl_Impl, void*, p, void )
if ( pDockWin )
pDockWin->Close();
}
else if (( pExecuteInfo->nCmd == EXEC_CMD_UNDOCKTOOLBAR ) &&
( pExecuteInfo->xLayoutManager.is() ))
{
pExecuteInfo->xLayoutManager->floatWindow( pExecuteInfo->aToolbarResName );
}
else if (( pExecuteInfo->nCmd == EXEC_CMD_DOCKTOOLBAR ) &&
( pExecuteInfo->xLayoutManager.is() ))
{