fixed count to tally rename inconsistencies

This commit is contained in:
DawnFire42 2026-06-19 10:41:16 -04:00
parent 189d7e5e6e
commit b58d3a14de
No known key found for this signature in database
GPG key ID: 24BB855EE2911B33
2 changed files with 22 additions and 22 deletions

View file

@ -79,12 +79,12 @@ GameView::GameView(GameScene *scene, QWidget *parent) : QGraphicsView(scene, par
totalCountLabel->setStyleSheet(totalCountLabelStyle); totalCountLabel->setStyleSheet(totalCountLabelStyle);
totalCountLabel->hide(); totalCountLabel->hide();
subtypeCountContainer = new QWidget(this); subtypeTallyContainer = new QWidget(this);
subtypeCountContainer->setStyleSheet(subtypeTallyLabelStyle); subtypeTallyContainer->setStyleSheet(subtypeTallyLabelStyle);
subtypeCountLayout = new QGridLayout(subtypeCountContainer); subtypeTallyLayout = new QGridLayout(subtypeTallyContainer);
subtypeCountLayout->setContentsMargins(2, 2, 2, 2); subtypeTallyLayout->setContentsMargins(2, 2, 2, 2);
subtypeCountLayout->setSpacing(2); subtypeTallyLayout->setSpacing(2);
subtypeCountContainer->hide(); subtypeTallyContainer->hide();
} }
void GameView::resizeEvent(QResizeEvent *event) void GameView::resizeEvent(QResizeEvent *event)
@ -179,7 +179,7 @@ void GameView::refreshShortcuts()
void GameView::clearSubtypeLabels() void GameView::clearSubtypeLabels()
{ {
QtUtils::clearLayoutRec(subtypeCountLayout); QtUtils::clearLayoutRec(subtypeTallyLayout);
} }
QSize GameView::rebuildSubtypeLabels(const QList<SubtypeEntry> &entries) QSize GameView::rebuildSubtypeLabels(const QList<SubtypeEntry> &entries)
@ -196,15 +196,15 @@ QSize GameView::rebuildSubtypeLabels(const QList<SubtypeEntry> &entries)
int row = 0; int row = 0;
for (const SubtypeEntry &entry : entries) { for (const SubtypeEntry &entry : entries) {
auto *nameLabel = new QLabel(entry.name, subtypeCountContainer); auto *nameLabel = new QLabel(entry.name, subtypeTallyContainer);
nameLabel->setStyleSheet(nameStyle); nameLabel->setStyleSheet(nameStyle);
nameLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter); nameLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
subtypeCountLayout->addWidget(nameLabel, row, 0); subtypeTallyLayout->addWidget(nameLabel, row, 0);
auto *countLabel = new QLabel(QString::number(entry.count), subtypeCountContainer); auto *countLabel = new QLabel(QString::number(entry.count), subtypeTallyContainer);
countLabel->setStyleSheet(countStyle); countLabel->setStyleSheet(countStyle);
countLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter); countLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
subtypeCountLayout->addWidget(countLabel, row, 1); subtypeTallyLayout->addWidget(countLabel, row, 1);
QSize nameSize = nameLabel->sizeHint(); QSize nameSize = nameLabel->sizeHint();
QSize countSize = countLabel->sizeHint(); QSize countSize = countLabel->sizeHint();
@ -215,9 +215,9 @@ QSize GameView::rebuildSubtypeLabels(const QList<SubtypeEntry> &entries)
++row; ++row;
} }
int spacing = subtypeCountLayout->spacing(); int spacing = subtypeTallyLayout->spacing();
int margins = subtypeCountLayout->contentsMargins().left() + subtypeCountLayout->contentsMargins().right(); int margins = subtypeTallyLayout->contentsMargins().left() + subtypeTallyLayout->contentsMargins().right();
int verticalMargins = subtypeCountLayout->contentsMargins().top() + subtypeCountLayout->contentsMargins().bottom(); int verticalMargins = subtypeTallyLayout->contentsMargins().top() + subtypeTallyLayout->contentsMargins().bottom();
int width = maxNameWidth + spacing + maxCountWidth + margins; int width = maxNameWidth + spacing + maxCountWidth + margins;
int height = totalHeight + (row - 1) * spacing + verticalMargins; int height = totalHeight + (row - 1) * spacing + verticalMargins;
@ -248,7 +248,7 @@ void GameView::updateTotalSelectionCount(const QSize &viewSize)
} }
if (!SettingsCache::instance().getShowSubtypeSelectionTally() || count <= 1) { if (!SettingsCache::instance().getShowSubtypeSelectionTally() || count <= 1) {
subtypeCountContainer->hide(); subtypeTallyContainer->hide();
cachedSubtypeEntries.clear(); cachedSubtypeEntries.clear();
return; return;
} }
@ -257,7 +257,7 @@ void GameView::updateTotalSelectionCount(const QSize &viewSize)
QList<SubtypeEntry> entries = SelectionSubtypeTally::countSubtypes(gameScene->selectedCards()); QList<SubtypeEntry> entries = SelectionSubtypeTally::countSubtypes(gameScene->selectedCards());
if (entries.isEmpty()) { if (entries.isEmpty()) {
subtypeCountContainer->hide(); subtypeTallyContainer->hide();
cachedSubtypeEntries.clear(); cachedSubtypeEntries.clear();
return; return;
} }
@ -267,9 +267,9 @@ void GameView::updateTotalSelectionCount(const QSize &viewSize)
if (entries != cachedSubtypeEntries) { if (entries != cachedSubtypeEntries) {
cachedSubtypeEntries = entries; cachedSubtypeEntries = entries;
containerSize = rebuildSubtypeLabels(entries); containerSize = rebuildSubtypeLabels(entries);
subtypeCountContainer->resize(containerSize); subtypeTallyContainer->resize(containerSize);
} else { } else {
containerSize = subtypeCountContainer->size(); containerSize = subtypeTallyContainer->size();
} }
int x = availableWidth - containerSize.width() - kMarginInPixels; int x = availableWidth - containerSize.width() - kMarginInPixels;
@ -283,8 +283,8 @@ void GameView::updateTotalSelectionCount(const QSize &viewSize)
y = qMax(kMarginInPixels, y); y = qMax(kMarginInPixels, y);
subtypeCountContainer->move(x, y); subtypeTallyContainer->move(x, y);
subtypeCountContainer->show(); subtypeTallyContainer->show();
} }
/** /**

View file

@ -24,8 +24,8 @@ private:
QRubberBand *rubberBand; QRubberBand *rubberBand;
QLabel *dragCountLabel; QLabel *dragCountLabel;
QLabel *totalCountLabel; QLabel *totalCountLabel;
QWidget *subtypeCountContainer; QWidget *subtypeTallyContainer;
QGridLayout *subtypeCountLayout; QGridLayout *subtypeTallyLayout;
QPointF selectionOrigin; QPointF selectionOrigin;
QList<SubtypeEntry> cachedSubtypeEntries; ///< Cached entries to avoid redundant rebuilds QList<SubtypeEntry> cachedSubtypeEntries; ///< Cached entries to avoid redundant rebuilds