mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-09-27 00:14:40 -07:00
Promote Fusion to default theme, rename Default to System
Fresh installs and new profiles now default to the Fusion (dark) theme instead of the platform-native theme. The old "Default" theme is renamed "System" to better describe its purpose — using the OS-native Qt style (windowsvista, macOS, etc.). Existing users who had "Default" selected are automatically migrated to "System" so they keep their platform-native styling. Users with an empty or invalid theme name now fall back to Fusion.
This commit is contained in:
parent
19a9fd4f1d
commit
e5427730d9
8 changed files with 23 additions and 15 deletions
|
|
@ -16,7 +16,7 @@ QString ThemeConfig::toIni() const
|
||||||
out += "[Appearance]\n";
|
out += "[Appearance]\n";
|
||||||
out += QString("ColorScheme = %1\n").arg(colorScheme.isEmpty() ? "System" : colorScheme);
|
out += QString("ColorScheme = %1\n").arg(colorScheme.isEmpty() ? "System" : colorScheme);
|
||||||
out += "\n[Style]\n";
|
out += "\n[Style]\n";
|
||||||
out += QString("Name = %1\n").arg(styleName.isEmpty() ? "Default" : styleName);
|
out += QString("Name = %1\n").arg(styleName.isEmpty() ? "System" : styleName);
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@
|
||||||
#include <Qt>
|
#include <Qt>
|
||||||
#include <libcockatrice/settings/paths_settings.h>
|
#include <libcockatrice/settings/paths_settings.h>
|
||||||
|
|
||||||
#define NONE_THEME_NAME "Default"
|
#define SYSTEM_THEME_NAME "System"
|
||||||
#define FUSION_THEME_NAME "Fusion"
|
#define FUSION_THEME_NAME "Fusion"
|
||||||
#define STYLE_CSS_NAME "style.css"
|
#define STYLE_CSS_NAME "style.css"
|
||||||
#define HANDZONE_BG_NAME "handzone"
|
#define HANDZONE_BG_NAME "handzone"
|
||||||
|
|
@ -96,7 +96,7 @@ struct PaletteColorInfo
|
||||||
static QString usableDefaultStyle(const QString &style)
|
static QString usableDefaultStyle(const QString &style)
|
||||||
{
|
{
|
||||||
// The Windows 11 native style is broken: when the OS default
|
// The Windows 11 native style is broken: when the OS default
|
||||||
// ("Default" theme selection) would use it, fall back to the Vista style.
|
// ("System" theme selection) would use it, fall back to the Vista style.
|
||||||
// Explicitly choosing "windows11" in a theme is still honored.
|
// Explicitly choosing "windows11" in a theme is still honored.
|
||||||
return style.compare("windows11", Qt::CaseInsensitive) == 0 ? QStringLiteral("windowsvista") : style;
|
return style.compare("windows11", Qt::CaseInsensitive) == 0 ? QStringLiteral("windowsvista") : style;
|
||||||
}
|
}
|
||||||
|
|
@ -119,10 +119,16 @@ ThemeManager::ThemeManager(QObject *parent) : QObject(parent)
|
||||||
|
|
||||||
void ThemeManager::ensureThemeDirectoryExists()
|
void ThemeManager::ensureThemeDirectoryExists()
|
||||||
{
|
{
|
||||||
if (SettingsCache::instance().getThemeName().isEmpty() ||
|
auto &settings = SettingsCache::instance();
|
||||||
!getAvailableThemes().contains(SettingsCache::instance().getThemeName())) {
|
|
||||||
|
// Migrate the old "Default" theme name to "System"
|
||||||
|
if (settings.getThemeName() == "Default") {
|
||||||
|
settings.setThemeName(SYSTEM_THEME_NAME);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (settings.getThemeName().isEmpty() || !getAvailableThemes().contains(settings.getThemeName())) {
|
||||||
qCInfo(ThemeManagerLog) << "Theme name not set, setting default value";
|
qCInfo(ThemeManagerLog) << "Theme name not set, setting default value";
|
||||||
SettingsCache::instance().setThemeName(NONE_THEME_NAME);
|
settings.setThemeName(FUSION_THEME_NAME);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -235,9 +241,7 @@ QStringMap &ThemeManager::getAvailableThemes()
|
||||||
// load themes from user profile dir
|
// load themes from user profile dir
|
||||||
dir.setPath(SettingsCache::instance().paths().getThemesPath());
|
dir.setPath(SettingsCache::instance().paths().getThemesPath());
|
||||||
|
|
||||||
// add default value
|
availableThemes.insert(SYSTEM_THEME_NAME, dir.absoluteFilePath("System"));
|
||||||
availableThemes.insert(NONE_THEME_NAME, dir.absoluteFilePath("Default"));
|
|
||||||
|
|
||||||
availableThemes.insert(FUSION_THEME_NAME, dir.absoluteFilePath("Fusion"));
|
availableThemes.insert(FUSION_THEME_NAME, dir.absoluteFilePath("Fusion"));
|
||||||
|
|
||||||
for (QString themeName : dir.entryList(QDir::AllDirs | QDir::NoDotAndDotDot, QDir::Name)) {
|
for (QString themeName : dir.entryList(QDir::AllDirs | QDir::NoDotAndDotDot, QDir::Name)) {
|
||||||
|
|
@ -395,7 +399,7 @@ void ThemeManager::applyStyleAndPalette(const QString &themeName,
|
||||||
Q_UNUSED(activeScheme)
|
Q_UNUSED(activeScheme)
|
||||||
#endif
|
#endif
|
||||||
QString styleName = themeCfg.styleName;
|
QString styleName = themeCfg.styleName;
|
||||||
if (styleName.isEmpty() || styleName.compare("Default", Qt::CaseInsensitive) == 0) {
|
if (styleName.isEmpty() || styleName.compare("System", Qt::CaseInsensitive) == 0) {
|
||||||
if (themeName == FUSION_THEME_NAME) {
|
if (themeName == FUSION_THEME_NAME) {
|
||||||
styleName = "Fusion";
|
styleName = "Fusion";
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -59,8 +59,8 @@ AppearanceSettingsPage::AppearanceSettingsPage()
|
||||||
connect(&schemeCombo, &QComboBox::currentIndexChanged, this,
|
connect(&schemeCombo, &QComboBox::currentIndexChanged, this,
|
||||||
[this] { themeManager->setColorScheme(schemeCombo.currentData().toString()); });
|
[this] { themeManager->setColorScheme(schemeCombo.currentData().toString()); });
|
||||||
|
|
||||||
// Qt widget style; "Default" lets the application decide
|
// Qt widget style; "System" lets the application decide
|
||||||
styleCombo.addItem(tr("Default"), QStringLiteral("Default"));
|
styleCombo.addItem(tr("System"), QStringLiteral("System"));
|
||||||
for (const QString &key : QStyleFactory::keys()) {
|
for (const QString &key : QStyleFactory::keys()) {
|
||||||
styleCombo.addItem(key, key);
|
styleCombo.addItem(key, key);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
#
|
#
|
||||||
# add themes subfolders
|
# add themes subfolders
|
||||||
|
|
||||||
set(defthemes Default Fabric Fusion Leather Plasma VelvetMarble)
|
set(defthemes Fabric Fusion Leather Plasma VelvetMarble System)
|
||||||
|
|
||||||
if(UNIX)
|
if(UNIX)
|
||||||
if(APPLE)
|
if(APPLE)
|
||||||
|
|
|
||||||
|
|
@ -2,4 +2,4 @@
|
||||||
ColorScheme = Light
|
ColorScheme = Light
|
||||||
|
|
||||||
[Style]
|
[Style]
|
||||||
Name = Default
|
Name = System
|
||||||
|
|
@ -374,7 +374,11 @@ static void migrateAppearanceSettings(const QString &settingsPath, QSettings &gl
|
||||||
QSettings appearanceIni(settingsPath + "appearance.ini", QSettings::IniFormat);
|
QSettings appearanceIni(settingsPath + "appearance.ini", QSettings::IniFormat);
|
||||||
for (auto it = appearanceKeyMap.constBegin(); it != appearanceKeyMap.constEnd(); ++it) {
|
for (auto it = appearanceKeyMap.constBegin(); it != appearanceKeyMap.constEnd(); ++it) {
|
||||||
if (globalIni.contains(it.key())) {
|
if (globalIni.contains(it.key())) {
|
||||||
appearanceIni.setValue(it.value(), globalIni.value(it.key()));
|
QVariant value = globalIni.value(it.key());
|
||||||
|
if (it.key() == "theme/name" && value.toString() == "Default") {
|
||||||
|
value = "System";
|
||||||
|
}
|
||||||
|
appearanceIni.setValue(it.value(), value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue