ContainmentInterface: Set transient parent of submenues

The actions added by plugins or applets can contain actions that are
menues. This causes a problem for the panel because it doesn't take
focus when right clicked. Since the menues had no transientParent, they
were created as new toplevels.
BUG:417378
This commit is contained in:
David Redondo 2021-04-19 12:07:03 +02:00
parent 2d5a492df6
commit 27299d1405

View File

@ -992,6 +992,17 @@ void ContainmentInterface::mousePressEvent(QMouseEvent *event)
KAcceleratorManager::manage(desktopMenu);
for (auto action : desktopMenu->actions()) {
if (action->menu()) {
connect(action->menu(), &QMenu::aboutToShow, desktopMenu, [action, desktopMenu] {
if (action->menu()->windowHandle()) {
// Need to add the transient parent otherwise Qt will create a new toplevel
action->menu()->windowHandle()->setTransientParent(desktopMenu->windowHandle());
}
});
}
}
desktopMenu->popup(pos);
event->setAccepted(true);
}