mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-09-21 09:05:10 -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 += QString("ColorScheme = %1\n").arg(colorScheme.isEmpty() ? "System" : colorScheme);
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
#include <Qt>
|
||||
#include <libcockatrice/settings/paths_settings.h>
|
||||
|
||||
#define NONE_THEME_NAME "Default"
|
||||
#define SYSTEM_THEME_NAME "System"
|
||||
#define FUSION_THEME_NAME "Fusion"
|
||||
#define STYLE_CSS_NAME "style.css"
|
||||
#define HANDZONE_BG_NAME "handzone"
|
||||
|
|
@ -96,7 +96,7 @@ 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.
|
||||
// ("System" 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;
|
||||
}
|
||||
|
|
@ -119,10 +119,16 @@ ThemeManager::ThemeManager(QObject *parent) : QObject(parent)
|
|||
|
||||
void ThemeManager::ensureThemeDirectoryExists()
|
||||
{
|
||||
if (SettingsCache::instance().getThemeName().isEmpty() ||
|
||||
!getAvailableThemes().contains(SettingsCache::instance().getThemeName())) {
|
||||
auto &settings = SettingsCache::instance();
|
||||
|
||||
// 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";
|
||||
SettingsCache::instance().setThemeName(NONE_THEME_NAME);
|
||||
settings.setThemeName(FUSION_THEME_NAME);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -235,9 +241,7 @@ QStringMap &ThemeManager::getAvailableThemes()
|
|||
// load themes from user profile dir
|
||||
dir.setPath(SettingsCache::instance().paths().getThemesPath());
|
||||
|
||||
// add default value
|
||||
availableThemes.insert(NONE_THEME_NAME, dir.absoluteFilePath("Default"));
|
||||
|
||||
availableThemes.insert(SYSTEM_THEME_NAME, dir.absoluteFilePath("System"));
|
||||
availableThemes.insert(FUSION_THEME_NAME, dir.absoluteFilePath("Fusion"));
|
||||
|
||||
for (QString themeName : dir.entryList(QDir::AllDirs | QDir::NoDotAndDotDot, QDir::Name)) {
|
||||
|
|
@ -395,7 +399,7 @@ void ThemeManager::applyStyleAndPalette(const QString &themeName,
|
|||
Q_UNUSED(activeScheme)
|
||||
#endif
|
||||
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) {
|
||||
styleName = "Fusion";
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -59,8 +59,8 @@ AppearanceSettingsPage::AppearanceSettingsPage()
|
|||
connect(&schemeCombo, &QComboBox::currentIndexChanged, this,
|
||||
[this] { themeManager->setColorScheme(schemeCombo.currentData().toString()); });
|
||||
|
||||
// Qt widget style; "Default" lets the application decide
|
||||
styleCombo.addItem(tr("Default"), QStringLiteral("Default"));
|
||||
// Qt widget style; "System" lets the application decide
|
||||
styleCombo.addItem(tr("System"), QStringLiteral("System"));
|
||||
for (const QString &key : QStyleFactory::keys()) {
|
||||
styleCombo.addItem(key, key);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
#
|
||||
# add themes subfolders
|
||||
|
||||
set(defthemes Default Fabric Fusion Leather Plasma VelvetMarble)
|
||||
set(defthemes Fabric Fusion Leather Plasma VelvetMarble System)
|
||||
|
||||
if(UNIX)
|
||||
if(APPLE)
|
||||
|
|
|
|||
|
|
@ -2,4 +2,4 @@
|
|||
ColorScheme = Light
|
||||
|
||||
[Style]
|
||||
Name = Default
|
||||
Name = System
|
||||
|
|
@ -374,7 +374,11 @@ static void migrateAppearanceSettings(const QString &settingsPath, QSettings &gl
|
|||
QSettings appearanceIni(settingsPath + "appearance.ini", QSettings::IniFormat);
|
||||
for (auto it = appearanceKeyMap.constBegin(); it != appearanceKeyMap.constEnd(); ++it) {
|
||||
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