From 78e974ba68aac7cc3d47b19acba6d2b1dd97bb8f Mon Sep 17 00:00:00 2001 From: N00byKing Date: Fri, 30 Mar 2018 11:50:10 +0200 Subject: Add Dark theme, Icon theming configure_general.ui: Add UI Option for Themes config.cpp: Save Theme Settings --- src/yuzu/main.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'src/yuzu/main.cpp') diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index bd323870b..53ac1fd6a 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -95,6 +95,9 @@ GMainWindow::GMainWindow() : config(new Config()), emu_thread(nullptr) { game_list->PopulateAsync(UISettings::values.gamedir, UISettings::values.gamedir_deepscan); + default_theme_paths = QIcon::themeSearchPaths(); + UpdateUITheme(); + // Show one-time "callout" messages to the user ShowCallouts(); @@ -653,6 +656,7 @@ void GMainWindow::OnConfigure() { auto result = configureDialog.exec(); if (result == QDialog::Accepted) { configureDialog.applyConfiguration(); + UpdateUITheme(); config->Save(); } } @@ -833,6 +837,31 @@ void GMainWindow::filterBarSetChecked(bool state) { emit(OnToggleFilterBar()); } +void GMainWindow::UpdateUITheme() { + QStringList theme_paths(default_theme_paths); + if (UISettings::values.theme != UISettings::themes[0].second && + !UISettings::values.theme.isEmpty()) { + QString theme_uri(":" + UISettings::values.theme + "/style.qss"); + QFile f(theme_uri); + if (!f.exists()) { + LOG_ERROR(Frontend, "Unable to set style, stylesheet file not found"); + } else { + f.open(QFile::ReadOnly | QFile::Text); + QTextStream ts(&f); + qApp->setStyleSheet(ts.readAll()); + GMainWindow::setStyleSheet(ts.readAll()); + } + theme_paths.append(QStringList{":/icons/default", ":/icons/" + UISettings::values.theme}); + QIcon::setThemeName(":/icons/" + UISettings::values.theme); + } else { + qApp->setStyleSheet(""); + GMainWindow::setStyleSheet(""); + theme_paths.append(QStringList{":/icons/default"}); + QIcon::setThemeName(":/icons/default"); + } + QIcon::setThemeSearchPaths(theme_paths); +} + #ifdef main #undef main #endif -- cgit v1.2.3 From 1b7dc84132b60ac08a062f618f4a3b075a250104 Mon Sep 17 00:00:00 2001 From: N00byKing Date: Fri, 30 Mar 2018 17:38:34 +0200 Subject: Port citra-emu/citra#3610 to yuzu --- src/yuzu/main.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/yuzu/main.cpp') diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index 53ac1fd6a..265502c2a 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -78,6 +78,9 @@ GMainWindow::GMainWindow() : config(new Config()), emu_thread(nullptr) { ui.setupUi(this); statusBar()->hide(); + default_theme_paths = QIcon::themeSearchPaths(); + UpdateUITheme(); + InitializeWidgets(); InitializeDebugWidgets(); InitializeRecentFileMenuActions(); @@ -95,9 +98,6 @@ GMainWindow::GMainWindow() : config(new Config()), emu_thread(nullptr) { game_list->PopulateAsync(UISettings::values.gamedir, UISettings::values.gamedir_deepscan); - default_theme_paths = QIcon::themeSearchPaths(); - UpdateUITheme(); - // Show one-time "callout" messages to the user ShowCallouts(); @@ -860,6 +860,7 @@ void GMainWindow::UpdateUITheme() { QIcon::setThemeName(":/icons/default"); } QIcon::setThemeSearchPaths(theme_paths); + emit UpdateThemedIcons(); } #ifdef main -- cgit v1.2.3