mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-08-07 01:42:30 +00:00
Unify System (Dark) and System (Light) into a single theme
To update the icon color you have to switch to another theme then back to System
This commit is contained in:
parent
54927a8967
commit
b6f5751b23
@ -115,8 +115,7 @@ void MainWindow::CreateActions() {
|
|||||||
m_theme_act_group->addAction(ui->setThemeBlue);
|
m_theme_act_group->addAction(ui->setThemeBlue);
|
||||||
m_theme_act_group->addAction(ui->setThemeViolet);
|
m_theme_act_group->addAction(ui->setThemeViolet);
|
||||||
m_theme_act_group->addAction(ui->setThemeGruvbox);
|
m_theme_act_group->addAction(ui->setThemeGruvbox);
|
||||||
m_theme_act_group->addAction(ui->setThemeSystemDark);
|
m_theme_act_group->addAction(ui->setThemeSystem);
|
||||||
m_theme_act_group->addAction(ui->setThemeSystemLight);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::AddUiWidgets() {
|
void MainWindow::AddUiWidgets() {
|
||||||
@ -565,12 +564,12 @@ void MainWindow::CreateConnects() {
|
|||||||
isIconBlack = false;
|
isIconBlack = false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
connect(ui->setThemeSystemDark, &QAction::triggered, &m_window_themes, [this]() {
|
connect(ui->setThemeSystem, &QAction::triggered, &m_window_themes, [this]() {
|
||||||
m_window_themes.SetWindowTheme(Theme::SystemDark, ui->mw_searchbar);
|
m_window_themes.SetWindowTheme(Theme::System, ui->mw_searchbar);
|
||||||
Config::setMainWindowTheme(static_cast<int>(Theme::SystemDark));
|
Config::setMainWindowTheme(static_cast<int>(Theme::System));
|
||||||
|
|
||||||
bool isSystemDarkMode;
|
bool isSystemDarkMode;
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
const QPalette defaultPalette;
|
const QPalette defaultPalette;
|
||||||
const auto text = defaultPalette.color(QPalette::WindowText);
|
const auto text = defaultPalette.color(QPalette::WindowText);
|
||||||
const auto window = defaultPalette.color(QPalette::Window);
|
const auto window = defaultPalette.color(QPalette::Window);
|
||||||
@ -579,31 +578,23 @@ void MainWindow::CreateConnects() {
|
|||||||
} else {
|
} else {
|
||||||
isSystemDarkMode = false;
|
isSystemDarkMode = false;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if(QGuiApplication::styleHints()->colorScheme() == Qt::ColorScheme::Dark) {
|
if(QGuiApplication::styleHints()->colorScheme() == Qt::ColorScheme::Dark) {
|
||||||
isSystemDarkMode = true;
|
isSystemDarkMode = true;
|
||||||
} else {
|
} else {
|
||||||
isSystemDarkMode = false;
|
isSystemDarkMode = false;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if(isSystemDarkMode) {
|
if (isSystemDarkMode) {
|
||||||
if (isIconBlack) {
|
if (isIconBlack) {
|
||||||
SetUiIcons(false);
|
SetUiIcons(false);
|
||||||
isIconBlack = false;
|
isIconBlack = false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!isIconBlack) {
|
if (!isIconBlack) {
|
||||||
SetUiIcons(true);
|
SetUiIcons(true);
|
||||||
isIconBlack = true;
|
isIconBlack = true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
|
||||||
connect(ui->setThemeSystemLight, &QAction::triggered, &m_window_themes, [this]() {
|
|
||||||
m_window_themes.SetWindowTheme(Theme::SystemLight, ui->mw_searchbar);
|
|
||||||
Config::setMainWindowTheme(static_cast<int>(Theme::SystemLight));
|
|
||||||
if (!isIconBlack) {
|
|
||||||
SetUiIcons(true);
|
|
||||||
isIconBlack = true;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -984,14 +975,32 @@ void MainWindow::SetLastUsedTheme() {
|
|||||||
isIconBlack = false;
|
isIconBlack = false;
|
||||||
SetUiIcons(false);
|
SetUiIcons(false);
|
||||||
break;
|
break;
|
||||||
case Theme::SystemDark:
|
case Theme::System:
|
||||||
ui->setThemeSystemDark->setChecked(true);
|
ui->setThemeSystem->setChecked(true);
|
||||||
isIconBlack = false;
|
bool isSystemDarkMode;
|
||||||
SetUiIcons(false);
|
#ifdef __linux__
|
||||||
break;
|
const QPalette defaultPalette;
|
||||||
case Theme::SystemLight:
|
const auto text = defaultPalette.color(QPalette::WindowText);
|
||||||
ui->setThemeLight->setChecked(true);
|
const auto window = defaultPalette.color(QPalette::Window);
|
||||||
isIconBlack = true;
|
if (text.lightness() > window.lightness()) {
|
||||||
|
isSystemDarkMode = true;
|
||||||
|
} else {
|
||||||
|
isSystemDarkMode = false;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
if (QGuiApplication::styleHints()->colorScheme() == Qt::ColorScheme::Dark) {
|
||||||
|
isSystemDarkMode = true;
|
||||||
|
} else {
|
||||||
|
isSystemDarkMode = false;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
if (isSystemDarkMode = true) {
|
||||||
|
isIconBlack = false;
|
||||||
|
SetUiIcons(false);
|
||||||
|
} else if (isSystemDarkMode = false) {
|
||||||
|
isIconBlack = true;
|
||||||
|
SetUiIcons(true);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -151,16 +151,7 @@ void WindowThemes::SetWindowTheme(Theme theme, QLineEdit* mw_searchbar) {
|
|||||||
themePalette.setColor(QPalette::HighlightedText, Qt::black);
|
themePalette.setColor(QPalette::HighlightedText, Qt::black);
|
||||||
qApp->setPalette(themePalette);
|
qApp->setPalette(themePalette);
|
||||||
break;
|
break;
|
||||||
case Theme::SystemDark:
|
case Theme::System:
|
||||||
mw_searchbar->setStyleSheet("QLineEdit {"
|
|
||||||
"border: 1px solid;"
|
|
||||||
"border-radius: 4px; padding: 5px; }"
|
|
||||||
"QLineEdit:focus {"
|
|
||||||
"border: 1px solid; }");
|
|
||||||
qApp->setPalette(s_system_palette);
|
|
||||||
qApp->setStyleSheet(QString());
|
|
||||||
break;
|
|
||||||
case Theme::SystemLight:
|
|
||||||
mw_searchbar->setStyleSheet("QLineEdit {"
|
mw_searchbar->setStyleSheet("QLineEdit {"
|
||||||
"border: 1px solid;"
|
"border: 1px solid;"
|
||||||
"border-radius: 4px; padding: 5px; }"
|
"border-radius: 4px; padding: 5px; }"
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
#include <QStyleFactory>
|
#include <QStyleFactory>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
enum class Theme : int { Dark, Light, Green, Blue, Violet, Gruvbox, SystemDark, SystemLight };
|
enum class Theme : int { Dark, Light, Green, Blue, Violet, Gruvbox, System };
|
||||||
|
|
||||||
class WindowThemes : public QObject {
|
class WindowThemes : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -37,8 +37,7 @@ public:
|
|||||||
QAction* setThemeBlue;
|
QAction* setThemeBlue;
|
||||||
QAction* setThemeViolet;
|
QAction* setThemeViolet;
|
||||||
QAction* setThemeGruvbox;
|
QAction* setThemeGruvbox;
|
||||||
QAction* setThemeSystemDark;
|
QAction* setThemeSystem;
|
||||||
QAction* setThemeSystemLight;
|
|
||||||
QWidget* centralWidget;
|
QWidget* centralWidget;
|
||||||
QLineEdit* mw_searchbar;
|
QLineEdit* mw_searchbar;
|
||||||
QPushButton* playButton;
|
QPushButton* playButton;
|
||||||
@ -164,12 +163,9 @@ public:
|
|||||||
setThemeGruvbox = new QAction(MainWindow);
|
setThemeGruvbox = new QAction(MainWindow);
|
||||||
setThemeGruvbox->setObjectName("setThemeGruvbox");
|
setThemeGruvbox->setObjectName("setThemeGruvbox");
|
||||||
setThemeGruvbox->setCheckable(true);
|
setThemeGruvbox->setCheckable(true);
|
||||||
setThemeSystemDark = new QAction(MainWindow);
|
setThemeSystem = new QAction(MainWindow);
|
||||||
setThemeSystemDark->setObjectName("setThemeSystemDark");
|
setThemeSystem->setObjectName("setThemeSystem");
|
||||||
setThemeSystemDark->setCheckable(true);
|
setThemeSystem->setCheckable(true);
|
||||||
setThemeSystemLight = new QAction(MainWindow);
|
|
||||||
setThemeSystemLight->setObjectName("setThemeSystemLight");
|
|
||||||
setThemeSystemLight->setCheckable(true);
|
|
||||||
centralWidget = new QWidget(MainWindow);
|
centralWidget = new QWidget(MainWindow);
|
||||||
centralWidget->setObjectName("centralWidget");
|
centralWidget->setObjectName("centralWidget");
|
||||||
sizePolicy.setHeightForWidth(centralWidget->sizePolicy().hasHeightForWidth());
|
sizePolicy.setHeightForWidth(centralWidget->sizePolicy().hasHeightForWidth());
|
||||||
@ -295,8 +291,7 @@ public:
|
|||||||
menuThemes->addAction(setThemeBlue);
|
menuThemes->addAction(setThemeBlue);
|
||||||
menuThemes->addAction(setThemeViolet);
|
menuThemes->addAction(setThemeViolet);
|
||||||
menuThemes->addAction(setThemeGruvbox);
|
menuThemes->addAction(setThemeGruvbox);
|
||||||
menuThemes->addAction(setThemeSystemDark);
|
menuThemes->addAction(setThemeSystem);
|
||||||
menuThemes->addAction(setThemeSystemLight);
|
|
||||||
menuGame_List_Icons->addAction(setIconSizeTinyAct);
|
menuGame_List_Icons->addAction(setIconSizeTinyAct);
|
||||||
menuGame_List_Icons->addAction(setIconSizeSmallAct);
|
menuGame_List_Icons->addAction(setIconSizeSmallAct);
|
||||||
menuGame_List_Icons->addAction(setIconSizeMediumAct);
|
menuGame_List_Icons->addAction(setIconSizeMediumAct);
|
||||||
@ -384,10 +379,8 @@ public:
|
|||||||
setThemeBlue->setText(QCoreApplication::translate("MainWindow", "Blue", nullptr));
|
setThemeBlue->setText(QCoreApplication::translate("MainWindow", "Blue", nullptr));
|
||||||
setThemeViolet->setText(QCoreApplication::translate("MainWindow", "Violet", nullptr));
|
setThemeViolet->setText(QCoreApplication::translate("MainWindow", "Violet", nullptr));
|
||||||
setThemeGruvbox->setText("Gruvbox");
|
setThemeGruvbox->setText("Gruvbox");
|
||||||
setThemeSystemDark->setText(
|
setThemeSystem->setText(
|
||||||
QCoreApplication::translate("MainWindow", "System (Dark)", nullptr));
|
QCoreApplication::translate("MainWindow", "System", nullptr));
|
||||||
setThemeSystemLight->setText(
|
|
||||||
QCoreApplication::translate("MainWindow", "System (Light)", nullptr));
|
|
||||||
toolBar->setWindowTitle(QCoreApplication::translate("MainWindow", "toolBar", nullptr));
|
toolBar->setWindowTitle(QCoreApplication::translate("MainWindow", "toolBar", nullptr));
|
||||||
} // retranslateUi
|
} // retranslateUi
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user