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); layout->addWidget(cardSelectionBar);
// Connect deck model data change signal to update display // Connect deck model data change signal to update display
connect(deckModel, &DeckListModel::dataChanged, this, [this]() { connect(deckModel, &DeckListModel::rowsInserted, this, &PrintingSelector::printingsInDeckChanged);
// Delay the update to avoid race conditions connect(deckModel, &DeckListModel::rowsRemoved, this, &PrintingSelector::printingsInDeckChanged);
QTimer::singleShot(100, this, &PrintingSelector::updateDisplay); }
});
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()) { if (newCard.isNull()) {
return; 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; selectedCard = newCard;
currentZone = _currentZone; currentZone = _currentZone;
if (isVisible()) { if (isVisible()) {

View file

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