don't redraw PrintingSelector's FlowWidget unless cards actually changed (#5392)

This commit is contained in:
RickyRister 2025-01-03 17:49:54 -08:00 committed by GitHub
parent 455cd9717a
commit 68226786a2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 17 additions and 4 deletions

View file

@ -57,10 +57,14 @@ PrintingSelector::PrintingSelector(QWidget *parent,
layout->addWidget(cardSelectionBar);
// Connect deck model data change signal to update display
connect(deckModel, &DeckListModel::dataChanged, this, [this]() {
// Delay the update to avoid race conditions
QTimer::singleShot(100, this, &PrintingSelector::updateDisplay);
});
connect(deckModel, &DeckListModel::rowsInserted, this, &PrintingSelector::printingsInDeckChanged);
connect(deckModel, &DeckListModel::rowsRemoved, this, &PrintingSelector::printingsInDeckChanged);
}
void PrintingSelector::printingsInDeckChanged()
{
// Delay the update to avoid race conditions
QTimer::singleShot(100, this, &PrintingSelector::updateDisplay);
}
/**
@ -89,6 +93,12 @@ void PrintingSelector::setCard(const CardInfoPtr &newCard, const QString &_curre
if (newCard.isNull()) {
return;
}
// we don't need to redraw the widget if the card is the same
if (!selectedCard.isNull() && selectedCard->getName() == newCard->getName()) {
return;
}
selectedCard = newCard;
currentZone = _currentZone;
if (isVisible()) {

View file

@ -37,6 +37,9 @@ public slots:
void toggleVisibilityCardSizeSlider(bool _state);
void toggleVisibilityNavigationButtons(bool _state);
private slots:
void printingsInDeckChanged();
private:
QVBoxLayout *layout;
PrintingSelectorViewOptionsToolbarWidget *viewOptionsToolbar;