diff --git a/UEFITool/uefitool.cpp b/UEFITool/uefitool.cpp index f38a845..4a79155 100644 --- a/UEFITool/uefitool.cpp +++ b/UEFITool/uefitool.cpp @@ -168,10 +168,14 @@ void UEFITool::init() ui->builderMessagesListWidget->installEventFilter(this); // Switch default window style to Fusion on Qt6 Windows builds - // TOOD: remove this one default style gains dark theme support + // TODO: remove this once default style gains dark theme support #if defined Q_OS_WIN and QT_VERSION_MAJOR >= 6 - QApplication::setStyle(QStyleFactory::create("Fusion")); - QApplication::setPalette(QApplication::style()->standardPalette()); + 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()); + model->setMarkingDarkMode(true); + } #endif } diff --git a/common/treemodel.cpp b/common/treemodel.cpp index 0ae747d..8fcc0bd 100644 --- a/common/treemodel.cpp +++ b/common/treemodel.cpp @@ -29,15 +29,10 @@ QVariant TreeModel::data(const UModelIndex &index, int role) const #if defined (QT_GUI_LIB) else if (role == Qt::BackgroundRole) { if (markingEnabledFlag && marking(index) != BootGuardMarking::None) { - // Use light colors by default - uint8_t bgFullyInRange = Qt::red; - uint8_t vendorFullyInRange = Qt::cyan; - uint8_t partiallyInRange = Qt::yellow; - switch (marking(index)) { - case BootGuardMarking::BootGuardFullyInRange: return QBrush((Qt::GlobalColor)bgFullyInRange); break; - case BootGuardMarking::VendorFullyInRange: return QBrush((Qt::GlobalColor)vendorFullyInRange); break; - case BootGuardMarking::PartiallyInRange: return QBrush((Qt::GlobalColor)partiallyInRange); break; + case BootGuardMarking::BootGuardFullyInRange: return QBrush((Qt::GlobalColor)(markingDarkModeFlag ? Qt::darkRed : Qt::red )); break; + case BootGuardMarking::VendorFullyInRange: return QBrush((Qt::GlobalColor)(markingDarkModeFlag ? Qt::darkCyan : Qt::cyan )); break; + case BootGuardMarking::PartiallyInRange: return QBrush((Qt::GlobalColor)(markingDarkModeFlag ? Qt::darkYellow : Qt::yellow)); break; } } } @@ -350,6 +345,13 @@ void TreeModel::TreeModel::setMarkingEnabled(const bool enabled) emit dataChanged(UModelIndex(), UModelIndex()); } +void TreeModel::TreeModel::setMarkingDarkMode(const bool enabled) +{ + markingDarkModeFlag = enabled; + + emit dataChanged(UModelIndex(), UModelIndex()); +} + void TreeModel::setMarking(const UModelIndex &index, const UINT8 marking) { if (!index.isValid()) diff --git a/common/treemodel.h b/common/treemodel.h index 50fbfc7..dee5661 100644 --- a/common/treemodel.h +++ b/common/treemodel.h @@ -96,13 +96,14 @@ class TreeModel : public QAbstractItemModel private: TreeItem *rootItem; bool markingEnabledFlag; + bool markingDarkModeFlag; public: QVariant data(const UModelIndex &index, int role) const; Qt::ItemFlags flags(const UModelIndex &index) const; QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; - TreeModel(QObject *parent = 0) : QAbstractItemModel(parent), markingEnabledFlag(true) { + TreeModel(QObject *parent = 0) : QAbstractItemModel(parent), markingEnabledFlag(true), markingDarkModeFlag(false) { rootItem = new TreeItem(0, Types::Root, 0, UString(), UString(), UString(), UByteArray(), UByteArray(), UByteArray(), true, false); } @@ -114,6 +115,7 @@ class TreeModel private: TreeItem *rootItem; bool markingEnabledFlag; + bool markingDarkModeFlag; void dataChanged(const UModelIndex &, const UModelIndex &) {} void layoutAboutToBeChanged() {} @@ -143,6 +145,9 @@ public: bool markingEnabled() { return markingEnabledFlag; } void setMarkingEnabled(const bool enabled); + bool markingDarkMode() { return markingDarkModeFlag; } + void setMarkingDarkMode(const bool enabled); + UModelIndex index(int row, int column, const UModelIndex &parent = UModelIndex()) const; UModelIndex parent(const UModelIndex &index) const; int rowCount(const UModelIndex &parent = UModelIndex()) const;