diff options
author | Shivam Kumar Singh <shivamhere247@gmail.com> | 2020-08-17 10:46:27 +0530 |
---|---|---|
committer | Heiko Tietze <heiko.tietze@documentfoundation.org> | 2020-08-25 11:29:49 +0200 |
commit | eef202b0659a8ef5f2c1d0b38f292039f0ceaa8d (patch) | |
tree | 93306d85b28dcb4777ac979eb1af7dbc03415503 /sfx2 | |
parent | ba9c11e0186844fffa02c594a5c49aad4a52242c (diff) |
tdf#135334 Add keyboard shortcut to launch SI
Change-Id: Id4e911e36527395eb0ed5f29a089a66e0908e882
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100835
Tested-by: Jenkins
Reviewed-by: Heiko Tietze <heiko.tietze@documentfoundation.org>
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/source/sidebar/Sidebar.cxx | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/sfx2/source/sidebar/Sidebar.cxx b/sfx2/source/sidebar/Sidebar.cxx index 6f205389e166..ccd2fbc589d2 100644 --- a/sfx2/source/sidebar/Sidebar.cxx +++ b/sfx2/source/sidebar/Sidebar.cxx @@ -21,11 +21,45 @@ #include <sfx2/sidebar/SidebarController.hxx> #include <sfx2/sidebar/ResourceManager.hxx> #include <sidebar/PanelDescriptor.hxx> +#include <sidebar/Tools.hxx> +#include <sfx2/sidebar/FocusManager.hxx> +#include <sfx2/childwin.hxx> +#include <sfx2/sfxsids.hrc> +#include <com/sun/star/frame/XDispatch.hpp> using namespace css; namespace sfx2::sidebar { +void Sidebar::ToggleDeck(const OUString& rsDeckId, SfxViewFrame* pViewFrame) +{ + if (!pViewFrame) + return; + + SfxChildWindow* pSidebarChildWindow = pViewFrame->GetChildWindow(SID_SIDEBAR); + bool bInitiallyVisible = pSidebarChildWindow && pSidebarChildWindow->IsVisible(); + if (!bInitiallyVisible) + pViewFrame->ShowChildWindow(SID_SIDEBAR); + + if (SidebarController* pController = + SidebarController::GetSidebarControllerForFrame(pViewFrame->GetFrame().GetFrameInterface())) + { + if (bInitiallyVisible && pController->IsDeckVisible(rsDeckId)) + { + // close the sidebar if it was already visible and showing this sidebar deck + const util::URL aURL(Tools::GetURL(".uno:Sidebar")); + css::uno::Reference<frame::XDispatch> xDispatch(Tools::GetDispatch(pViewFrame->GetFrame().GetFrameInterface(), aURL)); + if (xDispatch.is()) + xDispatch->dispatch(aURL, css::uno::Sequence<beans::PropertyValue>()); + } + else + { + pController->OpenThenSwitchToDeck(rsDeckId); + pController->GetFocusManager().GrabFocusPanel(); + } + } +} + void Sidebar::ShowPanel ( const OUString& rsPanelId, const css::uno::Reference<frame::XFrame>& rxFrame, bool bFocus) |