[DeckEditor] Update when settings change

Took 26 minutes

Took 4 seconds
This commit is contained in:
Lukas Brübach 2025-12-16 12:54:10 +01:00 committed by Brübach, Lukas
parent a3de2dfd46
commit 6f62a25c95
2 changed files with 36 additions and 13 deletions

View file

@ -153,6 +153,19 @@ void DeckEditorDeckDockWidget::createDeckDock()
bracketRefreshButton->setAutoRaise(true);
connect(bracketRefreshButton, &QToolButton::clicked, this, &DeckEditorDeckDockWidget::requestBracketEstimate);
if (SettingsCache::instance().getDeckEditorCommanderSpellbookIntegrationEnabled() !=
deckEditorCommanderSpellbookIntegrationEnabledIndexUnprompted) {
connect(&SettingsCache::instance(), &SettingsCache::deckEditorCommanderSpellbookIntegrationEnabledChanged, this,
&DeckEditorDeckDockWidget::maybeAutoEstimateBracket);
connect(&SettingsCache::instance(),
&SettingsCache::deckEditorCommanderSpellbookIntegrationUseOfficialBracketNamesChanged, this,
&DeckEditorDeckDockWidget::maybeAutoEstimateBracket);
}
bracketLabel->setVisible(false);
bracketValueLabel->setVisible(false);
bracketInfoButton->setVisible(false);
bracketRefreshButton->setVisible(false);
commentsLabel = new QLabel();
commentsLabel->setObjectName("commentsLabel");
@ -379,6 +392,12 @@ bool DeckEditorDeckDockWidget::promptCommanderSpellbookIntegration()
SettingsCache::instance().setDeckEditorCommanderSpellbookIntegrationUseOfficialBracketNames(useOfficial);
}
connect(&SettingsCache::instance(), &SettingsCache::deckEditorCommanderSpellbookIntegrationEnabledChanged, this,
&DeckEditorDeckDockWidget::maybeAutoEstimateBracket);
connect(&SettingsCache::instance(),
&SettingsCache::deckEditorCommanderSpellbookIntegrationUseOfficialBracketNamesChanged, this,
&DeckEditorDeckDockWidget::maybeAutoEstimateBracket);
// Persist integration mode
if (clickedButton == disableBtn) {
SettingsCache::instance().setDeckEditorCommanderSpellbookIntegrationEnabled(
@ -399,6 +418,14 @@ bool DeckEditorDeckDockWidget::promptCommanderSpellbookIntegration()
return false;
}
void DeckEditorDeckDockWidget::updateBracketVisibility(bool visible)
{
bracketLabel->setVisible(visible);
bracketValueLabel->setVisible(visible);
bracketInfoButton->setVisible(visible);
bracketRefreshButton->setVisible(visible);
}
void DeckEditorDeckDockWidget::requestBracketEstimate()
{
bracketRefreshButton->setEnabled(false);
@ -482,10 +509,7 @@ void DeckEditorDeckDockWidget::initializeFormats()
const bool bracketVisible = isCommander && commanderSpellbookIntegrationEnabled;
bracketLabel->setVisible(bracketVisible);
bracketValueLabel->setVisible(bracketVisible);
bracketInfoButton->setVisible(bracketVisible);
bracketRefreshButton->setVisible(bracketVisible);
updateBracketVisibility(bracketVisible);
if (!isCommander) {
bracketValueLabel->setText("-");
@ -507,22 +531,20 @@ void DeckEditorDeckDockWidget::maybeAutoEstimateBracket()
const bool isCommander = (formatKey.compare("commander", Qt::CaseInsensitive) == 0);
if (!isCommander) {
int mode = SettingsCache::instance().getDeckEditorCommanderSpellbookIntegrationEnabled();
if (!isCommander || mode == deckEditorCommanderSpellbookIntegrationEnabledIndexDisabled) {
updateBracketVisibility(false);
return;
}
int mode = SettingsCache::instance().getDeckEditorCommanderSpellbookIntegrationEnabled();
if (mode == deckEditorCommanderSpellbookIntegrationEnabledIndexUnprompted) {
if (!promptCommanderSpellbookIntegration()) {
bracketLabel->setVisible(false);
bracketValueLabel->setVisible(false);
bracketInfoButton->setVisible(false);
bracketRefreshButton->setVisible(false);
return; // user chose Disabled
updateBracketVisibility(false);
return;
}
// user chose Enabled or Automatic → fall through
}
updateBracketVisibility(true);
mode = SettingsCache::instance().getDeckEditorCommanderSpellbookIntegrationEnabled();
if (mode != deckEditorCommanderSpellbookIntegrationEnabledIndexAutomatic) {
return;

View file

@ -36,6 +36,7 @@ public:
QComboBox *bannerCardComboBox;
void createDeckDock();
bool promptCommanderSpellbookIntegration();
void updateBracketVisibility(bool visible);
void requestBracketEstimate();
ExactCard getCurrentCard();
void retranslateUi();