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,9 +347,12 @@ void ZoneViewWidget::initStyleOption(QStyleOption *option) const
titleBar->icon = QPixmap("theme:cockatrice"); titleBar->icon = QPixmap("theme:cockatrice");
} }
void ZoneViewWidget::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) /**
* Expands/shrinks the window, depending on the current height as well as the configured initial and expanded max
* heights.
*/
void ZoneViewWidget::expandWindow()
{ {
if (event->pos().y() <= 0) {
qreal maxInitialHeight = calcMaxInitialHeight(); qreal maxInitialHeight = calcMaxInitialHeight();
qreal maxExpandedHeight = rowsToHeight(SettingsCache::instance().getCardViewExpandedRowsMax()); qreal maxExpandedHeight = rowsToHeight(SettingsCache::instance().getCardViewExpandedRowsMax());
qreal height = rect().height() - extraHeight - 10; qreal height = rect().height() - extraHeight - 10;
@ -367,9 +370,15 @@ void ZoneViewWidget::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
if (doResetSize) { if (doResetSize) {
resizeToZoneContents(true); resizeToZoneContents(true);
} else { } else {
// expand/shrink window to expanded max height if current height is anywhere at or between initial max // expand/shrink window to expanded max height if current height is anywhere at or between initial max height
// height and actual max height // and actual max height
resize(maximumSize().boundedTo({maximumWidth(), maxExpandedHeight + extraHeight + 10})); resize(maximumSize().boundedTo({maximumWidth(), maxExpandedHeight + extraHeight + 10}));
} }
}
void ZoneViewWidget::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
{
if (event->pos().y() <= 0) {
expandWindow();
} }
} }

View file

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