set transientparent for menus

Summary:
set transient parent for popup menus created by appletinterface/
containmentinterface, it makes them appear at the proper coordinates

Test Plan: containment menus appear where the mouse was pressed

Reviewers: #plasma, davidedmundson

Reviewed By: #plasma, davidedmundson

Subscribers: davidedmundson, plasma-devel, #frameworks

Tags: #plasma, #frameworks

Differential Revision: https://phabricator.kde.org/D5918
This commit is contained in:
Marco Martin 2017-05-22 10:49:57 +02:00
parent f28ba7cba6
commit 5ba1bed582
2 changed files with 12 additions and 0 deletions

View File

@ -825,6 +825,9 @@ bool AppletInterface::eventFilter(QObject *watched, QEvent *event)
} }
QMenu *desktopMenu = new QMenu; QMenu *desktopMenu = new QMenu;
if (desktopMenu->winId()) {
desktopMenu->windowHandle()->setTransientParent(window());
}
emit applet()->contextualActionsAboutToShow(); emit applet()->contextualActionsAboutToShow();
ci->addAppletActions(desktopMenu, applet(), event); ci->addAppletActions(desktopMenu, applet(), event);

View File

@ -481,6 +481,9 @@ void ContainmentInterface::processMimeData(QMimeData *mimeData, int x, int y, KI
m_dropJobs[job] = dropJob; m_dropJobs[job] = dropJob;
} else { } else {
QMenu *choices = new QMenu(i18n("Content dropped")); QMenu *choices = new QMenu(i18n("Content dropped"));
if (choices->winId()) {
choices->windowHandle()->setTransientParent(window());
}
choices->addAction(QIcon::fromTheme(QStringLiteral("process-working")), i18n("Fetching file type...")); choices->addAction(QIcon::fromTheme(QStringLiteral("process-working")), i18n("Fetching file type..."));
choices->popup(window() ? window()->mapToGlobal(QPoint(x, y)) : QPoint(x, y)); choices->popup(window() ? window()->mapToGlobal(QPoint(x, y)) : QPoint(x, y));
@ -521,6 +524,9 @@ void ContainmentInterface::processMimeData(QMimeData *mimeData, int x, int y, KI
QMenu *choices = nullptr; QMenu *choices = nullptr;
if (!dropJob) { if (!dropJob) {
choices = new QMenu(); choices = new QMenu();
if (choices->winId()) {
choices->windowHandle()->setTransientParent(window());
}
} }
QList<QAction *> extraActions; QList<QAction *> extraActions;
QHash<QAction *, QString> actionsToPlugins; QHash<QAction *, QString> actionsToPlugins;
@ -999,6 +1005,9 @@ void ContainmentInterface::mousePressEvent(QMouseEvent *event)
//qDebug() << "Invoking menu for applet" << applet; //qDebug() << "Invoking menu for applet" << applet;
QMenu *desktopMenu = new QMenu; QMenu *desktopMenu = new QMenu;
if (desktopMenu->winId()) {
desktopMenu->windowHandle()->setTransientParent(window());
}
desktopMenu->setAttribute(Qt::WA_DeleteOnClose); desktopMenu->setAttribute(Qt::WA_DeleteOnClose);
m_contextMenu = desktopMenu; m_contextMenu = desktopMenu;