vcl/inc/qt5/Qt5Menu.hxx | 2 +- vcl/qt5/Qt5Menu.cxx | 45 +++++++++++++++++++++++---------------------- 2 files changed, 24 insertions(+), 23 deletions(-)
New commits: commit 5df2207997aa5de50abd3ce6e47bc20ab53dfb61 Author: Aleksei Nikiforov <darktemp...@basealt.ru> AuthorDate: Wed Feb 27 15:02:15 2019 +0300 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Thu Feb 28 09:30:19 2019 +0100 KDE5: set correct parent menu in function Set correct parent menu in function Qt5Menu::InsertMenuItem instead of just returning it and setting it later if needed. Change-Id: Id866987e91ec1d57c720735da6afc44109aa901a Reviewed-on: https://gerrit.libreoffice.org/68437 Tested-by: Jenkins Reviewed-by: Thorsten Behrens <thorsten.behr...@cib.de> (cherry picked from commit c74cc70966e9bc3756509f4d50af50ec181e1774) Reviewed-on: https://gerrit.libreoffice.org/68459 Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/vcl/inc/qt5/Qt5Menu.hxx b/vcl/inc/qt5/Qt5Menu.hxx index 1ad62a82b9bd..fb2f7e17027b 100644 --- a/vcl/inc/qt5/Qt5Menu.hxx +++ b/vcl/inc/qt5/Qt5Menu.hxx @@ -35,7 +35,7 @@ private: void DoFullMenuUpdate(Menu* pMenuBar); static void NativeItemText(OUString& rItemText); - QMenu* InsertMenuItem(Qt5MenuItem* pSalMenuItem, unsigned nPos); + void InsertMenuItem(Qt5MenuItem* pSalMenuItem, unsigned nPos); void ReinitializeActionGroup(unsigned nPos); void ResetAllActionGroups(); diff --git a/vcl/qt5/Qt5Menu.cxx b/vcl/qt5/Qt5Menu.cxx index a00cce02dffa..49de2c0305a7 100644 --- a/vcl/qt5/Qt5Menu.cxx +++ b/vcl/qt5/Qt5Menu.cxx @@ -33,9 +33,8 @@ Qt5Menu::Qt5Menu(bool bMenuBar) bool Qt5Menu::VisibleMenuBar() { return true; } -QMenu* Qt5Menu::InsertMenuItem(Qt5MenuItem* pSalMenuItem, unsigned nPos) +void Qt5Menu::InsertMenuItem(Qt5MenuItem* pSalMenuItem, unsigned nPos) { - QMenu* pQMenu = mpQMenu; sal_uInt16 nId = pSalMenuItem->mnId; OUString aText = mpVCLMenu->GetItemText(nId); NativeItemText(aText); @@ -49,7 +48,7 @@ QMenu* Qt5Menu::InsertMenuItem(Qt5MenuItem* pSalMenuItem, unsigned nPos) // top-level menu if (mpQMenuBar) { - pQMenu = new QMenu(toQString(aText), nullptr); + QMenu* pQMenu = new QMenu(toQString(aText), nullptr); pSalMenuItem->mpMenu.reset(pQMenu); if ((nPos != MENU_APPEND) @@ -62,31 +61,38 @@ QMenu* Qt5Menu::InsertMenuItem(Qt5MenuItem* pSalMenuItem, unsigned nPos) mpQMenuBar->addMenu(pQMenu); } + // correct parent menu for generated menu + if (pSalMenuItem->mpSubMenu) + { + pSalMenuItem->mpSubMenu->mpQMenu = pQMenu; + } + connect(pQMenu, &QMenu::aboutToShow, this, [pSalMenuItem] { slotMenuAboutToShow(pSalMenuItem); }); connect(pQMenu, &QMenu::aboutToHide, this, [pSalMenuItem] { slotMenuAboutToHide(pSalMenuItem); }); } } - else if (pQMenu) + else if (mpQMenu) { if (pSalMenuItem->mpSubMenu) { // submenu - QMenu* pTempQMenu = new QMenu(toQString(aText), nullptr); - pSalMenuItem->mpMenu.reset(pTempQMenu); + QMenu* pQMenu = new QMenu(toQString(aText), nullptr); + pSalMenuItem->mpMenu.reset(pQMenu); if ((nPos != MENU_APPEND) - && (static_cast<size_t>(nPos) < static_cast<size_t>(pQMenu->actions().size()))) + && (static_cast<size_t>(nPos) < static_cast<size_t>(mpQMenu->actions().size()))) { - pQMenu->insertMenu(pQMenu->actions()[nPos], pTempQMenu); + mpQMenu->insertMenu(mpQMenu->actions()[nPos], pQMenu); } else { - pQMenu->addMenu(pTempQMenu); + mpQMenu->addMenu(pQMenu); } - pQMenu = pTempQMenu; + // correct parent menu for generated menu + pSalMenuItem->mpSubMenu->mpQMenu = pQMenu; ReinitializeActionGroup(nPos); @@ -107,13 +113,13 @@ QMenu* Qt5Menu::InsertMenuItem(Qt5MenuItem* pSalMenuItem, unsigned nPos) pAction->setSeparator(true); if ((nPos != MENU_APPEND) - && (static_cast<size_t>(nPos) < static_cast<size_t>(pQMenu->actions().size()))) + && (static_cast<size_t>(nPos) < static_cast<size_t>(mpQMenu->actions().size()))) { - pQMenu->insertAction(pQMenu->actions()[nPos], pAction); + mpQMenu->insertAction(mpQMenu->actions()[nPos], pAction); } else { - pQMenu->addAction(pAction); + mpQMenu->addAction(pAction); } ReinitializeActionGroup(nPos); @@ -125,13 +131,13 @@ QMenu* Qt5Menu::InsertMenuItem(Qt5MenuItem* pSalMenuItem, unsigned nPos) pSalMenuItem->mpAction.reset(pAction); if ((nPos != MENU_APPEND) - && (static_cast<size_t>(nPos) < static_cast<size_t>(pQMenu->actions().size()))) + && (static_cast<size_t>(nPos) < static_cast<size_t>(mpQMenu->actions().size()))) { - pQMenu->insertAction(pQMenu->actions()[nPos], pAction); + mpQMenu->insertAction(mpQMenu->actions()[nPos], pAction); } else { - pQMenu->addAction(pAction); + mpQMenu->addAction(pAction); } ReinitializeActionGroup(nPos); @@ -152,8 +158,6 @@ QMenu* Qt5Menu::InsertMenuItem(Qt5MenuItem* pSalMenuItem, unsigned nPos) pAction->setEnabled(pSalMenuItem->mbEnabled); pAction->setVisible(pSalMenuItem->mbVisible); } - - return pQMenu; } void Qt5Menu::ReinitializeActionGroup(unsigned nPos) @@ -419,14 +423,11 @@ void Qt5Menu::DoFullMenuUpdate(Menu* pMenuBar) for (sal_Int32 nItem = 0; nItem < static_cast<sal_Int32>(GetItemCount()); nItem++) { Qt5MenuItem* pSalMenuItem = GetItemAtPos(nItem); - QMenu* pQMenu = InsertMenuItem(pSalMenuItem, nItem); + InsertMenuItem(pSalMenuItem, nItem); SetItemImage(nItem, pSalMenuItem, pSalMenuItem->maImage); if (pSalMenuItem->mpSubMenu != nullptr) { - // correct parent menu before calling HandleMenuActivateEvent - pSalMenuItem->mpSubMenu->mpQMenu = pQMenu; - pMenuBar->HandleMenuActivateEvent(pSalMenuItem->mpSubMenu->GetMenu()); pSalMenuItem->mpSubMenu->DoFullMenuUpdate(pMenuBar); pMenuBar->HandleMenuDeActivateEvent(pSalMenuItem->mpSubMenu->GetMenu()); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits