mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-22 14:53:53 -07:00
[DeckEditor] Update when settings change
Took 26 minutes Took 4 seconds
This commit is contained in:
parent
a3de2dfd46
commit
6f62a25c95
2 changed files with 36 additions and 13 deletions
|
|
@ -153,6 +153,19 @@ void DeckEditorDeckDockWidget::createDeckDock()
|
||||||
bracketRefreshButton->setAutoRaise(true);
|
bracketRefreshButton->setAutoRaise(true);
|
||||||
|
|
||||||
connect(bracketRefreshButton, &QToolButton::clicked, this, &DeckEditorDeckDockWidget::requestBracketEstimate);
|
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 = new QLabel();
|
||||||
commentsLabel->setObjectName("commentsLabel");
|
commentsLabel->setObjectName("commentsLabel");
|
||||||
|
|
@ -379,6 +392,12 @@ bool DeckEditorDeckDockWidget::promptCommanderSpellbookIntegration()
|
||||||
SettingsCache::instance().setDeckEditorCommanderSpellbookIntegrationUseOfficialBracketNames(useOfficial);
|
SettingsCache::instance().setDeckEditorCommanderSpellbookIntegrationUseOfficialBracketNames(useOfficial);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
connect(&SettingsCache::instance(), &SettingsCache::deckEditorCommanderSpellbookIntegrationEnabledChanged, this,
|
||||||
|
&DeckEditorDeckDockWidget::maybeAutoEstimateBracket);
|
||||||
|
connect(&SettingsCache::instance(),
|
||||||
|
&SettingsCache::deckEditorCommanderSpellbookIntegrationUseOfficialBracketNamesChanged, this,
|
||||||
|
&DeckEditorDeckDockWidget::maybeAutoEstimateBracket);
|
||||||
|
|
||||||
// Persist integration mode
|
// Persist integration mode
|
||||||
if (clickedButton == disableBtn) {
|
if (clickedButton == disableBtn) {
|
||||||
SettingsCache::instance().setDeckEditorCommanderSpellbookIntegrationEnabled(
|
SettingsCache::instance().setDeckEditorCommanderSpellbookIntegrationEnabled(
|
||||||
|
|
@ -399,6 +418,14 @@ bool DeckEditorDeckDockWidget::promptCommanderSpellbookIntegration()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DeckEditorDeckDockWidget::updateBracketVisibility(bool visible)
|
||||||
|
{
|
||||||
|
bracketLabel->setVisible(visible);
|
||||||
|
bracketValueLabel->setVisible(visible);
|
||||||
|
bracketInfoButton->setVisible(visible);
|
||||||
|
bracketRefreshButton->setVisible(visible);
|
||||||
|
}
|
||||||
|
|
||||||
void DeckEditorDeckDockWidget::requestBracketEstimate()
|
void DeckEditorDeckDockWidget::requestBracketEstimate()
|
||||||
{
|
{
|
||||||
bracketRefreshButton->setEnabled(false);
|
bracketRefreshButton->setEnabled(false);
|
||||||
|
|
@ -482,10 +509,7 @@ void DeckEditorDeckDockWidget::initializeFormats()
|
||||||
|
|
||||||
const bool bracketVisible = isCommander && commanderSpellbookIntegrationEnabled;
|
const bool bracketVisible = isCommander && commanderSpellbookIntegrationEnabled;
|
||||||
|
|
||||||
bracketLabel->setVisible(bracketVisible);
|
updateBracketVisibility(bracketVisible);
|
||||||
bracketValueLabel->setVisible(bracketVisible);
|
|
||||||
bracketInfoButton->setVisible(bracketVisible);
|
|
||||||
bracketRefreshButton->setVisible(bracketVisible);
|
|
||||||
|
|
||||||
if (!isCommander) {
|
if (!isCommander) {
|
||||||
bracketValueLabel->setText("-");
|
bracketValueLabel->setText("-");
|
||||||
|
|
@ -507,22 +531,20 @@ void DeckEditorDeckDockWidget::maybeAutoEstimateBracket()
|
||||||
|
|
||||||
const bool isCommander = (formatKey.compare("commander", Qt::CaseInsensitive) == 0);
|
const bool isCommander = (formatKey.compare("commander", Qt::CaseInsensitive) == 0);
|
||||||
|
|
||||||
if (!isCommander) {
|
int mode = SettingsCache::instance().getDeckEditorCommanderSpellbookIntegrationEnabled();
|
||||||
|
|
||||||
|
if (!isCommander || mode == deckEditorCommanderSpellbookIntegrationEnabledIndexDisabled) {
|
||||||
|
updateBracketVisibility(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int mode = SettingsCache::instance().getDeckEditorCommanderSpellbookIntegrationEnabled();
|
|
||||||
|
|
||||||
if (mode == deckEditorCommanderSpellbookIntegrationEnabledIndexUnprompted) {
|
if (mode == deckEditorCommanderSpellbookIntegrationEnabledIndexUnprompted) {
|
||||||
if (!promptCommanderSpellbookIntegration()) {
|
if (!promptCommanderSpellbookIntegration()) {
|
||||||
bracketLabel->setVisible(false);
|
updateBracketVisibility(false);
|
||||||
bracketValueLabel->setVisible(false);
|
return;
|
||||||
bracketInfoButton->setVisible(false);
|
|
||||||
bracketRefreshButton->setVisible(false);
|
|
||||||
return; // user chose Disabled
|
|
||||||
}
|
}
|
||||||
// user chose Enabled or Automatic → fall through
|
|
||||||
}
|
}
|
||||||
|
updateBracketVisibility(true);
|
||||||
mode = SettingsCache::instance().getDeckEditorCommanderSpellbookIntegrationEnabled();
|
mode = SettingsCache::instance().getDeckEditorCommanderSpellbookIntegrationEnabled();
|
||||||
if (mode != deckEditorCommanderSpellbookIntegrationEnabledIndexAutomatic) {
|
if (mode != deckEditorCommanderSpellbookIntegrationEnabledIndexAutomatic) {
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,7 @@ public:
|
||||||
QComboBox *bannerCardComboBox;
|
QComboBox *bannerCardComboBox;
|
||||||
void createDeckDock();
|
void createDeckDock();
|
||||||
bool promptCommanderSpellbookIntegration();
|
bool promptCommanderSpellbookIntegration();
|
||||||
|
void updateBracketVisibility(bool visible);
|
||||||
void requestBracketEstimate();
|
void requestBracketEstimate();
|
||||||
ExactCard getCurrentCard();
|
ExactCard getCurrentCard();
|
||||||
void retranslateUi();
|
void retranslateUi();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue