diff --git a/cockatrice/src/interface/palette_editor/palette_editor_dialog.cpp b/cockatrice/src/interface/palette_editor/palette_editor_dialog.cpp index cd247a18d..79875f0b0 100644 --- a/cockatrice/src/interface/palette_editor/palette_editor_dialog.cpp +++ b/cockatrice/src/interface/palette_editor/palette_editor_dialog.cpp @@ -158,17 +158,22 @@ void PaletteEditorDialog::setupUi() }); } +void PaletteEditorDialog::updateUserOverrideState() +{ + const bool hasUserOverride = + QFile::exists(QDir(userThemeDirPath).absoluteFilePath(PaletteConfig::fileName(loadedScheme))); + + revertButton->setEnabled(hasUserOverride); + revertButton->setToolTip(hasUserOverride ? tr("Delete your custom palette and restore the shipped defaults") + : tr("No custom palette overrides exist for this scheme")); +} + void PaletteEditorDialog::retranslateUi() { setWindowTitle(tr("Palette Editor — %1").arg(themeName)); titleLabel->setText(tr("Palette Editor  ·  %1").arg(themeName)); - const bool hasUserOverride = - QFile::exists(QDir(userThemeDirPath).absoluteFilePath(PaletteConfig::fileName("Light"))) || - QFile::exists(QDir(userThemeDirPath).absoluteFilePath(PaletteConfig::fileName("Dark"))); - revertButton->setEnabled(hasUserOverride); - revertButton->setToolTip(hasUserOverride ? tr("Delete your custom palette and restore the shipped defaults") - : tr("No custom palette overrides exist for this theme")); + updateUserOverrideState(); schemeComboBox->setToolTip(tr("Switch between the light and dark palette files")); editingLabel->setText(tr("Editing:")); @@ -236,6 +241,9 @@ void PaletteEditorDialog::onSchemeChanged(const QString &scheme) loadedScheme = scheme; paletteGrid->loadPalette(workingConfig.value(scheme)); seedAccentFromScheme(scheme); + + updateUserOverrideState(); + onApply(); } diff --git a/cockatrice/src/interface/palette_editor/palette_editor_dialog.h b/cockatrice/src/interface/palette_editor/palette_editor_dialog.h index 8da7c5589..024c2632a 100644 --- a/cockatrice/src/interface/palette_editor/palette_editor_dialog.h +++ b/cockatrice/src/interface/palette_editor/palette_editor_dialog.h @@ -31,6 +31,7 @@ private slots: private: void setupUi(); + void updateUserOverrideState(); void retranslateUi(); void refreshChromePalettes(); void loadScheme(const QString &scheme); // snapshot current, switch, load