From 1a88cf1446b5020f8840c620dcdda52d6e072d74 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Mon, 18 Sep 2023 12:40:47 +0300 Subject: [PATCH] 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 Reviewed-by: Mahmoud Badri --- .../qmldesigner/components/edit3d/edit3dview.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/plugins/qmldesigner/components/edit3d/edit3dview.cpp b/src/plugins/qmldesigner/components/edit3d/edit3dview.cpp index f05f813929a..a33c9c0019e 100644 --- a/src/plugins/qmldesigner/components/edit3d/edit3dview.cpp +++ b/src/plugins/qmldesigner/components/edit3d/edit3dview.cpp @@ -589,9 +589,17 @@ QPoint Edit3DView::resolveToolbarPopupPos(Edit3DAction *action) const const QList &objects = action->action()->associatedObjects(); for (QObject *obj : objects) { if (auto button = qobject_cast(obj)) { - // Add small negative modifier to Y coordinate, so highlighted toolbar buttons don't - // peek from under the popup - pos = button->mapToGlobal(QPoint(0, -2)); + if (auto toolBar = qobject_cast(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 + // peek from under the popup + pos = button->mapToGlobal(QPoint(0, -2)); + } + } break; } }