creates new light and dark themes (#2)

adds new light theme and dark theme 
Co-authored-by: RedDevilus <24227051+RedDevilus@users.noreply.github.com>
This commit is contained in:
Mrlinkwii 2020-09-24 14:46:04 +01:00 committed by GitHub
parent 729ba18041
commit b78277ae04
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 84 additions and 7 deletions

View file

@ -10,6 +10,7 @@
#include <QMessageBox>
#include <QTableWidget>
#include <QStatusBar>
#include <QStyleFactory>
#include "emuwindow.hpp"
#include "settingswindow.hpp"
@ -800,6 +801,55 @@ void EmuWindow::show_render_view()
void EmuWindow::update_status()
{
CPU_MODE mode;
if (Settings::instance().d_theme) //Dark theme colour change
{
qApp->setStyle(QStyleFactory::create("Fusion"));
QPalette darkPalette;
QColor darkColor = QColor(0,70,70);
QColor disabledColor = QColor(200,45,69);
darkPalette.setColor(QPalette::Window, darkColor);
darkPalette.setColor(QPalette::WindowText, Qt::white);
darkPalette.setColor(QPalette::Base, QColor(60,60,60));
darkPalette.setColor(QPalette::AlternateBase, darkColor);
darkPalette.setColor(QPalette::ToolTipBase, Qt::white);
darkPalette.setColor(QPalette::ToolTipText, Qt::white);
darkPalette.setColor(QPalette::Text, Qt::white);
darkPalette.setColor(QPalette::Disabled, QPalette::Text, disabledColor);
darkPalette.setColor(QPalette::Button, darkColor);
darkPalette.setColor(QPalette::ButtonText, Qt::white);
darkPalette.setColor(QPalette::Disabled, QPalette::ButtonText, disabledColor);
darkPalette.setColor(QPalette::BrightText, Qt::red);
darkPalette.setColor(QPalette::Link, QColor(200,45,69));
darkPalette.setColor(QPalette::Highlight, QColor(200,45,69));
darkPalette.setColor(QPalette::HighlightedText, Qt::black);
darkPalette.setColor(QPalette::Disabled, QPalette::HighlightedText, disabledColor);
qApp->setPalette(darkPalette);
qApp->setStyleSheet("QToolTip { color: #ffffff; background-color: #2a82da; border: 1px solid white; }");
}
if (Settings::instance().l_theme)// Change to light theme
{
qApp->setStyle(QStyleFactory::create("Fusion"));
QPalette lightPalette;
QColor lightColor = QColor(255,255,255);
qApp->setPalette(lightPalette);
lightPalette.setColor(QPalette::Window, lightColor);
lightPalette.setColor(QPalette::WindowText, Qt::black);
lightPalette.setColor(QPalette::Base, QColor(255,255,255));
lightPalette.setColor(QPalette::AlternateBase, lightColor);
lightPalette.setColor(QPalette::ToolTipBase, Qt::white);
lightPalette.setColor(QPalette::ToolTipText, Qt::black);
lightPalette.setColor(QPalette::Text, Qt::black);
lightPalette.setColor(QPalette::Button, lightColor);
lightPalette.setColor(QPalette::ButtonText, Qt::black);
lightPalette.setColor(QPalette::BrightText, Qt::black);
lightPalette.setColor(QPalette::Link, QColor(98, 102, 102));
lightPalette.setColor(QPalette::Highlight, QColor(214, 214, 214));
qApp->setPalette(lightPalette);
qApp->setStyleSheet("");
}
if (Settings::instance().ee_jit_enabled)
{
mode = CPU_MODE::JIT;

View file

@ -34,12 +34,12 @@ void Settings::reset()
vu1_jit_enabled = qsettings().value("vu1_jit_enabled", true).toBool();
last_used_directory = qsettings().value("last_used_dir", QDir::homePath()).toString();
screenshot_directory = qsettings().value("screenshot_directory", QDir::homePath()).toString();
rom_directories_to_add = QStringList();
rom_directories_to_remove = QStringList();
memcard_path = qsettings().value("memcard_path", "").toString();
scaling_factor = qsettings().value("ui_scaling_factor", 1).toInt();
d_theme = qsettings().value("dark theme", true).toBool();
l_theme = qsettings().value("light theme", false).toBool();
emit reload();
}
@ -74,6 +74,8 @@ void Settings::save()
qsettings().setValue("screenshot_directory", screenshot_directory);
qsettings().setValue("memcard_path", memcard_path);
qsettings().setValue("ui_scaling_factor", scaling_factor);
qsettings().setValue("dark theme", d_theme);
qsettings().setValue("light theme", l_theme);
qsettings().sync();
reset();
}

View file

@ -33,6 +33,8 @@ class Settings final : public QObject
bool vu0_jit_enabled;
bool vu1_jit_enabled;
bool ee_jit_enabled;
bool d_theme;
bool l_theme;
QString memcard_path;
@ -44,7 +46,6 @@ class Settings final : public QObject
void set_bios_path(const QString& path);
void set_screenshot_directory(const QString& directory);
void set_memcard_path(const QString& path);
void remove_rom_directory(const QString& directory);
void clear_rom_paths();
private:

View file

@ -24,12 +24,18 @@ GeneralTab::GeneralTab(QWidget* parent)
QRadioButton* ee_interpreter_checkbox = new QRadioButton(tr("Interpreter"));
QRadioButton* vu0_interpreter_checkbox = new QRadioButton(tr("Interpreter"));
QRadioButton* vu1_interpreter_checkbox = new QRadioButton(tr("Interpreter"));
QRadioButton* light_theme_checkbox = new QRadioButton(tr("light theme"));
QRadioButton* darktheme_checkbox = new QRadioButton(tr("dark theme"));
bool ee_jit = Settings::instance().ee_jit_enabled;
bool vu0_jit = Settings::instance().vu0_jit_enabled;
bool vu1_jit = Settings::instance().vu1_jit_enabled;
bool l_theme = Settings::instance().l_theme;
bool d_theme = Settings::instance().d_theme;
light_theme_checkbox->setChecked(l_theme);
darktheme_checkbox->setChecked(d_theme);
ee_jit_checkbox->setChecked(ee_jit);
ee_interpreter_checkbox->setChecked(!ee_jit);
vu0_jit_checkbox->setChecked(vu0_jit);
@ -60,17 +66,30 @@ GeneralTab::GeneralTab(QWidget* parent)
connect(vu1_interpreter_checkbox, &QRadioButton::clicked, this, [=]() {
Settings::instance().vu1_jit_enabled = false;
});
connect(light_theme_checkbox, &QRadioButton::clicked, this, [=]() {
Settings::instance().l_theme = true;
Settings::instance().d_theme = false;
});
connect(darktheme_checkbox, &QRadioButton::clicked, this, [=]() {
Settings::instance().d_theme = true;
Settings::instance().l_theme = false;
});
connect(&Settings::instance(), &Settings::reload, this, [=]() {
bool ee_jit_enabled = Settings::instance().ee_jit_enabled;
bool vu0_jit_enabled = Settings::instance().vu0_jit_enabled;
bool vu1_jit_enabled = Settings::instance().vu1_jit_enabled;
bool l_theme =Settings::instance().l_theme;
bool d_theme =Settings::instance().d_theme;
ee_jit_checkbox->setChecked(ee_jit_enabled);
ee_interpreter_checkbox->setChecked(!ee_jit_enabled);
vu0_jit_checkbox->setChecked(vu0_jit_enabled);
vu0_interpreter_checkbox->setChecked(!vu0_jit_enabled);
vu1_jit_checkbox->setChecked(vu1_jit_enabled);
vu1_interpreter_checkbox->setChecked(!vu1_jit_enabled);
light_theme_checkbox->setChecked(l_theme);
darktheme_checkbox->setChecked(d_theme);
});
@ -78,6 +97,13 @@ GeneralTab::GeneralTab(QWidget* parent)
vu0_layout->addWidget(vu0_jit_checkbox);
vu0_layout->addWidget(vu0_interpreter_checkbox);
QVBoxLayout* theme_layout = new QVBoxLayout;
theme_layout->addWidget(light_theme_checkbox);
theme_layout->addWidget(darktheme_checkbox);
QGroupBox* theme_group = new QGroupBox(tr("Theming"));
theme_group->setLayout(theme_layout);
QGroupBox* vu0_groupbox = new QGroupBox(tr("VU0"));
vu0_groupbox->setLayout(vu0_layout);
@ -93,17 +119,16 @@ GeneralTab::GeneralTab(QWidget* parent)
ee_layout->addWidget(ee_interpreter_checkbox);
QGroupBox* ee_groupbox = new QGroupBox(tr("EE"));
ee_groupbox->setLayout(ee_layout);
ee_groupbox->setLayout(ee_layout);
QVBoxLayout* layout = new QVBoxLayout;
layout->addWidget(ee_groupbox);
layout->addWidget(vu0_groupbox);
layout->addWidget(vu1_groupbox);
layout->addWidget(theme_group);
layout->addStretch(1);
setLayout(layout);
setMinimumWidth(400);
}
@ -246,7 +271,6 @@ SettingsWindow::SettingsWindow(QWidget *parent)
QVBoxLayout* layout = new QVBoxLayout;
layout->addWidget(tab_widget);
layout->addWidget(close_buttons);
setLayout(layout);
}