Commit 4c977747 authored by Andras Mantia's avatar Andras Mantia

Create new items at the position where the context menu was invoked

Reviewers: #plasma, broulik, hein, mwolff

Reviewed By: #plasma, hein

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D9311
parent b5985e45
......@@ -267,6 +267,9 @@ void FolderModel::newFileMenuItemCreated(const QUrl &url)
{
if (m_screenMapper) {
m_screenMapper->addMapping(url.toString(), m_screen, ScreenMapper::DelayedSignal);
m_dropTargetPositions.insert(url.fileName(), m_menuPosition);
m_menuPosition = {};
m_dropTargetPositionsCleanup->start();
}
}
......@@ -1595,6 +1598,8 @@ void FolderModel::updateActions()
if (m_newMenu) {
m_newMenu->checkUpToDate();
m_newMenu->setPopupFiles(m_dirModel->dirLister()->url());
// we need to set here as well, when the menu is shown via AppletInterface::eventFilter
m_menuPosition = QCursor::pos();
}
const bool isTrash = (resolvedUrl().scheme() == QLatin1String("trash"));
......@@ -1768,10 +1773,11 @@ void FolderModel::openContextMenu(QQuickItem *visualParent)
}
if (visualParent) {
menu->popup(visualParent->mapToGlobal(QPointF(0, visualParent->height())).toPoint());
m_menuPosition = visualParent->mapToGlobal(QPointF(0, visualParent->height())).toPoint();
} else {
menu->popup(QCursor::pos());
m_menuPosition = QCursor::pos();
}
menu->popup(m_menuPosition);
connect(menu, &QMenu::aboutToHide, [menu]() { menu->deleteLater(); });
}
......
......@@ -352,6 +352,7 @@ class FOLDERPLUGIN_TESTS_EXPORT FolderModel : public QSortFilterProxyModel, publ
ScreenMapper *m_screenMapper = nullptr;
QObject *m_appletInterface = nullptr;
bool m_complete;
QPoint m_menuPosition;
};
#endif
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