move popupleft when there is not enough room (it looks like the windowmanager doesn't always do it automatically)

svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=764755
This commit is contained in:
Marco Martin 2008-01-22 14:06:37 +00:00
parent ec2f627333
commit e8b62a6ceb

View File

@ -556,20 +556,30 @@ QPoint Widget::popupPosition(const QSize s) const
switch (loc) { switch (loc) {
case BottomEdge: case BottomEdge:
return QPoint(pos.x(), pos.y() - s.height()); pos = QPoint(pos.x(), pos.y() - s.height());
break;
case TopEdge: case TopEdge:
return QPoint(pos.x(), pos.y() + (int)size().height()); pos = QPoint(pos.x(), pos.y() + (int)size().height());
break;
case LeftEdge: case LeftEdge:
return QPoint(pos.x() + (int)size().width(), pos.y()); pos = QPoint(pos.x() + (int)size().width(), pos.y());
break;
case RightEdge: case RightEdge:
return QPoint(pos.x() - s.width(), pos.y()); pos = QPoint(pos.x() - s.width(), pos.y());
break;
default: default:
if (pos.y() > 0) { if (pos.y() > 0) {
return QPoint(pos.x(), pos.y() - s.height()); pos = QPoint(pos.x(), pos.y() - s.height());
} else { } else {
return QPoint(pos.x(), pos.y() + (int)size().height()); pos = QPoint(pos.x(), pos.y() + (int)size().height());
} }
} }
if (pos.rx() + s.width() > view()->width()) {
pos.rx() -= ((pos.rx() + s.width()) - view()->width());
}
return pos;
} }
void Widget::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) void Widget::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)