forked from ShuriZma/suyu
1
0
Fork 0

WIP: fix macOS style when OS dark mode is active

This commit is contained in:
flodavid 2024-04-11 10:19:20 -07:00 committed by Crimson Hawk
parent b28acaf7c9
commit 323ea0cdfd
No known key found for this signature in database
GPG Key ID: 0804DD39BB9BF5AC
1 changed files with 29 additions and 0 deletions

View File

@ -4851,6 +4851,7 @@ void GMainWindow::UpdateIcons(const QString& theme_path) {
} }
bool GMainWindow::TryLoadStylesheet(const QString& theme_uri) { bool GMainWindow::TryLoadStylesheet(const QString& theme_uri) {
LOG_DEBUG(Frontend, "TryLoadStylesheet()");
QString style_path; QString style_path;
// Use themed stylesheet if it exists // Use themed stylesheet if it exists
@ -4900,6 +4901,7 @@ static void AdjustLinkColor() {
} }
void GMainWindow::UpdateThemePalette() { void GMainWindow::UpdateThemePalette() {
LOG_DEBUG(Frontend, "UpdateThemePalette()");
QPalette themePalette(qApp->palette()); QPalette themePalette(qApp->palette());
#ifdef _WIN32 #ifdef _WIN32
QColor dark(25, 25, 25); QColor dark(25, 25, 25);
@ -4955,6 +4957,33 @@ void GMainWindow::UpdateThemePalette() {
} }
LOG_DEBUG(Frontend, "Using style: {}", style_name.toStdString()); LOG_DEBUG(Frontend, "Using style: {}", style_name.toStdString());
qApp->setStyle(style_name); qApp->setStyle(style_name);
#elif defined(__APPLE__)
// Force the usage of the light palette in light mode
if (CheckDarkMode()) {
// Reset dark palette
themePalette = this->style()->standardPalette();
} else {
themePalette.setColor(QPalette::Window, QColor(236, 236, 236));
themePalette.setColor(QPalette::WindowText, Qt::black);
themePalette.setColor(QPalette::Disabled, QPalette::WindowText, Qt::black);
themePalette.setColor(QPalette::Base, Qt::white);
themePalette.setColor(QPalette::AlternateBase, QColor(245, 245, 245));
themePalette.setColor(QPalette::ToolTipBase, Qt::white);
themePalette.setColor(QPalette::ToolTipText, Qt::black);
themePalette.setColor(QPalette::Text, Qt::black);
themePalette.setColor(QPalette::Disabled, QPalette::Text, Qt::black);
themePalette.setColor(QPalette::Dark, QColor(191, 191, 191));
themePalette.setColor(QPalette::Shadow, Qt::black);
themePalette.setColor(QPalette::Button, QColor(236, 236, 236));
themePalette.setColor(QPalette::ButtonText, Qt::black);
themePalette.setColor(QPalette::Disabled, QPalette::ButtonText, QColor(147, 147, 147));
themePalette.setColor(QPalette::BrightText, Qt::white);
themePalette.setColor(QPalette::Link, QColor(0, 140, 200));
themePalette.setColor(QPalette::Highlight, QColor(179, 215, 255));
themePalette.setColor(QPalette::Disabled, QPalette::Highlight, QColor(220, 220, 220));
themePalette.setColor(QPalette::HighlightedText, Qt::black);
themePalette.setColor(QPalette::Disabled, QPalette::HighlightedText, Qt::black);
}
#else #else
if (CheckDarkMode()) { if (CheckDarkMode()) {
// Set Dark palette on non Windows platforms (that may not have a dark palette) // Set Dark palette on non Windows platforms (that may not have a dark palette)