mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-08-04 16:32:39 +00:00
style: Add light and dark system themes
This commit is contained in:
parent
f75b719d96
commit
42671ad03c
@ -113,6 +113,8 @@ void MainWindow::CreateActions() {
|
||||
m_theme_act_group->addAction(ui->setThemeViolet);
|
||||
m_theme_act_group->addAction(ui->setThemeGruvbox);
|
||||
m_theme_act_group->addAction(ui->setThemeTokyoNight);
|
||||
m_theme_act_group->addAction(ui->setThemeSystemDark);
|
||||
m_theme_act_group->addAction(ui->setThemeSystemLight);
|
||||
}
|
||||
|
||||
void MainWindow::AddUiWidgets() {
|
||||
@ -558,6 +560,22 @@ void MainWindow::CreateConnects() {
|
||||
isIconBlack = false;
|
||||
}
|
||||
});
|
||||
connect(ui->setThemeSystemDark, &QAction::triggered, &m_window_themes, [this]() {
|
||||
m_window_themes.SetWindowTheme(Theme::SystemDark, ui->mw_searchbar);
|
||||
Config::setMainWindowTheme(static_cast<int>(Theme::SystemDark));
|
||||
if (isIconBlack) {
|
||||
SetUiIcons(false);
|
||||
isIconBlack = false;
|
||||
}
|
||||
});
|
||||
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;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void MainWindow::StartGame() {
|
||||
@ -941,6 +959,15 @@ void MainWindow::SetLastUsedTheme() {
|
||||
isIconBlack = false;
|
||||
SetUiIcons(false);
|
||||
break;
|
||||
case Theme::SystemDark:
|
||||
ui->setThemeSystemDark->setChecked(true);
|
||||
isIconBlack = false;
|
||||
SetUiIcons(false);
|
||||
break;
|
||||
case Theme::SystemLight:
|
||||
ui->setThemeLight->setChecked(true);
|
||||
isIconBlack = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,14 @@
|
||||
void WindowThemes::SetWindowTheme(Theme theme, QLineEdit* mw_searchbar) {
|
||||
QPalette themePalette;
|
||||
|
||||
static QPalette s_unthemed_palette;
|
||||
static bool s_unthemed_style_name_set;
|
||||
|
||||
if (!s_unthemed_style_name_set) {
|
||||
s_unthemed_style_name_set = true;
|
||||
s_unthemed_palette = QApplication::palette();
|
||||
}
|
||||
|
||||
switch (theme) {
|
||||
case Theme::Dark:
|
||||
mw_searchbar->setStyleSheet(
|
||||
@ -165,5 +173,25 @@ void WindowThemes::SetWindowTheme(Theme theme, QLineEdit* mw_searchbar) {
|
||||
themePalette.setColor(QPalette::HighlightedText, Qt::black);
|
||||
qApp->setPalette(themePalette);
|
||||
break;
|
||||
case Theme::SystemDark:
|
||||
mw_searchbar->setStyleSheet("QLineEdit {"
|
||||
"border: 1px solid;"
|
||||
"border-radius: 4px; padding: 5px; }"
|
||||
"QLineEdit:focus {"
|
||||
"border: 1px solid; }");
|
||||
qApp->setPalette(s_unthemed_palette);
|
||||
qApp->setStyleSheet(QString());
|
||||
qApp->setStyle(QApplication::style()->objectName());
|
||||
break;
|
||||
case Theme::SystemLight:
|
||||
mw_searchbar->setStyleSheet("QLineEdit {"
|
||||
"border: 1px solid;"
|
||||
"border-radius: 4px; padding: 5px; }"
|
||||
"QLineEdit:focus {"
|
||||
"border: 1px solid; }");
|
||||
qApp->setPalette(s_unthemed_palette);
|
||||
qApp->setStyleSheet(QString());
|
||||
qApp->setStyle(QApplication::style()->objectName());
|
||||
break;
|
||||
}
|
||||
}
|
@ -6,11 +6,12 @@
|
||||
#include <QApplication>
|
||||
#include <QLineEdit>
|
||||
#include <QWidget>
|
||||
#include <QStyle>
|
||||
|
||||
enum class Theme : int { Dark, Light, Green, Blue, Violet, Gruvbox, TokyoNight };
|
||||
enum class Theme : int { Dark, Light, Green, Blue, Violet, Gruvbox, TokyoNight, SystemDark, SystemLight };
|
||||
|
||||
class WindowThemes : public QObject {
|
||||
Q_OBJECT
|
||||
public Q_SLOTS:
|
||||
void SetWindowTheme(Theme theme, QLineEdit* mw_searchbar);
|
||||
};
|
||||
};
|
@ -38,6 +38,8 @@ public:
|
||||
QAction* setThemeViolet;
|
||||
QAction* setThemeGruvbox;
|
||||
QAction* setThemeTokyoNight;
|
||||
QAction* setThemeSystemDark;
|
||||
QAction* setThemeSystemLight;
|
||||
QWidget* centralWidget;
|
||||
QLineEdit* mw_searchbar;
|
||||
QPushButton* playButton;
|
||||
@ -166,6 +168,12 @@ public:
|
||||
setThemeTokyoNight = new QAction(MainWindow);
|
||||
setThemeTokyoNight->setObjectName("setThemeTokyoNight");
|
||||
setThemeTokyoNight->setCheckable(true);
|
||||
setThemeSystemDark = new QAction(MainWindow);
|
||||
setThemeSystemDark->setObjectName("setThemeSystem");
|
||||
setThemeSystemDark->setCheckable(true);
|
||||
setThemeSystemLight = new QAction(MainWindow);
|
||||
setThemeSystemLight->setObjectName("setThemeSystemLight");
|
||||
setThemeSystemLight->setCheckable(true);
|
||||
centralWidget = new QWidget(MainWindow);
|
||||
centralWidget->setObjectName("centralWidget");
|
||||
sizePolicy.setHeightForWidth(centralWidget->sizePolicy().hasHeightForWidth());
|
||||
@ -292,6 +300,8 @@ public:
|
||||
menuThemes->addAction(setThemeViolet);
|
||||
menuThemes->addAction(setThemeGruvbox);
|
||||
menuThemes->addAction(setThemeTokyoNight);
|
||||
menuThemes->addAction(setThemeSystemDark);
|
||||
menuThemes->addAction(setThemeSystemLight);
|
||||
menuGame_List_Icons->addAction(setIconSizeTinyAct);
|
||||
menuGame_List_Icons->addAction(setIconSizeSmallAct);
|
||||
menuGame_List_Icons->addAction(setIconSizeMediumAct);
|
||||
@ -380,6 +390,8 @@ public:
|
||||
setThemeViolet->setText(QCoreApplication::translate("MainWindow", "Violet", nullptr));
|
||||
setThemeGruvbox->setText("Gruvbox");
|
||||
setThemeTokyoNight->setText("Tokyo Night");
|
||||
setThemeSystemDark->setText(QCoreApplication::translate("MainWindow", "System (Dark)", nullptr));
|
||||
setThemeSystemLight->setText(QCoreApplication::translate("MainWindow", "System (Light)", nullptr));
|
||||
toolBar->setWindowTitle(QCoreApplication::translate("MainWindow", "toolBar", nullptr));
|
||||
} // retranslateUi
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user