mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-18 08:22:15 -07:00
refactor
This commit is contained in:
parent
c0be0b8692
commit
07b3920fc7
2 changed files with 31 additions and 21 deletions
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
@ -68,6 +68,7 @@ private slots:
|
|||
void zoneDeleted();
|
||||
void moveEvent(QGraphicsSceneMoveEvent * /* event */) override;
|
||||
void resizeEvent(QGraphicsSceneResizeEvent * /* event */) override;
|
||||
void expandWindow();
|
||||
|
||||
public:
|
||||
ZoneViewWidget(Player *_player,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue