make card view window max initial height configurable (#5236)

This commit is contained in:
RickyRister 2024-12-13 19:02:00 -08:00 committed by GitHub
parent 0463a6fd70
commit a0f74134bb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 41 additions and 1 deletions

View file

@ -254,6 +254,16 @@ void ZoneViewWidget::resizeEvent(QGraphicsSceneResizeEvent *event)
scrollBar->setMaximum(totalZoneHeight - newZoneHeight);
}
/**
* Calculates the max initial height from the settings.
* The max initial height setting is given as number of rows, so we need to map it to a height.
**/
static qreal calcMaxInitialHeight()
{
const qreal cardsHeight = (SettingsCache::instance().getCardViewInitialRowsMax() + 1) * (CARD_HEIGHT / 3);
return cardsHeight + 5; // +5 padding to make the cutoff look nicer
}
void ZoneViewWidget::resizeToZoneContents()
{
QRectF zoneRect = zone->getOptimumRect();
@ -265,7 +275,7 @@ void ZoneViewWidget::resizeToZoneContents()
QSizeF maxSize(width, zoneRect.height() + extraHeight + 10);
setMaximumSize(maxSize);
qreal initialZoneHeight = qMin(zoneRect.height(), 500.0);
qreal initialZoneHeight = qMin(zoneRect.height(), calcMaxInitialHeight());
QSizeF initialSize(width, initialZoneHeight + extraHeight + 10);
resize(initialSize);