From f7a8e53d18ac842a00e1210c3579797ff15d126e Mon Sep 17 00:00:00 2001 From: RickyRister Date: Mon, 24 Feb 2025 01:16:01 -0800 Subject: [PATCH] implement thing again --- .../src/game/zones/view_zone_widget.cpp | 24 +++++++++++++++---- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/cockatrice/src/game/zones/view_zone_widget.cpp b/cockatrice/src/game/zones/view_zone_widget.cpp index ad002524c..83bea2be2 100644 --- a/cockatrice/src/game/zones/view_zone_widget.cpp +++ b/cockatrice/src/game/zones/view_zone_widget.cpp @@ -350,12 +350,26 @@ void ZoneViewWidget::initStyleOption(QStyleOption *option) const void ZoneViewWidget::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) { if (event->pos().y() <= 0) { - // expand window to full height and width if not currently at full height and width - // otherwise shrink window to initial max height - if (size().height() < maximumHeight() || size().width() < maximumWidth()) { - resize(maximumSize()); - } else { + qreal maxInitialHeight = calcMaxInitialHeight(); + qreal maxExpandedHeight = rowsToHeight(SettingsCache::instance().getCardViewExpandedRowsMax()); + qreal height = rect().height() - extraHeight - 10; + qreal maxHeight = maximumHeight() - extraHeight - 10; + + // reset window to initial max height if... + bool doResetSize = + // current height is less than that + (height < maxInitialHeight) || + // current height is at expanded max height + (height == maxExpandedHeight) || + // current height is at actual max height, and actual max height is less than expanded max height + (height == maxHeight && height > maxInitialHeight && height < maxExpandedHeight); + + if (doResetSize) { resizeToZoneContents(true); + } else { + // expand/shrink window to expanded max height if current height is anywhere at or between initial max + // height and actual max height + resize(maximumSize().boundedTo({maximumWidth(), maxExpandedHeight + extraHeight + 10})); } } } \ No newline at end of file