Compare commits

...

1 Commits

Author SHA1 Message Date
RickyRister
0deaa9d9b4 [DeckEditor] Don't change widget focus when adding card (#6503) 2026-01-09 18:27:54 -08:00
5 changed files with 11 additions and 7 deletions

View File

@@ -459,12 +459,15 @@ void DeckEditorDeckDockWidget::syncBannerCardComboBoxSelectionWithDeck()
}
}
void DeckEditorDeckDockWidget::setSelectedIndex(const QModelIndex &newCardIndex)
void DeckEditorDeckDockWidget::setSelectedIndex(const QModelIndex &newCardIndex, bool preserveWidgetFocus)
{
deckView->clearSelection();
deckView->setCurrentIndex(newCardIndex);
recursiveExpand(newCardIndex);
deckView->setFocus(Qt::FocusReason::MouseFocusReason);
if (!preserveWidgetFocus) {
deckView->setFocus(Qt::FocusReason::MouseFocusReason);
}
}
void DeckEditorDeckDockWidget::syncDisplayWidgetsToModel()

View File

@@ -100,7 +100,7 @@ private slots:
void writeComments();
void writeBannerCard(int);
void applyActiveGroupCriteria();
void setSelectedIndex(const QModelIndex &newCardIndex);
void setSelectedIndex(const QModelIndex &newCardIndex, bool preserveWidgetFocus);
void updateHash();
void refreshShortcuts();
void updateShowBannerCardComboBox(bool visible);

View File

@@ -182,7 +182,7 @@ QModelIndex DeckStateManager::addCard(const ExactCard &card, const QString &zone
QModelIndex idx = modifyDeck(reason, [&card, &zone](auto model) { return model->addCard(card, zone); });
if (idx.isValid()) {
emit focusIndexChanged(idx);
emit focusIndexChanged(idx, true);
}
return idx;
@@ -208,7 +208,7 @@ QModelIndex DeckStateManager::decrementCard(const ExactCard &card, const QString
}
if (idx.isValid()) {
emit focusIndexChanged(idx);
emit focusIndexChanged(idx, true);
}
return idx;

View File

@@ -290,8 +290,9 @@ signals:
/**
* The selected card on any views connected to this deck should be changed to this index.
* @param index The model index
* @param preserveWidgetFocus Whether to keep the widget focus unchanged
*/
void focusIndexChanged(QModelIndex index);
void focusIndexChanged(QModelIndex index, bool preserveWidgetFocus);
};
#endif // COCKATRICE_DECK_STATE_MANAGER_H

View File

@@ -198,7 +198,7 @@ void CardAmountWidget::addPrinting(const QString &zone)
});
if (newCardIndex.isValid()) {
emit deckStateManager->focusIndexChanged(newCardIndex);
emit deckStateManager->focusIndexChanged(newCardIndex, false);
}
}