QmlDesigner: Open 3D view toolbar popups to correct position

The button that is shown under extension menu is not actually the
same button widget that is tied to the action, so we need to resolve
the menu position based on toolbar dimensions in that case.

Fixes: QDS-10635
Change-Id: I0c2319041638f9f1cb19f3e57fccbb993e31c743
Reviewed-by: Qt CI Patch Build Bot <ci_patchbuild_bot@qt.io>
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
This commit is contained in:
Miikka Heikkinen
2023-09-18 12:40:47 +03:00
parent 44699727ad
commit 1a88cf1446

View File

@@ -589,9 +589,17 @@ QPoint Edit3DView::resolveToolbarPopupPos(Edit3DAction *action) const
const QList<QObject *> &objects = action->action()->associatedObjects(); const QList<QObject *> &objects = action->action()->associatedObjects();
for (QObject *obj : objects) { for (QObject *obj : objects) {
if (auto button = qobject_cast<QToolButton *>(obj)) { if (auto button = qobject_cast<QToolButton *>(obj)) {
if (auto toolBar = qobject_cast<QWidget *>(button->parent())) {
// If the button has not yet been shown (i.e. it starts under extension menu),
// the button x value will be zero.
if (button->x() >= toolBar->width() - button->width() || button->x() == 0) {
pos = toolBar->mapToGlobal(QPoint(toolBar->width() - button->width(), 4));
} else {
// Add small negative modifier to Y coordinate, so highlighted toolbar buttons don't // Add small negative modifier to Y coordinate, so highlighted toolbar buttons don't
// peek from under the popup // peek from under the popup
pos = button->mapToGlobal(QPoint(0, -2)); pos = button->mapToGlobal(QPoint(0, -2));
}
}
break; break;
} }
} }