mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-23 10:52:16 -07:00
refactor resizing code
This commit is contained in:
parent
e4cfe08113
commit
67c9c4ea51
1 changed files with 11 additions and 8 deletions
|
|
@ -249,16 +249,19 @@ void ZoneViewWidget::resizeToZoneContents()
|
||||||
{
|
{
|
||||||
QRectF zoneRect = zone->getOptimumRect();
|
QRectF zoneRect = zone->getOptimumRect();
|
||||||
qreal totalZoneHeight = zoneRect.height();
|
qreal totalZoneHeight = zoneRect.height();
|
||||||
if (zoneRect.height() > 500)
|
|
||||||
zoneRect.setHeight(500);
|
qreal width = qMax(QGraphicsWidget::layout()->effectiveSizeHint(Qt::MinimumSize, QSizeF()).width(),
|
||||||
QSizeF newSize(qMax(QGraphicsWidget::layout()->effectiveSizeHint(Qt::MinimumSize, QSizeF()).width(),
|
zoneRect.width() + scrollBar->width() + 10);
|
||||||
zoneRect.width() + scrollBar->width() + 10),
|
|
||||||
zoneRect.height() + extraHeight + 10);
|
QSizeF maxSize(width, zoneRect.height() + extraHeight + 10);
|
||||||
setMaximumSize(newSize);
|
setMaximumSize(maxSize);
|
||||||
resize(newSize);
|
|
||||||
|
qreal initialZoneHeight = qMin(zoneRect.height(), 500.0);
|
||||||
|
QSizeF initialSize(width, initialZoneHeight + extraHeight + 10);
|
||||||
|
resize(initialSize);
|
||||||
|
|
||||||
zone->setGeometry(QRectF(0, -scrollBar->value(), zoneContainer->size().width(), totalZoneHeight));
|
zone->setGeometry(QRectF(0, -scrollBar->value(), zoneContainer->size().width(), totalZoneHeight));
|
||||||
scrollBar->setMaximum(totalZoneHeight - zoneRect.height());
|
scrollBar->setMaximum(totalZoneHeight - initialZoneHeight);
|
||||||
|
|
||||||
if (layout())
|
if (layout())
|
||||||
layout()->invalidate();
|
layout()->invalidate();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue