summaryrefslogtreecommitdiff
path: root/svtools/source
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
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')
-rw-r--r--svtools/source/control/toolbarmenu.cxx48
-rw-r--r--svtools/source/uno/popupwindowcontroller.cxx27
2 files changed, 69 insertions, 6 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();
diff --git a/svtools/source/uno/popupwindowcontroller.cxx b/svtools/source/uno/popupwindowcontroller.cxx
index 7b1e3357424d..50135adbe453 100644
--- a/svtools/source/uno/popupwindowcontroller.cxx
+++ b/svtools/source/uno/popupwindowcontroller.cxx
@@ -177,7 +177,7 @@ sal_Bool SAL_CALL PopupWindowController::supportsService( const OUString& Servic
void SAL_CALL PopupWindowController::dispose()
{
mxInterimPopover.clear();
- mxPopover.reset();
+ mxPopoverContainer.reset();
mxImpl.reset();
svt::ToolboxController::dispose();
}
@@ -207,8 +207,20 @@ void SAL_CALL PopupWindowController::statusChanged( const frame::FeatureStateEve
}
}
+std::unique_ptr<WeldToolbarPopup> PopupWindowController::weldPopupWindow()
+{
+ return nullptr;
+}
+
Reference< awt::XWindow > SAL_CALL PopupWindowController::createPopupWindow()
{
+ if (m_pToolbar)
+ {
+ mxPopoverContainer->unsetPopover();
+ mxPopoverContainer->setPopover(weldPopupWindow());
+ return Reference<awt::XWindow>();
+ }
+
VclPtr< ToolBox > pToolBox = dynamic_cast< ToolBox* >( VCLUnoHelper::GetWindow( getParent() ).get() );
if( pToolBox )
{
@@ -237,6 +249,19 @@ Reference< awt::XWindow > SAL_CALL PopupWindowController::createPopupWindow()
return Reference< awt::XWindow >();
}
+void SAL_CALL PopupWindowController::click()
+{
+ if (m_pToolbar)
+ {
+ if (m_pToolbar->get_menu_item_active(m_aCommandURL.toUtf8()))
+ createPopupWindow();
+ else
+ mxPopoverContainer->unsetPopover();
+ }
+
+ svt::ToolboxController::click();
+}
+
void PopupWindowController::EndPopupMode()
{
if (m_pToolbar)