diff options
author | Caolán McNamara <caolanm@redhat.com> | 2020-12-20 20:36:23 +0000 |
---|---|---|
committer | Szymon Kłos <szymon.klos@collabora.com> | 2021-05-25 12:12:31 +0200 |
commit | fbf21fd35c834955bd96edcf0898744098013cd9 (patch) | |
tree | b54518d2be597f4b353511938ae5f9b1d4480e8d /sd | |
parent | fff17f84febe42689e1d2d5c14358a21bb595f49 (diff) |
weld impress layoutmenu
Change-Id: Ibc8038b37f8ff689050d9abb4ec0d2fac2eaadf9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108066
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sd')
-rw-r--r-- | sd/source/ui/sidebar/LayoutMenu.cxx | 36 | ||||
-rw-r--r-- | sd/source/ui/sidebar/LayoutMenu.hxx | 3 |
2 files changed, 13 insertions, 26 deletions
diff --git a/sd/source/ui/sidebar/LayoutMenu.cxx b/sd/source/ui/sidebar/LayoutMenu.cxx index a402d99df3ab..559409519f9f 100644 --- a/sd/source/ui/sidebar/LayoutMenu.cxx +++ b/sd/source/ui/sidebar/LayoutMenu.cxx @@ -31,6 +31,7 @@ #include <sdresid.hxx> #include <unokywds.hxx> #include <bitmaps.hlst> +#include <tools/gen.hxx> #include <tools/SlotStateListener.hxx> #include <DrawController.hxx> #include <DrawDocShell.hxx> @@ -50,7 +51,7 @@ #include <svl/intitem.hxx> #include <vcl/commandevent.hxx> #include <vcl/image.hxx> -#include <vcl/floatwin.hxx> +#include <vcl/weldutils.hxx> #include <xmloff/autolayout.hxx> #include <com/sun/star/drawing/framework/XControllerManager.hpp> @@ -598,13 +599,10 @@ void LayoutMenu::ShowContextMenu(const Point* pPos) } // Setup the menu. - VclBuilder aBuilder(nullptr, AllSettings::GetUIRootDir(), "modules/simpress/ui/layoutmenu.ui", ""); - VclPtr<PopupMenu> pMenu(aBuilder.get_menu("menu")); - FloatingWindow* pMenuWindow = dynamic_cast<FloatingWindow*>(pMenu->GetWindow()); - if (pMenuWindow != nullptr) - pMenuWindow->SetPopupModeFlags( - pMenuWindow->GetPopupModeFlags() | FloatWinPopupFlags::NoMouseUpClose); - pMenu->SetSelectHdl(LINK(this, LayoutMenu, OnMenuItemSelected)); + ::tools::Rectangle aRect(aMenuPosition, Size(1, 1)); + weld::Window* pPopupParent = weld::GetPopupParent(*this, aRect); + std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(pPopupParent, "modules/simpress/ui/layoutmenu.ui")); + std::unique_ptr<weld::Menu> xMenu(xBuilder->weld_menu("menu")); // Disable the SID_INSERTPAGE_LAYOUT_MENU item when // the document is read-only. @@ -612,10 +610,10 @@ void LayoutMenu::ShowContextMenu(const Point* pPos) const SfxItemState aState ( mrBase.GetViewFrame()->GetDispatcher()->QueryState(SID_INSERTPAGE, pItem)); if (aState == SfxItemState::DISABLED) - pMenu->EnableItem(SID_INSERTPAGE_LAYOUT_MENU, false); + xMenu->set_sensitive("insert", false); // Show the menu. - pMenu->Execute(this, ::tools::Rectangle(aMenuPosition,Size(1,1)), PopupMenuFlags::ExecuteDown); + OnMenuItemSelected(xMenu->popup_at_rect(pPopupParent, aRect)); } IMPL_LINK_NOARG(LayoutMenu, StateChangeHandler, const OUString&, void) @@ -623,29 +621,21 @@ IMPL_LINK_NOARG(LayoutMenu, StateChangeHandler, const OUString&, void) InvalidateContent(); } -IMPL_LINK(LayoutMenu, OnMenuItemSelected, Menu*, pMenu, bool) +void LayoutMenu::OnMenuItemSelected(std::string_view ident) { - if (pMenu == nullptr) - { - OSL_ENSURE(pMenu!=nullptr, "LayoutMenu::OnMenuItemSelected: illegal menu!"); - return false; - } - - pMenu->Deactivate(); - OString sIdent = pMenu->GetCurItemIdent(); + if (ident.empty()) + return; - if (sIdent == "apply") + if (ident == "apply") { AssignLayoutToSelectedSlides(GetSelectedAutoLayout()); } - else if (sIdent == "insert") + else if (ident == "insert") { // Add arguments to this slot and forward it to the main view // shell. InsertPageWithLayout(GetSelectedAutoLayout()); } - - return false; } // Selects an appropriate layout of the slide inside control. diff --git a/sd/source/ui/sidebar/LayoutMenu.hxx b/sd/source/ui/sidebar/LayoutMenu.hxx index 90a7c5751892..32847df60d71 100644 --- a/sd/source/ui/sidebar/LayoutMenu.hxx +++ b/sd/source/ui/sidebar/LayoutMenu.hxx @@ -24,8 +24,6 @@ #include <sfx2/sidebar/PanelLayout.hxx> #include <svtools/valueset.hxx> -#include <vcl/menu.hxx> -#include <vcl/transfer.hxx> #include <sfx2/request.hxx> #include <xmloff/autolayout.hxx> @@ -156,7 +154,6 @@ private: DECL_LINK(StateChangeHandler, const OUString&, void); DECL_LINK(EventMultiplexerListener, ::sd::tools::EventMultiplexerEvent&, void); DECL_LINK(WindowEventHandler, VclWindowEvent&, void); - DECL_LINK(OnMenuItemSelected, Menu*, bool); void OnMenuItemSelected(std::string_view ident); }; |