mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-08-07 01:42:30 +00:00
Make widget and color changes reflect in real time
Reference: 56d29939b0
This commit is contained in:
parent
eeaa1bcaf3
commit
ea30efdcc7
@ -4,6 +4,7 @@
|
|||||||
#include <QDockWidget>
|
#include <QDockWidget>
|
||||||
#include <QKeyEvent>
|
#include <QKeyEvent>
|
||||||
#include <QProgressDialog>
|
#include <QProgressDialog>
|
||||||
|
#include <QStyleHints>
|
||||||
|
|
||||||
#include "about_dialog.h"
|
#include "about_dialog.h"
|
||||||
#include "cheats_patches.h"
|
#include "cheats_patches.h"
|
||||||
@ -26,6 +27,8 @@
|
|||||||
#include "common/discord_rpc_handler.h"
|
#include "common/discord_rpc_handler.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
std::string s_system_style_name;
|
||||||
|
|
||||||
MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent), ui(new Ui::MainWindow) {
|
MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent), ui(new Ui::MainWindow) {
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
installEventFilter(this);
|
installEventFilter(this);
|
||||||
@ -118,21 +121,15 @@ void MainWindow::CreateActions() {
|
|||||||
|
|
||||||
void MainWindow::AddUiWidgets() {
|
void MainWindow::AddUiWidgets() {
|
||||||
// add toolbar widgets
|
// add toolbar widgets
|
||||||
static QString s_system_style_name;
|
QString qsystem_style_name;
|
||||||
static bool s_system_style_name_set;
|
qsystem_style_name = QApplication::style()->objectName();
|
||||||
|
s_system_style_name = qsystem_style_name.toStdString();
|
||||||
if (!s_system_style_name_set) {
|
|
||||||
s_system_style_name_set = true;
|
|
||||||
s_system_style_name = QApplication::style()->objectName();
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string widget_style = Config::getWidgetStyle();
|
std::string widget_style = Config::getWidgetStyle();
|
||||||
if (widget_style == "Fusion") {
|
if (widget_style == "Fusion") {
|
||||||
qApp->setStyle(QStyleFactory::create("Fusion"));
|
qApp->setStyle(QStyleFactory::create("Fusion"));
|
||||||
qApp->setStyleSheet(QString());
|
|
||||||
} else if (widget_style == "System") {
|
} else if (widget_style == "System") {
|
||||||
qApp->setStyle(s_system_style_name);
|
qApp->setStyle(qsystem_style_name);
|
||||||
qApp->setStyleSheet(QString());
|
|
||||||
}
|
}
|
||||||
ui->toolBar->setObjectName("mw_toolbar");
|
ui->toolBar->setObjectName("mw_toolbar");
|
||||||
ui->toolBar->addWidget(ui->playButton);
|
ui->toolBar->addWidget(ui->playButton);
|
||||||
@ -571,10 +568,35 @@ void MainWindow::CreateConnects() {
|
|||||||
connect(ui->setThemeSystemDark, &QAction::triggered, &m_window_themes, [this]() {
|
connect(ui->setThemeSystemDark, &QAction::triggered, &m_window_themes, [this]() {
|
||||||
m_window_themes.SetWindowTheme(Theme::SystemDark, ui->mw_searchbar);
|
m_window_themes.SetWindowTheme(Theme::SystemDark, ui->mw_searchbar);
|
||||||
Config::setMainWindowTheme(static_cast<int>(Theme::SystemDark));
|
Config::setMainWindowTheme(static_cast<int>(Theme::SystemDark));
|
||||||
if (isIconBlack) {
|
|
||||||
|
bool isSystemDarkMode;
|
||||||
|
#ifdef __linux__
|
||||||
|
const QPalette defaultPalette;
|
||||||
|
const auto text = defaultPalette.color(QPalette::WindowText);
|
||||||
|
const auto window = defaultPalette.color(QPalette::Window);
|
||||||
|
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) {
|
||||||
|
if (isIconBlack) {
|
||||||
SetUiIcons(false);
|
SetUiIcons(false);
|
||||||
isIconBlack = false;
|
isIconBlack = false;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if (!isIconBlack) {
|
||||||
|
SetUiIcons(true);
|
||||||
|
isIconBlack = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
connect(ui->setThemeSystemLight, &QAction::triggered, &m_window_themes, [this]() {
|
connect(ui->setThemeSystemLight, &QAction::triggered, &m_window_themes, [this]() {
|
||||||
m_window_themes.SetWindowTheme(Theme::SystemLight, ui->mw_searchbar);
|
m_window_themes.SetWindowTheme(Theme::SystemLight, ui->mw_searchbar);
|
||||||
|
@ -24,6 +24,8 @@
|
|||||||
#include "main_window_ui.h"
|
#include "main_window_ui.h"
|
||||||
#include "pkg_viewer.h"
|
#include "pkg_viewer.h"
|
||||||
|
|
||||||
|
extern std::string s_system_style_name;
|
||||||
|
|
||||||
class GameListFrame;
|
class GameListFrame;
|
||||||
|
|
||||||
class MainWindow : public QMainWindow {
|
class MainWindow : public QMainWindow {
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
#include "common/logging/backend.h"
|
#include "common/logging/backend.h"
|
||||||
#include "common/logging/filter.h"
|
#include "common/logging/filter.h"
|
||||||
#include "common/logging/formatter.h"
|
#include "common/logging/formatter.h"
|
||||||
|
#include "common/logging/log.h"
|
||||||
#include "main_window.h"
|
#include "main_window.h"
|
||||||
#include "settings_dialog.h"
|
#include "settings_dialog.h"
|
||||||
#include "ui_settings_dialog.h"
|
#include "ui_settings_dialog.h"
|
||||||
@ -527,6 +528,18 @@ void SettingsDialog::UpdateSettings() {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
BackgroundMusicPlayer::getInstance().setVolume(ui->BGMVolumeSlider->value());
|
BackgroundMusicPlayer::getInstance().setVolume(ui->BGMVolumeSlider->value());
|
||||||
|
|
||||||
|
if (Config::getWidgetStyle() == "Fusion") {
|
||||||
|
qApp->setStyle(QStyleFactory::create("Fusion"));
|
||||||
|
} else if (Config::getWidgetStyle() == "System") {
|
||||||
|
qApp->setStyle(QString::fromStdString(s_system_style_name));
|
||||||
|
}
|
||||||
|
printf("%s", s_system_style_name.c_str());
|
||||||
|
|
||||||
|
foreach (QWidget* widget, QApplication::topLevelWidgets()) {
|
||||||
|
widget->update();
|
||||||
|
}
|
||||||
|
QCoreApplication::processEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingsDialog::ResetInstallFolders() {
|
void SettingsDialog::ResetInstallFolders() {
|
||||||
|
Loading…
Reference in New Issue
Block a user