From 44ea4d31e72c234a190cb723fb461e45c5abc9c2 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Fri, 28 Jul 2017 14:03:22 +0200 Subject: Fix QQuickPopupPositioner::reposition() f1e139b broke popup flipping. Many of the sub-menu positioning tests start failing when merging 5.9->dev. The intention was to avoid calling mapToScene() twice and re-use the already mapped rectangle, but the flipping code needs the requested Popup coordinates, whereas the mapped rectangle is conditionally using PopupItem coordinates, so re-using the mapped rectangle is not possible after all. Change-Id: Ic00e985d937fce7aadfd24f817a06fd86d9e307d Reviewed-by: Mitch Curtis Reviewed-by: Frederik Gladhorn --- src/quicktemplates2/qquickpopuppositioner.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/quicktemplates2/qquickpopuppositioner.cpp b/src/quicktemplates2/qquickpopuppositioner.cpp index 95d07690..2b67c85e 100644 --- a/src/quicktemplates2/qquickpopuppositioner.cpp +++ b/src/quicktemplates2/qquickpopuppositioner.cpp @@ -129,14 +129,14 @@ void QQuickPopupPositioner::reposition() // if the popup doesn't fit horizontally inside the window, try flipping it around (left <-> right) if (p->allowHorizontalFlip && (rect.left() < bounds.left() || rect.right() > bounds.right())) { - const QRectF flipped(m_parentItem->width() - rect.x() - rect.width(), rect.y(), rect.width(), rect.height()); + const QRectF flipped(m_parentItem->mapToScene(QPointF(m_parentItem->width() - p->x - rect.width(), p->y)), rect.size()); if (flipped.intersected(bounds).width() > rect.intersected(bounds).width()) rect.moveLeft(flipped.left()); } // if the popup doesn't fit vertically inside the window, try flipping it around (above <-> below) if (p->allowVerticalFlip && (rect.top() < bounds.top() || rect.bottom() > bounds.bottom())) { - const QRectF flipped(rect.x(), m_parentItem->height() - rect.y() - rect.height(), rect.width(), rect.height()); + const QRectF flipped(m_parentItem->mapToScene(QPointF(p->x, m_parentItem->height() - p->y - rect.height())), rect.size()); if (flipped.intersected(bounds).height() > rect.intersected(bounds).height()) rect.moveTop(flipped.top()); } -- cgit v1.2.3