diff options
author | J-P Nurmi <jpnurmi@qt.io> | 2017-07-26 13:22:33 +0200 |
---|---|---|
committer | J-P Nurmi <jpnurmi@qt.io> | 2017-07-27 12:03:59 +0000 |
commit | f1e139b9ac02313f541ed6749f05e265f4c8bf13 (patch) | |
tree | a29df97ee1881a6c8e44e502c57c8a1972d88d81 /src/quicktemplates2/qquickpopuppositioner.cpp | |
parent | b94889f49170e3d8df5b348d3f179445d892f232 (diff) |
Popups: take Window::contentOrientation into account
Task-number: QTBUG-62158
Change-Id: I0bcf5b02da6a3500e4324462d5f1249a6178c9fd
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src/quicktemplates2/qquickpopuppositioner.cpp')
-rw-r--r-- | src/quicktemplates2/qquickpopuppositioner.cpp | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/quicktemplates2/qquickpopuppositioner.cpp b/src/quicktemplates2/qquickpopuppositioner.cpp index a8e217f1..95d07690 100644 --- a/src/quicktemplates2/qquickpopuppositioner.cpp +++ b/src/quicktemplates2/qquickpopuppositioner.cpp @@ -116,25 +116,27 @@ void QQuickPopupPositioner::reposition() !p->hasWidth && iw > 0 ? iw : w, !p->hasHeight && ih > 0 ? ih : h); if (m_parentItem) { - rect = m_parentItem->mapRectToScene(rect); + rect.moveTopLeft(m_parentItem->mapToItem(popupItem->parentItem(), rect.topLeft())); if (p->window) { const QMarginsF margins = p->getMargins(); - const QRectF bounds(qMax<qreal>(0.0, margins.left()), - qMax<qreal>(0.0, margins.top()), - p->window->width() - qMax<qreal>(0.0, margins.left()) - qMax<qreal>(0.0, margins.right()), - p->window->height() - qMax<qreal>(0.0, margins.top()) - qMax<qreal>(0.0, margins.bottom())); + QRectF bounds(qMax<qreal>(0.0, margins.left()), + qMax<qreal>(0.0, margins.top()), + p->window->width() - qMax<qreal>(0.0, margins.left()) - qMax<qreal>(0.0, margins.right()), + p->window->height() - qMax<qreal>(0.0, margins.top()) - qMax<qreal>(0.0, margins.bottom())); + if (p->window->contentOrientation() == Qt::LandscapeOrientation || p->window->contentOrientation() == Qt::InvertedLandscapeOrientation) + bounds = bounds.transposed(); // 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->mapRectToScene(QRectF(m_parentItem->width() - p->x - rect.width(), p->y, rect.width(), rect.height())); + const QRectF flipped(m_parentItem->width() - rect.x() - rect.width(), rect.y(), rect.width(), rect.height()); 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 = m_parentItem->mapRectToScene(QRectF(p->x, m_parentItem->height() - p->y - rect.height(), rect.width(), rect.height())); + const QRectF flipped(rect.x(), m_parentItem->height() - rect.y() - rect.height(), rect.width(), rect.height()); if (flipped.intersected(bounds).height() > rect.intersected(bounds).height()) rect.moveTop(flipped.top()); } |