Commit 603c0b5a authored by David Redondo's avatar David Redondo 🏎
Browse files

Set a transientParent for the FolderView ContextMenu

We already had the possibility to specify a visualParent but never did.
The positioning below the parent is not optimal because the Delegates
include the spacing between rows at their bottom which was likely never
discovered because the visualParent was never set. So just set it always
to the cursor position.
CCBUG:417378
parent 0362df57
......@@ -306,7 +306,7 @@ FocusScope {
if (mouse.buttons & Qt.RightButton) {
clearPressState();
dir.openContextMenu(null, mouse.modifiers);
dir.openContextMenu(main, mouse.modifiers);
mouse.accepted = true;
}
} else {
......@@ -344,7 +344,7 @@ FocusScope {
clearPressState();
dir.openContextMenu(null, mouse.modifiers);
dir.openContextMenu(hoveredItem, mouse.modifiers);
mouse.accepted = true;
}
}
......@@ -365,7 +365,7 @@ FocusScope {
}
clearPressState();
if (hoveredItem) {
dir.openContextMenu(null, mouse.modifiers);
dir.openContextMenu(hoveredItem, mouse.modifiers);
}
}
}
......
......@@ -1866,18 +1866,16 @@ void FolderModel::openContextMenu(QQuickItem *visualParent, Qt::KeyboardModifier
}
}
if (visualParent) {
m_menuPosition = visualParent->mapToGlobal(QPointF(0, visualParent->height())).toPoint();
} else {
m_menuPosition = QCursor::pos();
menu->setAttribute(Qt::WA_TranslucentBackground);
menu->winId(); // force surface creation before ensurePolish call in menu::Popup which happens before show
if (visualParent && menu->windowHandle()) {
menu->windowHandle()->setTransientParent(visualParent->window());
}
// Used to monitor Shift modifier usage while the menu is open, to
// swap the Trash and Delete actions.
menu->installEventFilter(this);
menu->setAttribute(Qt::WA_TranslucentBackground);
menu->winId(); // force surface creation before ensurePolish call in menu::Popup which happens before show
menu->popup(m_menuPosition);
connect(menu, &QMenu::aboutToHide, [menu]() {
menu->deleteLater();
......
Supports Markdown
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