mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-09-29 09:22:18 -07:00
[ThemeManager] Capture app palette before theme is applied for reverting
This commit is contained in:
parent
6a889d301a
commit
143c466165
2 changed files with 11 additions and 1 deletions
|
|
@ -99,6 +99,8 @@ ThemeManager::ThemeManager(QObject *parent) : QObject(parent)
|
|||
QStyleFactory::keys().contains("windows11", Qt::CaseInsensitive)) {
|
||||
defaultStyleName = "windows11";
|
||||
}
|
||||
// Capture the untouched application palette before any theme is applied.
|
||||
defaultPalette = qApp->palette();
|
||||
ensureThemeDirectoryExists();
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(6, 5, 0))
|
||||
connect(QGuiApplication::styleHints(), &QStyleHints::colorSchemeChanged, this, &ThemeManager::themeChangedSlot);
|
||||
|
|
@ -332,7 +334,11 @@ void ThemeManager::applyStyleAndPalette(const QString &themeName,
|
|||
}
|
||||
#endif
|
||||
} else {
|
||||
base = qApp->palette();
|
||||
// Use the pristine startup palette rather than qApp->palette(): the
|
||||
// latter may already carry a previously-applied custom (e.g. dark)
|
||||
// palette, which would otherwise persist when switching to a scheme
|
||||
// that supplies no palette of its own.
|
||||
base = defaultPalette;
|
||||
}
|
||||
|
||||
// Overlay custom palette colours
|
||||
|
|
|
|||
|
|
@ -43,6 +43,10 @@ public:
|
|||
|
||||
private:
|
||||
QString defaultStyleName;
|
||||
// Pristine application palette captured at startup, before any custom theme
|
||||
// palette is applied. Used as the base when a theme supplies no palette, so
|
||||
// switching away from a custom palette restores the original colours.
|
||||
QPalette defaultPalette;
|
||||
QString currentThemePath;
|
||||
std::array<QBrush, Role::MaxRole + 1> brushes;
|
||||
QStringMap availableThemes;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue