mirror of
https://github.com/yuzu-emu/yuzu.git
synced 2024-11-30 07:24:20 +01:00
Replace "Light" theme by "Default"
This reflects the current behavior: Light = System default. If your system is set to dark theme, then Light = Dark, which is a bit confusing for the end user. In this PR, I propose to change "Light" with "Default". This way, the user has "Default" and "Default Colorful", which will apply the system theme. Now that the Flatpak respects the system theme, I think this makes much more sense. I also simplified the theme update. Before the code was branching between the default theme and the others, but I think we can have something simpler by forcing the default theme if no theme is defined in the settings, or if the selected theme doesn't exist. And if there's an error, tell the theme name in the error message.
This commit is contained in:
parent
0eacc362dd
commit
2e5866147e
@ -3381,36 +3381,38 @@ void GMainWindow::filterBarSetChecked(bool state) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void GMainWindow::UpdateUITheme() {
|
void GMainWindow::UpdateUITheme() {
|
||||||
const QString default_icons = QStringLiteral("default");
|
const QString default_theme = QStringLiteral("default");
|
||||||
const QString& current_theme = UISettings::values.theme;
|
QString current_theme = UISettings::values.theme;
|
||||||
const bool is_default_theme = current_theme == QString::fromUtf8(UISettings::themes[0].second);
|
|
||||||
QStringList theme_paths(default_theme_paths);
|
QStringList theme_paths(default_theme_paths);
|
||||||
|
|
||||||
if (is_default_theme || current_theme.isEmpty()) {
|
if (current_theme.isEmpty()) {
|
||||||
const QString theme_uri(QStringLiteral(":default/style.qss"));
|
current_theme = default_theme;
|
||||||
QFile f(theme_uri);
|
|
||||||
if (f.open(QFile::ReadOnly | QFile::Text)) {
|
|
||||||
QTextStream ts(&f);
|
|
||||||
qApp->setStyleSheet(ts.readAll());
|
|
||||||
setStyleSheet(ts.readAll());
|
|
||||||
} else {
|
|
||||||
qApp->setStyleSheet({});
|
|
||||||
setStyleSheet({});
|
|
||||||
}
|
|
||||||
QIcon::setThemeName(default_icons);
|
|
||||||
} else {
|
|
||||||
const QString theme_uri(QLatin1Char{':'} + current_theme + QStringLiteral("/style.qss"));
|
|
||||||
QFile f(theme_uri);
|
|
||||||
if (f.open(QFile::ReadOnly | QFile::Text)) {
|
|
||||||
QTextStream ts(&f);
|
|
||||||
qApp->setStyleSheet(ts.readAll());
|
|
||||||
setStyleSheet(ts.readAll());
|
|
||||||
} else {
|
|
||||||
LOG_ERROR(Frontend, "Unable to set style, stylesheet file not found");
|
|
||||||
}
|
|
||||||
QIcon::setThemeName(current_theme);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (current_theme != default_theme) {
|
||||||
|
QString theme_uri{QStringLiteral(":%1/style.qss").arg(current_theme)};
|
||||||
|
QFile f(theme_uri);
|
||||||
|
if (!f.open(QFile::ReadOnly | QFile::Text)) {
|
||||||
|
LOG_ERROR(Frontend, "Unable to open style \"{}\", fallback to the default theme",
|
||||||
|
UISettings::values.theme.toStdString());
|
||||||
|
current_theme = default_theme;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QString theme_uri{QStringLiteral(":%1/style.qss").arg(current_theme)};
|
||||||
|
QFile f(theme_uri);
|
||||||
|
if (f.open(QFile::ReadOnly | QFile::Text)) {
|
||||||
|
QTextStream ts(&f);
|
||||||
|
qApp->setStyleSheet(ts.readAll());
|
||||||
|
setStyleSheet(ts.readAll());
|
||||||
|
} else {
|
||||||
|
LOG_ERROR(Frontend, "Unable to set style \"{}\", stylesheet file not found",
|
||||||
|
UISettings::values.theme.toStdString());
|
||||||
|
qApp->setStyleSheet({});
|
||||||
|
setStyleSheet({});
|
||||||
|
}
|
||||||
|
|
||||||
|
QIcon::setThemeName(current_theme);
|
||||||
QIcon::setThemeSearchPaths(theme_paths);
|
QIcon::setThemeSearchPaths(theme_paths);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,8 +7,8 @@
|
|||||||
namespace UISettings {
|
namespace UISettings {
|
||||||
|
|
||||||
const Themes themes{{
|
const Themes themes{{
|
||||||
{"Light", "default"},
|
{"Default", "default"},
|
||||||
{"Light Colorful", "colorful"},
|
{"Default Colorful", "colorful"},
|
||||||
{"Dark", "qdarkstyle"},
|
{"Dark", "qdarkstyle"},
|
||||||
{"Dark Colorful", "colorful_dark"},
|
{"Dark Colorful", "colorful_dark"},
|
||||||
{"Midnight Blue", "qdarkstyle_midnight_blue"},
|
{"Midnight Blue", "qdarkstyle_midnight_blue"},
|
||||||
|
Loading…
Reference in New Issue
Block a user