Fix resize limits.
If the widget would be resized more than it's allowed, don't leave it as is, but use the limit size. Noticable if you move the mouse quickly. svn path=/trunk/KDE/kdelibs/; revision=884179
This commit is contained in:
parent
07c8015ade
commit
7529d778a8
31
dialog.cpp
31
dialog.cpp
@ -239,43 +239,32 @@ void Dialog::mouseMoveEvent(QMouseEvent *event)
|
|||||||
|
|
||||||
switch(d->resizeStartCorner) {
|
switch(d->resizeStartCorner) {
|
||||||
case Dialog::NorthEast:
|
case Dialog::NorthEast:
|
||||||
newWidth = event->x();
|
newWidth = qMin(maximumWidth(), qMax(minimumWidth(), event->x()));
|
||||||
newHeight = height() - event->y();
|
newHeight = qMin(maximumHeight(), qMax(minimumHeight(), height() - event->y()));
|
||||||
position = QPoint(x(), y() + height() - newHeight);
|
position = QPoint(x(), y() + height() - newHeight);
|
||||||
break;
|
break;
|
||||||
case Dialog::NorthWest:
|
case Dialog::NorthWest:
|
||||||
newWidth = width() - event->x();
|
newWidth = qMin(maximumWidth(), qMax(minimumWidth(), width() - event->x()));
|
||||||
newHeight = height() - event->y();
|
newHeight = qMin(maximumHeight(), qMax(minimumHeight(), height() - event->y()));
|
||||||
position = QPoint(x() + width() - newWidth, y() + height() - newHeight);
|
position = QPoint(x() + width() - newWidth, y() + height() - newHeight);
|
||||||
break;
|
break;
|
||||||
case Dialog::SouthWest:
|
case Dialog::SouthWest:
|
||||||
newWidth = width() - event->x();
|
newWidth = qMin(maximumWidth(), qMax(minimumWidth(), width() - event->x()));
|
||||||
newHeight = event->y();
|
newHeight = qMin(maximumHeight(), qMax(minimumHeight(), event->y()));
|
||||||
position = QPoint(x() + width() - newWidth, y());
|
position = QPoint(x() + width() - newWidth, y());
|
||||||
break;
|
break;
|
||||||
case Dialog::SouthEast:
|
case Dialog::SouthEast:
|
||||||
newWidth = event->x();
|
newWidth = qMin(maximumWidth(), qMax(minimumWidth(), event->x()));
|
||||||
newHeight = event->y();
|
newHeight = qMin(maximumHeight(), qMax(minimumHeight(), event->y()));
|
||||||
position = QPoint(x(), y());
|
position = QPoint(x(), y());
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
newWidth = width();
|
newWidth = qMin(maximumWidth(), qMax(minimumWidth(), width()));
|
||||||
newHeight = height();
|
newHeight = qMin(maximumHeight(), qMax(minimumHeight(), height()));
|
||||||
position = QPoint(x(), y());
|
position = QPoint(x(), y());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// let's check for limitations
|
|
||||||
if (newWidth < minimumWidth() || newWidth > maximumWidth()) {
|
|
||||||
newWidth = width();
|
|
||||||
position.setX(x());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (newHeight < minimumHeight() || newHeight > maximumHeight()) {
|
|
||||||
newHeight = height();
|
|
||||||
position.setY(y());
|
|
||||||
}
|
|
||||||
|
|
||||||
setGeometry(QRect(position, QSize(newWidth, newHeight)));
|
setGeometry(QRect(position, QSize(newWidth, newHeight)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user