Adapt hack for context menu positioning issues to work in windowed mode

This commit is contained in:
Martchus 2022-11-29 23:41:18 +01:00
parent 6c89b2dc0a
commit e3f230546d
1 changed files with 2 additions and 1 deletions

View File

@ -22,7 +22,8 @@ void showViewMenu(const QPoint &position, const QTreeView &view, QMenu &menu)
static const auto needsHack = QLibraryInfo::version() < QVersionNumber(6, 2, 3);
#endif
const QMenu *topLevelWidget;
if (needsHack && (topLevelWidget = qobject_cast<const QMenu *>(view.topLevelWidget()))) {
if (needsHack && (topLevelWidget = qobject_cast<const QMenu *>(view.topLevelWidget()))
&& (topLevelWidget->windowFlags() & Qt::Popup) == Qt::Popup) {
menu.exec(topLevelWidget->mapToGlobal(position));
} else {
menu.exec(view.viewport()->mapToGlobal(position));