diff --git a/UEFITool/uefitool.cpp b/UEFITool/uefitool.cpp index 0722816..f38a845 100644 --- a/UEFITool/uefitool.cpp +++ b/UEFITool/uefitool.cpp @@ -148,7 +148,7 @@ void UEFITool::init() model->setMarkingEnabled(markingEnabled); ui->actionToggleBootGuardMarking->setChecked(markingEnabled); - // Connect + // Connect signals to slots connect(ui->structureTreeView->selectionModel(), SIGNAL(currentChanged(const QModelIndex &, const QModelIndex &)), this, SLOT(populateUi(const QModelIndex &))); connect(ui->structureTreeView->selectionModel(), SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)), @@ -162,10 +162,17 @@ void UEFITool::init() connect(ui->fitTableWidget, SIGNAL(itemDoubleClicked(QTableWidgetItem*)), this, SLOT(scrollTreeView(QTableWidgetItem*))); connect(ui->messagesTabWidget, SIGNAL(currentChanged(int)), this, SLOT(currentTabChanged(int))); - // allow enter/return pressing to scroll tree view + // Allow enter/return pressing to scroll tree view ui->parserMessagesListWidget->installEventFilter(this); ui->finderMessagesListWidget->installEventFilter(this); ui->builderMessagesListWidget->installEventFilter(this); + + // Switch default window style to Fusion on Qt6 Windows builds + // TOOD: remove this one 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()); +#endif } void UEFITool::populateUi(const QItemSelection &selected) diff --git a/UEFITool/uefitool.h b/UEFITool/uefitool.h index d758ba6..7c68ab0 100644 --- a/UEFITool/uefitool.h +++ b/UEFITool/uefitool.h @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include diff --git a/common/ffsparser.cpp b/common/ffsparser.cpp index 588469b..95dd684 100644 --- a/common/ffsparser.cpp +++ b/common/ffsparser.cpp @@ -35,17 +35,6 @@ #include "digest/sha2.h" #include "digest/sm3.h" -#ifndef QT_CORE_LIB -namespace Qt { -enum GlobalColor { - red = 7, - green = 8, - cyan = 10, - yellow = 12, -}; -} -#endif - // Constructor FfsParser::FfsParser(TreeModel* treeModel) : model(treeModel), imageBase(0), addressDiff(0x100000000ULL), protectedRegionsBase(0) { @@ -3778,14 +3767,14 @@ USTATUS FfsParser::markProtectedRangeRecursive(const UModelIndex & index, const if (std::min(currentOffset + currentSize, range.Offset + range.Size) > std::max(currentOffset, range.Offset)) { if (range.Offset <= currentOffset && currentOffset + currentSize <= range.Offset + range.Size) { // Mark as fully in range if (range.Type == PROTECTED_RANGE_INTEL_BOOT_GUARD_IBB) { - model->setMarking(index, Qt::red); + model->setMarking(index, BootGuardMarking::BootGuardFullyInRange); } else { - model->setMarking(index, Qt::cyan); + model->setMarking(index, BootGuardMarking::VendorFullyInRange); } } else { // Mark as partially in range - model->setMarking(index, Qt::yellow); + model->setMarking(index, BootGuardMarking::PartiallyInRange); } } } diff --git a/common/treemodel.cpp b/common/treemodel.cpp index b49c508..0ae747d 100644 --- a/common/treemodel.cpp +++ b/common/treemodel.cpp @@ -28,8 +28,17 @@ QVariant TreeModel::data(const UModelIndex &index, int role) const } #if defined (QT_GUI_LIB) else if (role == Qt::BackgroundRole) { - if (markingEnabledFlag && marking(index) > 0) { - return QBrush((Qt::GlobalColor)marking(index)); + 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; + } } } #endif diff --git a/common/treemodel.h b/common/treemodel.h index 7ff4c8c..50fbfc7 100644 --- a/common/treemodel.h +++ b/common/treemodel.h @@ -19,6 +19,13 @@ enum ItemFixedState { Fixed }; +enum BootGuardMarking { + None = 0, // Needs to be zero + PartiallyInRange, + BootGuardFullyInRange, + VendorFullyInRange +}; + #if defined(QT_CORE_LIB) // Use Qt classes #include