forked from qt-creator/qt-creator
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:
@@ -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)) {
|
||||||
// Add small negative modifier to Y coordinate, so highlighted toolbar buttons don't
|
if (auto toolBar = qobject_cast<QWidget *>(button->parent())) {
|
||||||
// peek from under the popup
|
// If the button has not yet been shown (i.e. it starts under extension menu),
|
||||||
pos = button->mapToGlobal(QPoint(0, -2));
|
// 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;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user