summaryrefslogtreecommitdiff
path: root/svtools/source/control/toolbarmenu.cxx
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2020-01-09 15:45:46 +0000
committerCaolán McNamara <caolanm@redhat.com>2020-01-10 15:13:45 +0100
commit14e26096f0476b8ecb70511c304a0cdf5440ef7a (patch)
tree9aca765b2599b23ad5d88e37877c345c1a71c254 /svtools/source/control/toolbarmenu.cxx
parent9b97efd4228489f2e54a948e676917e50902fd33 (diff)
make welded toolbars on-demand that were previously on-demand
Change-Id: I795723260deb317093e83d951d968e0b3d3a1850 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/86531 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'svtools/source/control/toolbarmenu.cxx')
-rw-r--r--svtools/source/control/toolbarmenu.cxx48
1 files changed, 43 insertions, 5 deletions
diff --git a/svtools/source/control/toolbarmenu.cxx b/svtools/source/control/toolbarmenu.cxx
index 7b12d910a81e..7d74380a2d10 100644
--- a/svtools/source/control/toolbarmenu.cxx
+++ b/svtools/source/control/toolbarmenu.cxx
@@ -1537,27 +1537,65 @@ IMPL_LINK_NOARG(WeldToolbarPopup, FocusHdl, weld::Widget&, void)
GrabFocus();
}
-InterimToolbarPopup::InterimToolbarPopup(const css::uno::Reference<css::frame::XFrame>& rFrame, vcl::Window* pParent, WeldToolbarPopup* pPopup)
+ToolbarPopupContainer::ToolbarPopupContainer(weld::Widget* pParent)
+ : m_xBuilder(Application::CreateBuilder(pParent, "svx/ui/toolbarpopover.ui"))
+ , m_xTopLevel(m_xBuilder->weld_container("ToolbarPopover"))
+ , m_xContainer(m_xBuilder->weld_container("container"))
+{
+ m_xTopLevel->connect_focus_in(LINK(this, ToolbarPopupContainer, FocusHdl));
+}
+
+void ToolbarPopupContainer::setPopover(std::unique_ptr<WeldToolbarPopup> xPopup)
+{
+ m_xPopup = std::move(xPopup);
+ // move the WeldToolbarPopup contents into this toolbar so on-demand contents can appear inside a preexisting gtk popover
+ // because the arrow for the popover is only enabled if there's a popover set
+ m_xPopup->getTopLevel()->move(m_xPopup->getContainer(), m_xContainer.get());
+ m_xPopup->GrabFocus();
+}
+
+void ToolbarPopupContainer::unsetPopover()
+{
+ if (!m_xPopup)
+ return;
+ m_xContainer->move(m_xPopup->getContainer(), m_xPopup->getTopLevel());
+ m_xPopup.reset();
+}
+
+ToolbarPopupContainer::~ToolbarPopupContainer()
+{
+ unsetPopover();
+}
+
+IMPL_LINK_NOARG(ToolbarPopupContainer, FocusHdl, weld::Widget&, void)
+{
+ if (m_xPopup)
+ m_xPopup->GrabFocus();
+}
+
+InterimToolbarPopup::InterimToolbarPopup(const css::uno::Reference<css::frame::XFrame>& rFrame, vcl::Window* pParent,
+ std::unique_ptr<WeldToolbarPopup> xPopup)
: ToolbarPopup(rFrame, pParent, "InterimDockParent", "svx/ui/interimdockparent.ui")
, m_xBox(get<vcl::Window>("box"))
, m_xBuilder(Application::CreateInterimBuilder(m_xBox.get(), "svx/ui/interimparent.ui"))
, m_xContainer(m_xBuilder->weld_container("container"))
- , m_pPopup(pPopup)
+ , m_xPopup(std::move(xPopup))
{
// move the WeldToolbarPopup contents into this interim toolbar so welded contents can appear as a dropdown in an unwelded toolbar
- m_pPopup->getTopLevel()->move(m_pPopup->getContainer(), m_xContainer.get());
+ m_xPopup->getTopLevel()->move(m_xPopup->getContainer(), m_xContainer.get());
}
void InterimToolbarPopup::GetFocus()
{
ToolbarPopup::GetFocus();
- m_pPopup->GrabFocus();
+ m_xPopup->GrabFocus();
}
void InterimToolbarPopup::dispose()
{
// move the contents back where it belongs
- m_xContainer->move(m_pPopup->getContainer(), m_pPopup->getTopLevel());
+ m_xContainer->move(m_xPopup->getContainer(), m_xPopup->getTopLevel());
+ m_xPopup.reset();
m_xContainer.reset();
m_xBox.clear();
ToolbarPopup::dispose();