mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-09-28 00:42:19 -07:00
[ThemeManager] Better default style guard
Took 21 minutes
This commit is contained in:
parent
2086deff5c
commit
25fcabc5fd
1 changed files with 11 additions and 7 deletions
|
|
@ -90,13 +90,17 @@ struct PaletteColorInfo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static QString usableDefaultStyle(const QString &style)
|
||||||
|
{
|
||||||
|
// The Windows 11 native style is broken: when the OS default
|
||||||
|
// ("Default" theme selection) would use it, fall back to the Vista style.
|
||||||
|
// Explicitly choosing "windows11" in a theme is still honored.
|
||||||
|
return style.compare("windows11", Qt::CaseInsensitive) == 0 ? QStringLiteral("windowsvista") : style;
|
||||||
|
}
|
||||||
|
|
||||||
ThemeManager::ThemeManager(QObject *parent) : QObject(parent)
|
ThemeManager::ThemeManager(QObject *parent) : QObject(parent)
|
||||||
{
|
{
|
||||||
defaultStyleName = qApp->style()->objectName();
|
defaultStyleName = usableDefaultStyle(qApp->style()->objectName());
|
||||||
//! \todo Workaround for windows11 style being broken.
|
|
||||||
if (defaultStyleName == "windows11") {
|
|
||||||
defaultStyleName = "windowsvista";
|
|
||||||
}
|
|
||||||
// Capture the untouched application palette before any theme is applied.
|
// Capture the untouched application palette before any theme is applied.
|
||||||
defaultPalette = qApp->palette();
|
defaultPalette = qApp->palette();
|
||||||
ensureThemeDirectoryExists();
|
ensureThemeDirectoryExists();
|
||||||
|
|
@ -316,13 +320,13 @@ void ThemeManager::applyStyleAndPalette(const QString &themeName,
|
||||||
if (themeName == FUSION_THEME_NAME) {
|
if (themeName == FUSION_THEME_NAME) {
|
||||||
styleName = "Fusion";
|
styleName = "Fusion";
|
||||||
} else {
|
} else {
|
||||||
styleName = defaultStyleName;
|
styleName = usableDefaultStyle(defaultStyleName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QStyle *style = QStyleFactory::create(styleName);
|
QStyle *style = QStyleFactory::create(styleName);
|
||||||
if (!style) {
|
if (!style) {
|
||||||
style = QStyleFactory::create(defaultStyleName);
|
style = QStyleFactory::create(usableDefaultStyle(defaultStyleName));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Base palette
|
// Base palette
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue