get thing to work

This commit is contained in:
RickyRister 2024-12-02 21:19:55 -08:00
parent c9c56d5c73
commit 3affc0b56a
2 changed files with 14 additions and 1 deletions

View file

@ -245,6 +245,19 @@ void ZoneViewWidget::moveEvent(QGraphicsSceneMoveEvent * /* event */)
setPos(scenePos); setPos(scenePos);
} }
void ZoneViewWidget::resizeEvent(QGraphicsSceneResizeEvent *event)
{
if (!zone)
return;
// We need to manually resize the scroll bar whenever the window gets resized
qreal totalZoneHeight = zone->getOptimumRect().height();
qreal newWindowHeight = event->newSize().height();
qreal newZoneHeight = newWindowHeight - extraHeight - 10;
scrollBar->setMaximum(totalZoneHeight - newZoneHeight);
}
void ZoneViewWidget::resizeToZoneContents() void ZoneViewWidget::resizeToZoneContents()
{ {
QRectF zoneRect = zone->getOptimumRect(); QRectF zoneRect = zone->getOptimumRect();
@ -261,7 +274,6 @@ void ZoneViewWidget::resizeToZoneContents()
resize(initialSize); 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 - initialZoneHeight);
if (layout()) if (layout())
layout()->invalidate(); layout()->invalidate();

View file

@ -65,6 +65,7 @@ private slots:
void handleScrollBarChange(int value); void handleScrollBarChange(int value);
void zoneDeleted(); void zoneDeleted();
void moveEvent(QGraphicsSceneMoveEvent * /* event */); void moveEvent(QGraphicsSceneMoveEvent * /* event */);
void resizeEvent(QGraphicsSceneResizeEvent * /* event */);
public: public:
ZoneViewWidget(Player *_player, ZoneViewWidget(Player *_player,