diff options
author | J-P Nurmi <jpnurmi@qt.io> | 2017-07-28 14:03:22 +0200 |
---|---|---|
committer | J-P Nurmi <jpnurmi@qt.io> | 2017-07-28 12:24:17 +0000 |
commit | 44ea4d31e72c234a190cb723fb461e45c5abc9c2 (patch) | |
tree | 53df994aad69b3a82b3f6a7afe3b1b289044640b /src/quicktemplates2/qquickpopuppositioner.cpp | |
parent | f1e139b9ac02313f541ed6749f05e265f4c8bf13 (diff) |
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 <mitch.curtis@qt.io>
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
Diffstat (limited to 'src/quicktemplates2/qquickpopuppositioner.cpp')
-rw-r--r-- | src/quicktemplates2/qquickpopuppositioner.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
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()); } |