diff options
author | J-P Nurmi <jpnurmi@theqtcompany.com> | 2016-03-21 15:17:55 +0100 |
---|---|---|
committer | J-P Nurmi <jpnurmi@theqtcompany.com> | 2016-03-21 16:44:37 +0000 |
commit | 47e50cb3d0088e1080c98996601664119d3d588e (patch) | |
tree | db94cf91f79106417e4b2cc4c6d4e6d0988af22c /src/templates | |
parent | fec1a78618bae112ff8d1c0e6f078ea890cf283e (diff) |
Popup: fix margins
Change-Id: I09f974a00a5a2a8f14645ff5d9bfbd6bad03d324
Task-number: QTBUG-51990
Reviewed-by: Mitch Curtis <mitch.curtis@theqtcompany.com>
Diffstat (limited to 'src/templates')
-rw-r--r-- | src/templates/qquickpopup.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/templates/qquickpopup.cpp b/src/templates/qquickpopup.cpp index 8d40dd0c..f8df8df0 100644 --- a/src/templates/qquickpopup.cpp +++ b/src/templates/qquickpopup.cpp @@ -488,7 +488,19 @@ void QQuickPopupPositioner::repositionPopup() QQuickWindow *window = m_parentItem->window(); if (window) { - const QRectF bounds = QRectF(0, 0, window->width(), window->height()).marginsRemoved(m_popup->getMargins()); + const QMarginsF margins = m_popup->getMargins(); + const QRectF bounds = QRectF(0, 0, window->width(), window->height()).marginsRemoved(margins); + + // push inside the margins + if (margins.top() > 0 && rect.top() < bounds.top()) + rect.moveTop(margins.top()); + if (margins.bottom() > 0 && rect.bottom() > bounds.bottom()) + rect.moveBottom(bounds.bottom()); + if (margins.left() > 0 && rect.left() < bounds.left()) + rect.moveLeft(margins.left()); + if (margins.right() > 0 && rect.right() > bounds.right()) + rect.moveRight(bounds.right()); + if (rect.top() < bounds.top() || rect.bottom() > bounds.bottom()) { // if the popup doesn't fit inside the window, try flipping it around (below <-> above) const QRectF flipped = m_parentItem->mapRectToScene(QRectF(m_x, m_parentItem->height() - m_y - rect.height(), rect.width(), rect.height())); |