yuzu-emu
/
yuzu-mainline
Archived
1
0
Fork 0

Merge pull request #293 from N00byKing/drkthm

Add Dark Theme (And Theming in General + Icon Theming)
This commit is contained in:
bunnei 2018-03-31 00:46:18 -04:00 committed by GitHub
commit b3298465cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
57 changed files with 1428 additions and 5 deletions

View File

@ -1,5 +0,0 @@
<RCC>
<qresource prefix="icons">
<file>yuzu.png</file>
</qresource>
</RCC>

BIN
dist/icons/yuzu.png vendored

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.5 KiB

11
dist/qt_themes/default/default.qrc vendored Normal file
View File

@ -0,0 +1,11 @@
<RCC>
<qresource prefix="icons/default">
<file alias="index.theme">icons/index.theme</file>
<file alias="16x16/checked.png">icons/16x16/checked.png</file>
<file alias="16x16/failed.png">icons/16x16/failed.png</file>
<file alias="256x256/yuzu.png">icons/256x256/yuzu.png</file>
</qresource>
</RCC>

Binary file not shown.

After

Width:  |  Height:  |  Size: 451 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 428 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.0 KiB

View File

@ -0,0 +1,10 @@
[Icon Theme]
Name=default
Comment=default theme
Directories=16x16,256x256
[16x16]
Size=16
[256x256]
Size=256

View File

@ -0,0 +1,11 @@
[Icon Theme]
Name=qdarkstyle
Comment=dark theme
Inherits=default
Directories=16x16,256x256
[16x16]
Size=16
[256x256]
Size=256

Binary file not shown.

After

Width:  |  Height:  |  Size: 220 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 172 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 228 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 187 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 147 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 160 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 150 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 166 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 492 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 491 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 252 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 493 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 492 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 249 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 464 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 464 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 240 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 598 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 598 B

BIN
dist/qt_themes/qdarkstyle/rc/close.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 586 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 165 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 166 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 166 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 166 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 940 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 972 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 846 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 728 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 760 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 646 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 160 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 160 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 129 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 224 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 182 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 239 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 195 B

BIN
dist/qt_themes/qdarkstyle/rc/undock.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 578 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 158 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 159 B

49
dist/qt_themes/qdarkstyle/style.qrc vendored Normal file
View File

@ -0,0 +1,49 @@
<RCC>
<qresource prefix="icons/qdarkstyle">
<file alias="index.theme">icons/index.theme</file>
</qresource>
<qresource prefix="qss_icons">
<file>rc/up_arrow_disabled.png</file>
<file>rc/Hmovetoolbar.png</file>
<file>rc/stylesheet-branch-end.png</file>
<file>rc/branch_closed-on.png</file>
<file>rc/stylesheet-vline.png</file>
<file>rc/branch_closed.png</file>
<file>rc/branch_open-on.png</file>
<file>rc/transparent.png</file>
<file>rc/right_arrow_disabled.png</file>
<file>rc/sizegrip.png</file>
<file>rc/close.png</file>
<file>rc/close-hover.png</file>
<file>rc/close-pressed.png</file>
<file>rc/down_arrow.png</file>
<file>rc/Vmovetoolbar.png</file>
<file>rc/left_arrow.png</file>
<file>rc/stylesheet-branch-more.png</file>
<file>rc/up_arrow.png</file>
<file>rc/right_arrow.png</file>
<file>rc/left_arrow_disabled.png</file>
<file>rc/Hsepartoolbar.png</file>
<file>rc/branch_open.png</file>
<file>rc/Vsepartoolbar.png</file>
<file>rc/down_arrow_disabled.png</file>
<file>rc/undock.png</file>
<file>rc/checkbox_checked_disabled.png</file>
<file>rc/checkbox_checked_focus.png</file>
<file>rc/checkbox_checked.png</file>
<file>rc/checkbox_indeterminate.png</file>
<file>rc/checkbox_indeterminate_focus.png</file>
<file>rc/checkbox_unchecked_disabled.png</file>
<file>rc/checkbox_unchecked_focus.png</file>
<file>rc/checkbox_unchecked.png</file>
<file>rc/radio_checked_disabled.png</file>
<file>rc/radio_checked_focus.png</file>
<file>rc/radio_checked.png</file>
<file>rc/radio_unchecked_disabled.png</file>
<file>rc/radio_unchecked_focus.png</file>
<file>rc/radio_unchecked.png</file>
</qresource>
<qresource prefix="qdarkstyle">
<file>style.qss</file>
</qresource>
</RCC>

1268
dist/qt_themes/qdarkstyle/style.qss vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@ -2,12 +2,14 @@
// Licensed under GPLv2 or any later version // Licensed under GPLv2 or any later version
// Refer to the license.txt file included. // Refer to the license.txt file included.
#include <QIcon>
#include "common/scm_rev.h" #include "common/scm_rev.h"
#include "ui_aboutdialog.h" #include "ui_aboutdialog.h"
#include "yuzu/about_dialog.h" #include "yuzu/about_dialog.h"
AboutDialog::AboutDialog(QWidget* parent) : QDialog(parent), ui(new Ui::AboutDialog) { AboutDialog::AboutDialog(QWidget* parent) : QDialog(parent), ui(new Ui::AboutDialog) {
ui->setupUi(this); ui->setupUi(this);
ui->labelLogo->setPixmap(QIcon::fromTheme("yuzu").pixmap(200));
ui->labelBuildInfo->setText(ui->labelBuildInfo->text().arg( ui->labelBuildInfo->setText(ui->labelBuildInfo->text().arg(
Common::g_build_name, Common::g_scm_branch, Common::g_scm_desc)); Common::g_build_name, Common::g_scm_branch, Common::g_scm_desc));
} }

View File

@ -107,6 +107,8 @@ void Config::ReadValues() {
qt_config->endGroup(); qt_config->endGroup();
qt_config->beginGroup("UI"); qt_config->beginGroup("UI");
UISettings::values.theme = qt_config->value("theme", UISettings::themes[0].second).toString();
qt_config->beginGroup("UILayout"); qt_config->beginGroup("UILayout");
UISettings::values.geometry = qt_config->value("geometry").toByteArray(); UISettings::values.geometry = qt_config->value("geometry").toByteArray();
UISettings::values.state = qt_config->value("state").toByteArray(); UISettings::values.state = qt_config->value("state").toByteArray();

View File

@ -13,6 +13,10 @@ ConfigureGeneral::ConfigureGeneral(QWidget* parent)
ui->setupUi(this); ui->setupUi(this);
for (auto theme : UISettings::themes) {
ui->theme_combobox->addItem(theme.first, theme.second);
}
this->setConfiguration(); this->setConfiguration();
ui->use_cpu_jit->setEnabled(!Core::System::GetInstance().IsPoweredOn()); ui->use_cpu_jit->setEnabled(!Core::System::GetInstance().IsPoweredOn());
@ -24,6 +28,7 @@ ConfigureGeneral::~ConfigureGeneral() {}
void ConfigureGeneral::setConfiguration() { void ConfigureGeneral::setConfiguration() {
ui->toggle_deepscan->setChecked(UISettings::values.gamedir_deepscan); ui->toggle_deepscan->setChecked(UISettings::values.gamedir_deepscan);
ui->toggle_check_exit->setChecked(UISettings::values.confirm_before_closing); ui->toggle_check_exit->setChecked(UISettings::values.confirm_before_closing);
ui->theme_combobox->setCurrentIndex(ui->theme_combobox->findData(UISettings::values.theme));
ui->use_cpu_jit->setChecked(Settings::values.use_cpu_jit); ui->use_cpu_jit->setChecked(Settings::values.use_cpu_jit);
ui->use_docked_mode->setChecked(Settings::values.use_docked_mode); ui->use_docked_mode->setChecked(Settings::values.use_docked_mode);
} }
@ -31,6 +36,9 @@ void ConfigureGeneral::setConfiguration() {
void ConfigureGeneral::applyConfiguration() { void ConfigureGeneral::applyConfiguration() {
UISettings::values.gamedir_deepscan = ui->toggle_deepscan->isChecked(); UISettings::values.gamedir_deepscan = ui->toggle_deepscan->isChecked();
UISettings::values.confirm_before_closing = ui->toggle_check_exit->isChecked(); UISettings::values.confirm_before_closing = ui->toggle_check_exit->isChecked();
UISettings::values.theme =
ui->theme_combobox->itemData(ui->theme_combobox->currentIndex()).toString();
Settings::values.use_cpu_jit = ui->use_cpu_jit->isChecked(); Settings::values.use_cpu_jit = ui->use_cpu_jit->isChecked();
Settings::values.use_docked_mode = ui->use_docked_mode->isChecked(); Settings::values.use_docked_mode = ui->use_docked_mode->isChecked();
Settings::Apply(); Settings::Apply();

View File

@ -83,6 +83,33 @@
</layout> </layout>
</widget> </widget>
</item> </item>
<item>
<widget class="QGroupBox" name="theme_group_box">
<property name="title">
<string>Theme</string>
</property>
<layout class="QHBoxLayout" name="theme_qhbox_layout">
<item>
<layout class="QVBoxLayout" name="theme_qvbox_layout">
<item>
<layout class="QHBoxLayout" name="theme_qhbox_layout_2">
<item>
<widget class="QLabel" name="theme_label">
<property name="text">
<string>Theme:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="theme_combobox"/>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item> <item>
<widget class="QGroupBox" name="HotKeysGroupBox"> <widget class="QGroupBox" name="HotKeysGroupBox">
<property name="title"> <property name="title">

View File

@ -78,6 +78,9 @@ GMainWindow::GMainWindow() : config(new Config()), emu_thread(nullptr) {
ui.setupUi(this); ui.setupUi(this);
statusBar()->hide(); statusBar()->hide();
default_theme_paths = QIcon::themeSearchPaths();
UpdateUITheme();
InitializeWidgets(); InitializeWidgets();
InitializeDebugWidgets(); InitializeDebugWidgets();
InitializeRecentFileMenuActions(); InitializeRecentFileMenuActions();
@ -653,6 +656,7 @@ void GMainWindow::OnConfigure() {
auto result = configureDialog.exec(); auto result = configureDialog.exec();
if (result == QDialog::Accepted) { if (result == QDialog::Accepted) {
configureDialog.applyConfiguration(); configureDialog.applyConfiguration();
UpdateUITheme();
config->Save(); config->Save();
} }
} }
@ -833,6 +837,32 @@ void GMainWindow::filterBarSetChecked(bool state) {
emit(OnToggleFilterBar()); 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);
emit UpdateThemedIcons();
}
#ifdef main #ifdef main
#undef main #undef main
#endif #endif

View File

@ -64,6 +64,9 @@ signals:
*/ */
void EmulationStopping(); void EmulationStopping();
// Signal that tells widgets to update icons to use the current theme
void UpdateThemedIcons();
private: private:
void InitializeWidgets(); void InitializeWidgets();
void InitializeDebugWidgets(); void InitializeDebugWidgets();
@ -166,6 +169,9 @@ private:
QAction* actions_recent_files[max_recent_files_item]; QAction* actions_recent_files[max_recent_files_item];
// stores default icon theme search paths for the platform
QStringList default_theme_paths;
protected: protected:
void dropEvent(QDropEvent* event) override; void dropEvent(QDropEvent* event) override;
void dragEnterEvent(QDragEnterEvent* event) override; void dragEnterEvent(QDragEnterEvent* event) override;

View File

@ -15,6 +15,10 @@ namespace UISettings {
using ContextualShortcut = std::pair<QString, int>; using ContextualShortcut = std::pair<QString, int>;
using Shortcut = std::pair<QString, ContextualShortcut>; using Shortcut = std::pair<QString, ContextualShortcut>;
static const std::array<std::pair<QString, QString>, 2> themes = {
{std::make_pair(QString("Default"), QString("default")),
std::make_pair(QString("Dark"), QString("qdarkstyle"))}};
struct Values { struct Values {
QByteArray geometry; QByteArray geometry;
QByteArray state; QByteArray state;