aboutsummaryrefslogtreecommitdiffstats
path: root/src/quicktemplates/qquickpopuppositioner.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/quicktemplates/qquickpopuppositioner.cpp')
-rw-r--r--src/quicktemplates/qquickpopuppositioner.cpp23
1 files changed, 17 insertions, 6 deletions
diff --git a/src/quicktemplates/qquickpopuppositioner.cpp b/src/quicktemplates/qquickpopuppositioner.cpp
index aecbc7373c..f8113a5526 100644
--- a/src/quicktemplates/qquickpopuppositioner.cpp
+++ b/src/quicktemplates/qquickpopuppositioner.cpp
@@ -98,6 +98,7 @@ void QQuickPopupPositioner::reposition()
!centerInParent ? p->allowVerticalMove ? p->y : popupItem->y() : 0,
!p->hasWidth && iw > 0 ? iw : w,
!p->hasHeight && ih > 0 ? ih : h);
+ bool relaxEdgeConstraint = p->relaxEdgeConstraint;
if (m_parentItem) {
// m_parentItem is the parent that the popup should open in,
// and popupItem()->parentItem() is the overlay, so the mapToItem() calls below
@@ -110,6 +111,8 @@ void QQuickPopupPositioner::reposition()
if (centerInOverlay) {
rect.moveCenter(QPointF(qRound(centerInOverlay->width() / 2.0), qRound(centerInOverlay->height() / 2.0)));
+ // Popup cannot be moved outside window bounds when its centered with overlay
+ relaxEdgeConstraint = false;
} else {
const QPointF parentItemCenter = QPointF(qRound(m_parentItem->width() / 2), qRound(m_parentItem->height() / 2));
rect.moveCenter(m_parentItem->mapToItem(popupItem->parentItem(), parentItemCenter));
@@ -124,8 +127,6 @@ void QQuickPopupPositioner::reposition()
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())) {
@@ -170,12 +171,17 @@ void QQuickPopupPositioner::reposition()
}
// as a last resort, adjust the width to fit the window
+ // Negative margins don't require resize as popup not pushed within
+ // the boundary. But otherwise, retain existing behavior of resizing
+ // for items, such as menus, which enables flip.
if (p->allowHorizontalResize) {
- if (rect.left() < bounds.left()) {
+ if ((margins.left() >= 0 || !relaxEdgeConstraint)
+ && (rect.left() < bounds.left())) {
rect.setLeft(bounds.left());
widthAdjusted = true;
}
- if (rect.right() > bounds.right()) {
+ if ((margins.right() >= 0 || !relaxEdgeConstraint)
+ && (rect.right() > bounds.right())) {
rect.setRight(bounds.right());
widthAdjusted = true;
}
@@ -198,12 +204,17 @@ void QQuickPopupPositioner::reposition()
}
// as a last resort, adjust the height to fit the window
+ // Negative margins don't require resize as popup not pushed within
+ // the boundary. But otherwise, retain existing behavior of resizing
+ // for items, such as menus, which enables flip.
if (p->allowVerticalResize) {
- if (rect.top() < bounds.top()) {
+ if ((margins.top() >= 0 || !relaxEdgeConstraint)
+ && (rect.top() < bounds.top())) {
rect.setTop(bounds.top());
heightAdjusted = true;
}
- if (rect.bottom() > bounds.bottom()) {
+ if ((margins.bottom() >= 0 || !relaxEdgeConstraint)
+ && (rect.bottom() > bounds.bottom())) {
rect.setBottom(bounds.bottom());
heightAdjusted = true;
}