This commit is contained in:
RickyRister 2025-02-24 20:44:59 -08:00
parent c0be0b8692
commit 07b3920fc7
2 changed files with 31 additions and 21 deletions

View file

@ -347,29 +347,38 @@ void ZoneViewWidget::initStyleOption(QStyleOption *option) const
titleBar->icon = QPixmap("theme:cockatrice");
}
/**
* Expands/shrinks the window, depending on the current height as well as the configured initial and expanded max
* heights.
*/
void ZoneViewWidget::expandWindow()
{
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}));
}
}
void ZoneViewWidget::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
{
if (event->pos().y() <= 0) {
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}));
}
expandWindow();
}
}

View file

@ -68,6 +68,7 @@ private slots:
void zoneDeleted();
void moveEvent(QGraphicsSceneMoveEvent * /* event */) override;
void resizeEvent(QGraphicsSceneResizeEvent * /* event */) override;
void expandWindow();
public:
ZoneViewWidget(Player *_player,