diff --git a/containments/desktop/package/contents/ui/FolderView.qml b/containments/desktop/package/contents/ui/FolderView.qml --- a/containments/desktop/package/contents/ui/FolderView.qml +++ b/containments/desktop/package/contents/ui/FolderView.qml @@ -775,12 +775,12 @@ } Keys.onMenuPressed: { - // FIXME TODO: Correct popup position. - return; - - if (currentIndex != -1 && dir.hasSelection()) { + if (currentIndex != -1 && dir.hasSelection() && currentItem) { dir.setSelected(positioner.map(currentIndex)); - dir.openContextMenu(); + dir.openContextMenu(currentItem.frame); + } else { + // Otherwise let the containment handle it. + event.accepted = false; } } diff --git a/containments/desktop/plugins/folder/foldermodel.h b/containments/desktop/plugins/folder/foldermodel.h --- a/containments/desktop/plugins/folder/foldermodel.h +++ b/containments/desktop/plugins/folder/foldermodel.h @@ -198,7 +198,7 @@ Q_INVOKABLE QAction* action(const QString& name) const; QObject* newMenu() const; Q_INVOKABLE void updateActions(); - Q_INVOKABLE void openContextMenu(); + Q_INVOKABLE void openContextMenu(QQuickItem *visualParent = nullptr); Q_INVOKABLE void linkHere(const QUrl &sourceUrl); diff --git a/containments/desktop/plugins/folder/foldermodel.cpp b/containments/desktop/plugins/folder/foldermodel.cpp --- a/containments/desktop/plugins/folder/foldermodel.cpp +++ b/containments/desktop/plugins/folder/foldermodel.cpp @@ -1382,7 +1382,7 @@ } } -void FolderModel::openContextMenu() +void FolderModel::openContextMenu(QQuickItem *visualParent) { QModelIndexList indexes = m_selectionModel->selectedIndexes(); @@ -1511,7 +1511,11 @@ } - menu->popup(QCursor::pos()); + if (visualParent) { + menu->popup(visualParent->mapToGlobal(QPointF(0, visualParent->height())).toPoint()); + } else { + menu->popup(QCursor::pos()); + } connect(menu, &QMenu::aboutToHide, [menu]() { menu->deleteLater(); }); }