summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Romain Failliot2021-11-13 22:14:30 -0500
committerGravatar Romain Failliot2021-11-14 08:52:55 -0500
commit2e5866147eb24545e597d86f4e6621c2f2c63165 (patch)
treec1ff4011bf80c475a5f23b8d659b4aa5dcbdaafc
parentMerge pull request #7272 from behunin/the-courteous-logger (diff)
downloadyuzu-2e5866147eb24545e597d86f4e6621c2f2c63165.tar.gz
yuzu-2e5866147eb24545e597d86f4e6621c2f2c63165.tar.xz
yuzu-2e5866147eb24545e597d86f4e6621c2f2c63165.zip
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.
-rw-r--r--src/yuzu/main.cpp48
-rw-r--r--src/yuzu/uisettings.cpp4
2 files changed, 27 insertions, 25 deletions
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp
index 4e5552d2a..cfda60997 100644
--- a/src/yuzu/main.cpp
+++ b/src/yuzu/main.cpp
@@ -3381,36 +3381,38 @@ void GMainWindow::filterBarSetChecked(bool state) {
3381} 3381}
3382 3382
3383void GMainWindow::UpdateUITheme() { 3383void GMainWindow::UpdateUITheme() {
3384 const QString default_icons = QStringLiteral("default"); 3384 const QString default_theme = QStringLiteral("default");
3385 const QString& current_theme = UISettings::values.theme; 3385 QString current_theme = UISettings::values.theme;
3386 const bool is_default_theme = current_theme == QString::fromUtf8(UISettings::themes[0].second);
3387 QStringList theme_paths(default_theme_paths); 3386 QStringList theme_paths(default_theme_paths);
3388 3387
3389 if (is_default_theme || current_theme.isEmpty()) { 3388 if (current_theme.isEmpty()) {
3390 const QString theme_uri(QStringLiteral(":default/style.qss")); 3389 current_theme = default_theme;
3390 }
3391
3392 if (current_theme != default_theme) {
3393 QString theme_uri{QStringLiteral(":%1/style.qss").arg(current_theme)};
3391 QFile f(theme_uri); 3394 QFile f(theme_uri);
3392 if (f.open(QFile::ReadOnly | QFile::Text)) { 3395 if (!f.open(QFile::ReadOnly | QFile::Text)) {
3393 QTextStream ts(&f); 3396 LOG_ERROR(Frontend, "Unable to open style \"{}\", fallback to the default theme",
3394 qApp->setStyleSheet(ts.readAll()); 3397 UISettings::values.theme.toStdString());
3395 setStyleSheet(ts.readAll()); 3398 current_theme = default_theme;
3396 } else {
3397 qApp->setStyleSheet({});
3398 setStyleSheet({});
3399 } 3399 }
3400 QIcon::setThemeName(default_icons); 3400 }
3401
3402 QString theme_uri{QStringLiteral(":%1/style.qss").arg(current_theme)};
3403 QFile f(theme_uri);
3404 if (f.open(QFile::ReadOnly | QFile::Text)) {
3405 QTextStream ts(&f);
3406 qApp->setStyleSheet(ts.readAll());
3407 setStyleSheet(ts.readAll());
3401 } else { 3408 } else {
3402 const QString theme_uri(QLatin1Char{':'} + current_theme + QStringLiteral("/style.qss")); 3409 LOG_ERROR(Frontend, "Unable to set style \"{}\", stylesheet file not found",
3403 QFile f(theme_uri); 3410 UISettings::values.theme.toStdString());
3404 if (f.open(QFile::ReadOnly | QFile::Text)) { 3411 qApp->setStyleSheet({});
3405 QTextStream ts(&f); 3412 setStyleSheet({});
3406 qApp->setStyleSheet(ts.readAll());
3407 setStyleSheet(ts.readAll());
3408 } else {
3409 LOG_ERROR(Frontend, "Unable to set style, stylesheet file not found");
3410 }
3411 QIcon::setThemeName(current_theme);
3412 } 3413 }
3413 3414
3415 QIcon::setThemeName(current_theme);
3414 QIcon::setThemeSearchPaths(theme_paths); 3416 QIcon::setThemeSearchPaths(theme_paths);
3415} 3417}
3416 3418
diff --git a/src/yuzu/uisettings.cpp b/src/yuzu/uisettings.cpp
index 37499fc85..21683576c 100644
--- a/src/yuzu/uisettings.cpp
+++ b/src/yuzu/uisettings.cpp
@@ -7,8 +7,8 @@
7namespace UISettings { 7namespace UISettings {
8 8
9const Themes themes{{ 9const Themes themes{{
10 {"Light", "default"}, 10 {"Default", "default"},
11 {"Light Colorful", "colorful"}, 11 {"Default Colorful", "colorful"},
12 {"Dark", "qdarkstyle"}, 12 {"Dark", "qdarkstyle"},
13 {"Dark Colorful", "colorful_dark"}, 13 {"Dark Colorful", "colorful_dark"},
14 {"Midnight Blue", "qdarkstyle_midnight_blue"}, 14 {"Midnight Blue", "qdarkstyle_midnight_blue"},