diff options
| author | 2018-03-31 00:46:18 -0400 | |
|---|---|---|
| committer | 2018-03-31 00:46:18 -0400 | |
| commit | b3298465cfc0586d8ca145b3ca76216fbe85e34e (patch) | |
| tree | 9a62aaa7986b9ce309a9c0197076790f283b31ae /src | |
| parent | Merge pull request #292 from bunnei/botw-progress (diff) | |
| parent | Port citra-emu/citra#3610 to yuzu (diff) | |
| download | yuzu-b3298465cfc0586d8ca145b3ca76216fbe85e34e.tar.gz yuzu-b3298465cfc0586d8ca145b3ca76216fbe85e34e.tar.xz yuzu-b3298465cfc0586d8ca145b3ca76216fbe85e34e.zip | |
Merge pull request #293 from N00byKing/drkthm
Add Dark Theme (And Theming in General + Icon Theming)
Diffstat (limited to 'src')
| -rw-r--r-- | src/yuzu/about_dialog.cpp | 2 | ||||
| -rw-r--r-- | src/yuzu/configuration/config.cpp | 2 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_general.cpp | 8 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_general.ui | 27 | ||||
| -rw-r--r-- | src/yuzu/main.cpp | 30 | ||||
| -rw-r--r-- | src/yuzu/main.h | 6 | ||||
| -rw-r--r-- | src/yuzu/ui_settings.h | 4 |
7 files changed, 79 insertions, 0 deletions
diff --git a/src/yuzu/about_dialog.cpp b/src/yuzu/about_dialog.cpp index da3429822..d6647eeea 100644 --- a/src/yuzu/about_dialog.cpp +++ b/src/yuzu/about_dialog.cpp | |||
| @@ -2,12 +2,14 @@ | |||
| 2 | // Licensed under GPLv2 or any later version | 2 | // Licensed under GPLv2 or any later version |
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include <QIcon> | ||
| 5 | #include "common/scm_rev.h" | 6 | #include "common/scm_rev.h" |
| 6 | #include "ui_aboutdialog.h" | 7 | #include "ui_aboutdialog.h" |
| 7 | #include "yuzu/about_dialog.h" | 8 | #include "yuzu/about_dialog.h" |
| 8 | 9 | ||
| 9 | AboutDialog::AboutDialog(QWidget* parent) : QDialog(parent), ui(new Ui::AboutDialog) { | 10 | AboutDialog::AboutDialog(QWidget* parent) : QDialog(parent), ui(new Ui::AboutDialog) { |
| 10 | ui->setupUi(this); | 11 | ui->setupUi(this); |
| 12 | ui->labelLogo->setPixmap(QIcon::fromTheme("yuzu").pixmap(200)); | ||
| 11 | ui->labelBuildInfo->setText(ui->labelBuildInfo->text().arg( | 13 | ui->labelBuildInfo->setText(ui->labelBuildInfo->text().arg( |
| 12 | Common::g_build_name, Common::g_scm_branch, Common::g_scm_desc)); | 14 | Common::g_build_name, Common::g_scm_branch, Common::g_scm_desc)); |
| 13 | } | 15 | } |
diff --git a/src/yuzu/configuration/config.cpp b/src/yuzu/configuration/config.cpp index 4b4216eec..8843f2078 100644 --- a/src/yuzu/configuration/config.cpp +++ b/src/yuzu/configuration/config.cpp | |||
| @@ -107,6 +107,8 @@ void Config::ReadValues() { | |||
| 107 | qt_config->endGroup(); | 107 | qt_config->endGroup(); |
| 108 | 108 | ||
| 109 | qt_config->beginGroup("UI"); | 109 | qt_config->beginGroup("UI"); |
| 110 | UISettings::values.theme = qt_config->value("theme", UISettings::themes[0].second).toString(); | ||
| 111 | |||
| 110 | qt_config->beginGroup("UILayout"); | 112 | qt_config->beginGroup("UILayout"); |
| 111 | UISettings::values.geometry = qt_config->value("geometry").toByteArray(); | 113 | UISettings::values.geometry = qt_config->value("geometry").toByteArray(); |
| 112 | UISettings::values.state = qt_config->value("state").toByteArray(); | 114 | UISettings::values.state = qt_config->value("state").toByteArray(); |
diff --git a/src/yuzu/configuration/configure_general.cpp b/src/yuzu/configuration/configure_general.cpp index 616a67f9f..2d73fc5aa 100644 --- a/src/yuzu/configuration/configure_general.cpp +++ b/src/yuzu/configuration/configure_general.cpp | |||
| @@ -13,6 +13,10 @@ ConfigureGeneral::ConfigureGeneral(QWidget* parent) | |||
| 13 | 13 | ||
| 14 | ui->setupUi(this); | 14 | ui->setupUi(this); |
| 15 | 15 | ||
| 16 | for (auto theme : UISettings::themes) { | ||
| 17 | ui->theme_combobox->addItem(theme.first, theme.second); | ||
| 18 | } | ||
| 19 | |||
| 16 | this->setConfiguration(); | 20 | this->setConfiguration(); |
| 17 | 21 | ||
| 18 | ui->use_cpu_jit->setEnabled(!Core::System::GetInstance().IsPoweredOn()); | 22 | ui->use_cpu_jit->setEnabled(!Core::System::GetInstance().IsPoweredOn()); |
| @@ -24,6 +28,7 @@ ConfigureGeneral::~ConfigureGeneral() {} | |||
| 24 | void ConfigureGeneral::setConfiguration() { | 28 | void ConfigureGeneral::setConfiguration() { |
| 25 | ui->toggle_deepscan->setChecked(UISettings::values.gamedir_deepscan); | 29 | ui->toggle_deepscan->setChecked(UISettings::values.gamedir_deepscan); |
| 26 | ui->toggle_check_exit->setChecked(UISettings::values.confirm_before_closing); | 30 | ui->toggle_check_exit->setChecked(UISettings::values.confirm_before_closing); |
| 31 | ui->theme_combobox->setCurrentIndex(ui->theme_combobox->findData(UISettings::values.theme)); | ||
| 27 | ui->use_cpu_jit->setChecked(Settings::values.use_cpu_jit); | 32 | ui->use_cpu_jit->setChecked(Settings::values.use_cpu_jit); |
| 28 | ui->use_docked_mode->setChecked(Settings::values.use_docked_mode); | 33 | ui->use_docked_mode->setChecked(Settings::values.use_docked_mode); |
| 29 | } | 34 | } |
| @@ -31,6 +36,9 @@ void ConfigureGeneral::setConfiguration() { | |||
| 31 | void ConfigureGeneral::applyConfiguration() { | 36 | void ConfigureGeneral::applyConfiguration() { |
| 32 | UISettings::values.gamedir_deepscan = ui->toggle_deepscan->isChecked(); | 37 | UISettings::values.gamedir_deepscan = ui->toggle_deepscan->isChecked(); |
| 33 | UISettings::values.confirm_before_closing = ui->toggle_check_exit->isChecked(); | 38 | UISettings::values.confirm_before_closing = ui->toggle_check_exit->isChecked(); |
| 39 | UISettings::values.theme = | ||
| 40 | ui->theme_combobox->itemData(ui->theme_combobox->currentIndex()).toString(); | ||
| 41 | |||
| 34 | Settings::values.use_cpu_jit = ui->use_cpu_jit->isChecked(); | 42 | Settings::values.use_cpu_jit = ui->use_cpu_jit->isChecked(); |
| 35 | Settings::values.use_docked_mode = ui->use_docked_mode->isChecked(); | 43 | Settings::values.use_docked_mode = ui->use_docked_mode->isChecked(); |
| 36 | Settings::Apply(); | 44 | Settings::Apply(); |
diff --git a/src/yuzu/configuration/configure_general.ui b/src/yuzu/configuration/configure_general.ui index 5ff68f079..1775c4d40 100644 --- a/src/yuzu/configuration/configure_general.ui +++ b/src/yuzu/configuration/configure_general.ui | |||
| @@ -84,6 +84,33 @@ | |||
| 84 | </widget> | 84 | </widget> |
| 85 | </item> | 85 | </item> |
| 86 | <item> | 86 | <item> |
| 87 | <widget class="QGroupBox" name="theme_group_box"> | ||
| 88 | <property name="title"> | ||
| 89 | <string>Theme</string> | ||
| 90 | </property> | ||
| 91 | <layout class="QHBoxLayout" name="theme_qhbox_layout"> | ||
| 92 | <item> | ||
| 93 | <layout class="QVBoxLayout" name="theme_qvbox_layout"> | ||
| 94 | <item> | ||
| 95 | <layout class="QHBoxLayout" name="theme_qhbox_layout_2"> | ||
| 96 | <item> | ||
| 97 | <widget class="QLabel" name="theme_label"> | ||
| 98 | <property name="text"> | ||
| 99 | <string>Theme:</string> | ||
| 100 | </property> | ||
| 101 | </widget> | ||
| 102 | </item> | ||
| 103 | <item> | ||
| 104 | <widget class="QComboBox" name="theme_combobox"/> | ||
| 105 | </item> | ||
| 106 | </layout> | ||
| 107 | </item> | ||
| 108 | </layout> | ||
| 109 | </item> | ||
| 110 | </layout> | ||
| 111 | </widget> | ||
| 112 | </item> | ||
| 113 | <item> | ||
| 87 | <widget class="QGroupBox" name="HotKeysGroupBox"> | 114 | <widget class="QGroupBox" name="HotKeysGroupBox"> |
| 88 | <property name="title"> | 115 | <property name="title"> |
| 89 | <string>Hotkeys</string> | 116 | <string>Hotkeys</string> |
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index bd323870b..265502c2a 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp | |||
| @@ -78,6 +78,9 @@ GMainWindow::GMainWindow() : config(new Config()), emu_thread(nullptr) { | |||
| 78 | ui.setupUi(this); | 78 | ui.setupUi(this); |
| 79 | statusBar()->hide(); | 79 | statusBar()->hide(); |
| 80 | 80 | ||
| 81 | default_theme_paths = QIcon::themeSearchPaths(); | ||
| 82 | UpdateUITheme(); | ||
| 83 | |||
| 81 | InitializeWidgets(); | 84 | InitializeWidgets(); |
| 82 | InitializeDebugWidgets(); | 85 | InitializeDebugWidgets(); |
| 83 | InitializeRecentFileMenuActions(); | 86 | InitializeRecentFileMenuActions(); |
| @@ -653,6 +656,7 @@ void GMainWindow::OnConfigure() { | |||
| 653 | auto result = configureDialog.exec(); | 656 | auto result = configureDialog.exec(); |
| 654 | if (result == QDialog::Accepted) { | 657 | if (result == QDialog::Accepted) { |
| 655 | configureDialog.applyConfiguration(); | 658 | configureDialog.applyConfiguration(); |
| 659 | UpdateUITheme(); | ||
| 656 | config->Save(); | 660 | config->Save(); |
| 657 | } | 661 | } |
| 658 | } | 662 | } |
| @@ -833,6 +837,32 @@ void GMainWindow::filterBarSetChecked(bool state) { | |||
| 833 | emit(OnToggleFilterBar()); | 837 | emit(OnToggleFilterBar()); |
| 834 | } | 838 | } |
| 835 | 839 | ||
| 840 | void GMainWindow::UpdateUITheme() { | ||
| 841 | QStringList theme_paths(default_theme_paths); | ||
| 842 | if (UISettings::values.theme != UISettings::themes[0].second && | ||
| 843 | !UISettings::values.theme.isEmpty()) { | ||
| 844 | QString theme_uri(":" + UISettings::values.theme + "/style.qss"); | ||
| 845 | QFile f(theme_uri); | ||
| 846 | if (!f.exists()) { | ||
| 847 | LOG_ERROR(Frontend, "Unable to set style, stylesheet file not found"); | ||
| 848 | } else { | ||
| 849 | f.open(QFile::ReadOnly | QFile::Text); | ||
| 850 | QTextStream ts(&f); | ||
| 851 | qApp->setStyleSheet(ts.readAll()); | ||
| 852 | GMainWindow::setStyleSheet(ts.readAll()); | ||
| 853 | } | ||
| 854 | theme_paths.append(QStringList{":/icons/default", ":/icons/" + UISettings::values.theme}); | ||
| 855 | QIcon::setThemeName(":/icons/" + UISettings::values.theme); | ||
| 856 | } else { | ||
| 857 | qApp->setStyleSheet(""); | ||
| 858 | GMainWindow::setStyleSheet(""); | ||
| 859 | theme_paths.append(QStringList{":/icons/default"}); | ||
| 860 | QIcon::setThemeName(":/icons/default"); | ||
| 861 | } | ||
| 862 | QIcon::setThemeSearchPaths(theme_paths); | ||
| 863 | emit UpdateThemedIcons(); | ||
| 864 | } | ||
| 865 | |||
| 836 | #ifdef main | 866 | #ifdef main |
| 837 | #undef main | 867 | #undef main |
| 838 | #endif | 868 | #endif |
diff --git a/src/yuzu/main.h b/src/yuzu/main.h index 592ab7d9e..20ff65314 100644 --- a/src/yuzu/main.h +++ b/src/yuzu/main.h | |||
| @@ -64,6 +64,9 @@ signals: | |||
| 64 | */ | 64 | */ |
| 65 | void EmulationStopping(); | 65 | void EmulationStopping(); |
| 66 | 66 | ||
| 67 | // Signal that tells widgets to update icons to use the current theme | ||
| 68 | void UpdateThemedIcons(); | ||
| 69 | |||
| 67 | private: | 70 | private: |
| 68 | void InitializeWidgets(); | 71 | void InitializeWidgets(); |
| 69 | void InitializeDebugWidgets(); | 72 | void InitializeDebugWidgets(); |
| @@ -166,6 +169,9 @@ private: | |||
| 166 | 169 | ||
| 167 | QAction* actions_recent_files[max_recent_files_item]; | 170 | QAction* actions_recent_files[max_recent_files_item]; |
| 168 | 171 | ||
| 172 | // stores default icon theme search paths for the platform | ||
| 173 | QStringList default_theme_paths; | ||
| 174 | |||
| 169 | protected: | 175 | protected: |
| 170 | void dropEvent(QDropEvent* event) override; | 176 | void dropEvent(QDropEvent* event) override; |
| 171 | void dragEnterEvent(QDragEnterEvent* event) override; | 177 | void dragEnterEvent(QDragEnterEvent* event) override; |
diff --git a/src/yuzu/ui_settings.h b/src/yuzu/ui_settings.h index 9036ce2c1..8e215a002 100644 --- a/src/yuzu/ui_settings.h +++ b/src/yuzu/ui_settings.h | |||
| @@ -15,6 +15,10 @@ namespace UISettings { | |||
| 15 | using ContextualShortcut = std::pair<QString, int>; | 15 | using ContextualShortcut = std::pair<QString, int>; |
| 16 | using Shortcut = std::pair<QString, ContextualShortcut>; | 16 | using Shortcut = std::pair<QString, ContextualShortcut>; |
| 17 | 17 | ||
| 18 | static const std::array<std::pair<QString, QString>, 2> themes = { | ||
| 19 | {std::make_pair(QString("Default"), QString("default")), | ||
| 20 | std::make_pair(QString("Dark"), QString("qdarkstyle"))}}; | ||
| 21 | |||
| 18 | struct Values { | 22 | struct Values { |
| 19 | QByteArray geometry; | 23 | QByteArray geometry; |
| 20 | QByteArray state; | 24 | QByteArray state; |