mirror of
https://github.com/LongSoft/UEFITool.git
synced 2024-11-23 16:38:23 +08:00
Automatically select dark colors for BootGuard markings in dark mode
This commit is contained in:
parent
ef7ceefa41
commit
944133caa7
@ -168,10 +168,14 @@ 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
|
||||||
// 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
|
#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::setStyle(QStyleFactory::create("Fusion"));
|
||||||
QApplication::setPalette(QApplication::style()->standardPalette());
|
QApplication::setPalette(QApplication::style()->standardPalette());
|
||||||
|
model->setMarkingDarkMode(true);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,15 +29,10 @@ QVariant TreeModel::data(const UModelIndex &index, int role) const
|
|||||||
#if defined (QT_GUI_LIB)
|
#if defined (QT_GUI_LIB)
|
||||||
else if (role == Qt::BackgroundRole) {
|
else if (role == Qt::BackgroundRole) {
|
||||||
if (markingEnabledFlag && marking(index) != BootGuardMarking::None) {
|
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)) {
|
switch (marking(index)) {
|
||||||
case BootGuardMarking::BootGuardFullyInRange: return QBrush((Qt::GlobalColor)bgFullyInRange); break;
|
case BootGuardMarking::BootGuardFullyInRange: return QBrush((Qt::GlobalColor)(markingDarkModeFlag ? Qt::darkRed : Qt::red )); break;
|
||||||
case BootGuardMarking::VendorFullyInRange: return QBrush((Qt::GlobalColor)vendorFullyInRange); break;
|
case BootGuardMarking::VendorFullyInRange: return QBrush((Qt::GlobalColor)(markingDarkModeFlag ? Qt::darkCyan : Qt::cyan )); break;
|
||||||
case BootGuardMarking::PartiallyInRange: return QBrush((Qt::GlobalColor)partiallyInRange); 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());
|
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)
|
void TreeModel::setMarking(const UModelIndex &index, const UINT8 marking)
|
||||||
{
|
{
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
|
@ -96,13 +96,14 @@ class TreeModel : public QAbstractItemModel
|
|||||||
private:
|
private:
|
||||||
TreeItem *rootItem;
|
TreeItem *rootItem;
|
||||||
bool markingEnabledFlag;
|
bool markingEnabledFlag;
|
||||||
|
bool markingDarkModeFlag;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QVariant data(const UModelIndex &index, int role) const;
|
QVariant data(const UModelIndex &index, int role) const;
|
||||||
Qt::ItemFlags flags(const UModelIndex &index) const;
|
Qt::ItemFlags flags(const UModelIndex &index) const;
|
||||||
QVariant headerData(int section, Qt::Orientation orientation,
|
QVariant headerData(int section, Qt::Orientation orientation,
|
||||||
int role = Qt::DisplayRole) const;
|
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);
|
rootItem = new TreeItem(0, Types::Root, 0, UString(), UString(), UString(), UByteArray(), UByteArray(), UByteArray(), true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,6 +115,7 @@ class TreeModel
|
|||||||
private:
|
private:
|
||||||
TreeItem *rootItem;
|
TreeItem *rootItem;
|
||||||
bool markingEnabledFlag;
|
bool markingEnabledFlag;
|
||||||
|
bool markingDarkModeFlag;
|
||||||
|
|
||||||
void dataChanged(const UModelIndex &, const UModelIndex &) {}
|
void dataChanged(const UModelIndex &, const UModelIndex &) {}
|
||||||
void layoutAboutToBeChanged() {}
|
void layoutAboutToBeChanged() {}
|
||||||
@ -143,6 +145,9 @@ public:
|
|||||||
bool markingEnabled() { return markingEnabledFlag; }
|
bool markingEnabled() { return markingEnabledFlag; }
|
||||||
void setMarkingEnabled(const bool enabled);
|
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 index(int row, int column, const UModelIndex &parent = UModelIndex()) const;
|
||||||
UModelIndex parent(const UModelIndex &index) const;
|
UModelIndex parent(const UModelIndex &index) const;
|
||||||
int rowCount(const UModelIndex &parent = UModelIndex()) const;
|
int rowCount(const UModelIndex &parent = UModelIndex()) const;
|
||||||
|
Loading…
Reference in New Issue
Block a user