[Libreoffice-commits] core.git: framework/inc framework/source
Jim Raykowski (via logerrit)
logerrit at kemper.freedesktop.org
Mon Feb 24 07:01:22 UTC 2020
framework/inc/classes/resource.hxx | 9 +++---
framework/inc/strings.hrc | 1
framework/inc/uielement/toolbarmanager.hxx | 1
framework/source/uielement/toolbarmanager.cxx | 36 +++++++++++++++++++++++---
4 files changed, 40 insertions(+), 7 deletions(-)
New commits:
commit 0fb4f2107d08febd4925dce6d96b41da9917e9ae
Author: Jim Raykowski <raykowj at gmail..com>
AuthorDate: Sat Dec 21 14:54:28 2019 -0900
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Mon Feb 24 08:00:46 2020 +0100
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 at collabora.co.uk>
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/framework/inc/classes/resource.hxx b/framework/inc/classes/resource.hxx
index a9f98e607baa..04f00677c69d 100644
--- a/framework/inc/classes/resource.hxx
+++ b/framework/inc/classes/resource.hxx
@@ -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
diff --git a/framework/inc/strings.hrc b/framework/inc/strings.hrc
index ef3ad73c1956..d3f28fcc9e21 100644
--- a/framework/inc/strings.hrc
+++ b/framework/inc/strings.hrc
@@ -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" )
diff --git a/framework/inc/uielement/toolbarmanager.hxx b/framework/inc/uielement/toolbarmanager.hxx
index f43a3511b85d..8f3eb4c2b2eb 100644
--- a/framework/inc/uielement/toolbarmanager.hxx
+++ b/framework/inc/uielement/toolbarmanager.hxx
@@ -94,6 +94,7 @@ class ToolBarManager : public ToolbarManager_Base
enum ExecuteCommand
{
EXEC_CMD_CLOSETOOLBAR,
+ EXEC_CMD_UNDOCKTOOLBAR,
EXEC_CMD_DOCKTOOLBAR,
EXEC_CMD_DOCKALLTOOLBARS
};
diff --git a/framework/source/uielement/toolbarmanager.cxx b/framework/source/uielement/toolbarmanager.cxx
index 78a5c1198584..d224cfc2a955 100644
--- a/framework/source/uielement/toolbarmanager.cxx
+++ b/framework/source/uielement/toolbarmanager.cxx
@@ -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() ))
{
More information about the Libreoffice-commits
mailing list