Kaydet (Commit) a77163f0 authored tarafından Katarina Behrens's avatar Katarina Behrens

tdf#119856: [Re-]activate menu before dispatching command

Menu entry dispatchers may be cleared (after they've been initially
set) when an extension comes with its own menu entries. Activating
the entry sets the dispatcher again so that dispatching a command
can proceed

Change-Id: I3909fb5eb6e6e2fa7db0418aca17009e60f01372
Reviewed-on: https://gerrit.libreoffice.org/62180
Tested-by: Jenkins
Reviewed-by: 's avatarKatarina Behrens <Katarina.Behrens@cib.de>
üst 22beeb3e
......@@ -60,7 +60,7 @@ public:
Qt5MenuItem* GetItemAtPos(unsigned nPos) { return maItems[nPos]; }
private slots:
void DispatchCommand(Qt5MenuItem* pQItem);
void slotMenuTriggered(Qt5MenuItem* pQItem);
};
class Qt5MenuItem : public SalMenuItem
......
......@@ -138,7 +138,7 @@ void Qt5Menu::DoFullMenuUpdate(Menu* pMenuBar, QMenu* pParentMenu)
pAction->setVisible(pSalMenuItem->mbVisible);
connect(pAction, &QAction::triggered, this,
[this, pSalMenuItem] { DispatchCommand(pSalMenuItem); });
[this, pSalMenuItem] { slotMenuTriggered(pSalMenuItem); });
}
}
}
......@@ -234,14 +234,18 @@ const Qt5Frame* Qt5Menu::GetFrame() const
return pMenu ? pMenu->mpFrame : nullptr;
}
void Qt5Menu::DispatchCommand(Qt5MenuItem* pQItem)
void Qt5Menu::slotMenuTriggered(Qt5MenuItem* pQItem)
{
if (pQItem)
{
Qt5Menu* pSalMenu = pQItem->mpParentMenu;
Qt5Menu* pTopLevel = pSalMenu->GetTopLevel();
// it is possible that dispatcher of a menu entry was cleared since
// initial activation (happens e.g. when extension comes w/ its own menus
// and dispatchers) so re-activate the entry before dispatching the command
pTopLevel->GetMenu()->HandleMenuActivateEvent(pSalMenu->GetMenu());
pTopLevel->GetMenu()->HandleMenuCommandEvent(pSalMenu->GetMenu(), pQItem->mnId);
SAL_WARN("vcl.qt5", "menu triggered " << pQItem->mnId);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment