Detect macOS dark aqua mode

This commit is contained in:
Nikolaj Schlej 2023-02-11 21:29:35 -08:00
parent 745f4b69f2
commit 6232836fb6
2 changed files with 16 additions and 6 deletions

View File

@ -168,14 +168,23 @@ void UEFITool::init()
ui->builderMessagesListWidget->installEventFilter(this); ui->builderMessagesListWidget->installEventFilter(this);
// Switch default window style to Fusion on Qt6 Windows builds // Switch default window style to Fusion on Qt6 Windows builds
// TODO: remove this once default style gains dark theme support
#if defined Q_OS_WIN and QT_VERSION_MAJOR >= 6 #if QT_VERSION_MAJOR >= 6
QSettings settings("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize", QSettings::NativeFormat); #if defined Q_OS_OSX
if (settings.value("AppsUseLightTheme", 1).toInt() == 0) { const QPalette palette = QApplication::palette();
QApplication::setStyle(QStyleFactory::create("Fusion")); const QColor& color = palette.color(QPalette::Active, QPalette::Base);
QApplication::setPalette(QApplication::style()->standardPalette()); if (color.lightness() < 127) { // TreeView has dark background
model->setMarkingDarkMode(true); model->setMarkingDarkMode(true);
} }
#elif defined Q_OS_WIN
QSettings settings("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize", QSettings::NativeFormat);
if (settings.value("AppsUseLightTheme", 1).toInt() == 0) {
model->setMarkingDarkMode(true);
// TODO: remove this once default style gains dark theme support
QApplication::setStyle(QStyleFactory::create("Fusion"));
QApplication::setPalette(QApplication::style()->standardPalette());
}
#endif
#endif #endif
} }

View File

@ -27,6 +27,7 @@
#include <QMenu> #include <QMenu>
#include <QMessageBox> #include <QMessageBox>
#include <QMimeData> #include <QMimeData>
#include <QPalette>
#include <QPlainTextEdit> #include <QPlainTextEdit>
#include <QProcess> #include <QProcess>
#include <QSettings> #include <QSettings>