summaryrefslogtreecommitdiff
path: root/sfx2
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2016-06-03 11:06:22 +0100
committerCaolán McNamara <caolanm@redhat.com>2016-06-03 11:32:02 +0100
commit905afcee78db68c21b24bddebb0ec082ca938c7d (patch)
treeb2b3b94eec6cc4c01da676019498e974b7ddf395 /sfx2
parent3e50a7bf0e3437a22b6440d0f36c242e40c451ae (diff)
OpenThenSwitchToDeck actually *toggles* deck visibility
so rename it to that and add a OpenThenSwitchToDeck that actually does that, using the Toggle varient as the callback from the sidebar button which toggles the current deck on/off which retains the features of // tdf#67627 Clicking a second time on a Deck icon will close the Deck // tdf#88241 Summoning an undocked sidebar a second time should close sidebar but means that calls to OpenThenSwitchToDeck from e.g. slide layout don't auto close it if that deck is already open Change-Id: I3e3724626b93447a7ab6bc7032e9c6839dabcf55 (cherry picked from commit b81daea4a78083def286fa2d5360b152b7a703fd)
Diffstat (limited to 'sfx2')
-rw-r--r--sfx2/source/sidebar/Sidebar.cxx22
-rw-r--r--sfx2/source/sidebar/SidebarController.cxx19
-rw-r--r--sfx2/source/view/viewfrm.cxx4
3 files changed, 40 insertions, 5 deletions
diff --git a/sfx2/source/sidebar/Sidebar.cxx b/sfx2/source/sidebar/Sidebar.cxx
index ac45f616275a..eaa8a510c00f 100644
--- a/sfx2/source/sidebar/Sidebar.cxx
+++ b/sfx2/source/sidebar/Sidebar.cxx
@@ -47,6 +47,28 @@ void Sidebar::ShowPanel (
pController->OpenThenSwitchToDeck(pPanelDescriptor->msDeckId);
}
+void Sidebar::TogglePanel (
+ const OUString& rsPanelId,
+ const css::uno::Reference<frame::XFrame>& rxFrame)
+{
+ SidebarController* pController = SidebarController::GetSidebarControllerForFrame(rxFrame);
+ if (!pController)
+ return;
+
+ const PanelDescriptor* pPanelDescriptor = pController->GetResourceManager()->GetPanelDescriptor(rsPanelId);
+
+ if (!pPanelDescriptor)
+ return;
+
+ // This should be a lot more sophisticated:
+ // - Make the deck switching asynchronous
+ // - Make sure to use a context that really shows the panel
+
+ // All that is not necessary for the current use cases so lets
+ // keep it simple for the time being.
+ pController->OpenThenToggleDeck(pPanelDescriptor->msDeckId);
+}
+
bool Sidebar::IsPanelVisible(
const OUString& rsPanelId,
const css::uno::Reference<frame::XFrame>& rxFrame)
diff --git a/sfx2/source/sidebar/SidebarController.cxx b/sfx2/source/sidebar/SidebarController.cxx
index 0506b77ba85c..002bcc49e672 100644
--- a/sfx2/source/sidebar/SidebarController.cxx
+++ b/sfx2/source/sidebar/SidebarController.cxx
@@ -95,7 +95,7 @@ SidebarController::SidebarController (
mpTabBar(VclPtr<TabBar>::Create(
mpParentWindow,
rxFrame,
- [this](const ::rtl::OUString& rsDeckId) { return this->OpenThenSwitchToDeck(rsDeckId); },
+ [this](const ::rtl::OUString& rsDeckId) { return this->OpenThenToggleDeck(rsDeckId); },
[this](const Rectangle& rButtonBox,const ::std::vector<TabBar::DeckMenuData>& rMenuData) { return this->ShowPopupMenu(rButtonBox,rMenuData); },
this)),
mxFrame(rxFrame),
@@ -503,8 +503,8 @@ void SidebarController::UpdateConfigurations()
}
}
-void SidebarController::OpenThenSwitchToDeck (
- const ::rtl::OUString& rsDeckId)
+void SidebarController::OpenThenToggleDeck (
+ const OUString& rsDeckId)
{
SfxSplitWindow* pSplitWindow = GetSplitWindow();
if ( pSplitWindow && !pSplitWindow->IsFadeIn() )
@@ -526,6 +526,19 @@ void SidebarController::OpenThenSwitchToDeck (
mpTabBar->HighlightDeck(rsDeckId);
}
+void SidebarController::OpenThenSwitchToDeck (
+ const OUString& rsDeckId)
+{
+ SfxSplitWindow* pSplitWindow = GetSplitWindow();
+ if ( pSplitWindow && !pSplitWindow->IsFadeIn() )
+ // tdf#83546 Collapsed sidebar should expand first
+ pSplitWindow->FadeIn();
+ RequestOpenDeck();
+ SwitchToDeck(rsDeckId);
+ mpTabBar->Invalidate();
+ mpTabBar->HighlightDeck(rsDeckId);
+}
+
void SidebarController::SwitchToDefaultDeck()
{
SwitchToDeck(gsDefaultDeckId);
diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx
index 3545508973bc..4046ba616ceb 100644
--- a/sfx2/source/view/viewfrm.cxx
+++ b/sfx2/source/view/viewfrm.cxx
@@ -3036,8 +3036,8 @@ void SfxViewFrame::ChildWindowExecute( SfxRequest &rReq )
// First make sure that the sidebar is visible
ShowChildWindow(SID_SIDEBAR);
- ::sfx2::sidebar::Sidebar::ShowPanel("StyleListPanel",
- GetFrame().GetFrameInterface());
+ ::sfx2::sidebar::Sidebar::TogglePanel("StyleListPanel",
+ GetFrame().GetFrameInterface());
rReq.Done();
return;
}