take into account panel size while positioning
make the dialog look always inside the panel, to not have borders looking brutally cutted away
This commit is contained in:
parent
ef2e4f46d4
commit
99e350bb34
@ -336,14 +336,27 @@ QPoint DialogProxy::popupPosition(QQuickItem *item, const QSize &size, Qt::Align
|
|||||||
//we do not rely on item->window()->screen() because
|
//we do not rely on item->window()->screen() because
|
||||||
//QWindow::screen() is always only the screen where the window gets first created
|
//QWindow::screen() is always only the screen where the window gets first created
|
||||||
//not actually the current window. See QWindow::screen() documentation
|
//not actually the current window. See QWindow::screen() documentation
|
||||||
const QRect avail = screenForItem(item)->availableGeometry();
|
QRect avail = screenForItem(item)->availableGeometry();
|
||||||
|
|
||||||
|
|
||||||
|
//make the panel look it's inside the panel, in order to not make it look cutted
|
||||||
|
switch (m_location) {
|
||||||
|
case Plasma::Types::LeftEdge:
|
||||||
|
case Plasma::Types::RightEdge:
|
||||||
|
avail.setTop(qMax(avail.top(), parentGeometryBounds.top()));
|
||||||
|
avail.setBottom(qMin(avail.bottom(), parentGeometryBounds.bottom()));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
avail.setLeft(qMax(avail.left(), parentGeometryBounds.left()));
|
||||||
|
avail.setRight(qMin(avail.right(), parentGeometryBounds.right()));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (dialogPos.x() < avail.left()) {
|
if (dialogPos.x() < avail.left()) {
|
||||||
// popup hits lhs
|
// popup hits lhs
|
||||||
if (m_location == Plasma::Types::TopEdge || m_location == Plasma::Types::BottomEdge) {
|
if (m_location == Plasma::Types::TopEdge || m_location == Plasma::Types::BottomEdge) {
|
||||||
// move it
|
// move it
|
||||||
dialogPos.setX(0);
|
dialogPos.setX(avail.left());
|
||||||
} else {
|
} else {
|
||||||
// swap edge
|
// swap edge
|
||||||
dialogPos.setX(rightPoint.x());
|
dialogPos.setX(rightPoint.x());
|
||||||
@ -352,7 +365,7 @@ QPoint DialogProxy::popupPosition(QQuickItem *item, const QSize &size, Qt::Align
|
|||||||
if (dialogPos.x() + size.width() > avail.right()) {
|
if (dialogPos.x() + size.width() > avail.right()) {
|
||||||
// popup hits rhs
|
// popup hits rhs
|
||||||
if (m_location == Plasma::Types::TopEdge || m_location == Plasma::Types::BottomEdge) {
|
if (m_location == Plasma::Types::TopEdge || m_location == Plasma::Types::BottomEdge) {
|
||||||
dialogPos.setX(avail.width() - size.width());
|
dialogPos.setX(avail.right() - size.width());
|
||||||
} else {
|
} else {
|
||||||
dialogPos.setX(leftPoint.x());
|
dialogPos.setX(leftPoint.x());
|
||||||
}
|
}
|
||||||
@ -360,7 +373,7 @@ QPoint DialogProxy::popupPosition(QQuickItem *item, const QSize &size, Qt::Align
|
|||||||
if (dialogPos.y() < avail.top()) {
|
if (dialogPos.y() < avail.top()) {
|
||||||
// hitting top
|
// hitting top
|
||||||
if (m_location == Plasma::Types::LeftEdge || m_location == Plasma::Types::RightEdge) {
|
if (m_location == Plasma::Types::LeftEdge || m_location == Plasma::Types::RightEdge) {
|
||||||
dialogPos.setY(0);
|
dialogPos.setY(avail.top());
|
||||||
} else {
|
} else {
|
||||||
dialogPos.setY(bottomPoint.y());
|
dialogPos.setY(bottomPoint.y());
|
||||||
}
|
}
|
||||||
@ -370,7 +383,7 @@ QPoint DialogProxy::popupPosition(QQuickItem *item, const QSize &size, Qt::Align
|
|||||||
if (m_location == Plasma::Types::TopEdge || m_location == Plasma::Types::BottomEdge) {
|
if (m_location == Plasma::Types::TopEdge || m_location == Plasma::Types::BottomEdge) {
|
||||||
dialogPos.setY(topPoint.y());
|
dialogPos.setY(topPoint.y());
|
||||||
} else {
|
} else {
|
||||||
dialogPos.setY(avail.height() - item->boundingRect().height());
|
dialogPos.setY(avail.bottom() - item->boundingRect().height());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user