[Libreoffice-commits] core.git: vcl/inc vcl/qt5
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Wed Feb 27 19:54:53 UTC 2019
vcl/inc/qt5/Qt5Menu.hxx | 2 +-
vcl/qt5/Qt5Menu.cxx | 45 +++++++++++++++++++++++----------------------
2 files changed, 24 insertions(+), 23 deletions(-)
New commits:
commit c74cc70966e9bc3756509f4d50af50ec181e1774
Author: Aleksei Nikiforov <darktemplar at basealt.ru>
AuthorDate: Wed Feb 27 15:02:15 2019 +0300
Commit: Thorsten Behrens <Thorsten.Behrens at CIB.de>
CommitDate: Wed Feb 27 20:54:25 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.Behrens at CIB.de>
diff --git a/vcl/inc/qt5/Qt5Menu.hxx b/vcl/inc/qt5/Qt5Menu.hxx
index a11fbd186575..adac6f6ccdad 100644
--- a/vcl/inc/qt5/Qt5Menu.hxx
+++ b/vcl/inc/qt5/Qt5Menu.hxx
@@ -38,7 +38,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());
More information about the Libreoffice-commits
mailing list