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);
// 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
QSettings settings("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize", QSettings::NativeFormat);
if (settings.value("AppsUseLightTheme", 1).toInt() == 0) {
QApplication::setStyle(QStyleFactory::create("Fusion"));
QApplication::setPalette(QApplication::style()->standardPalette());
#if QT_VERSION_MAJOR >= 6
#if defined Q_OS_OSX
const QPalette palette = QApplication::palette();
const QColor& color = palette.color(QPalette::Active, QPalette::Base);
if (color.lightness() < 127) { // TreeView has dark background
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
}

View File

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