From 9efbe097fcc882511fb0ea8ed8a60bf94280a219 Mon Sep 17 00:00:00 2001 From: Spiros Date: Sun, 2 Jun 2024 14:25:09 +0300 Subject: [PATCH] Add colored dots for NVMe --- mainwindow.cpp | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/mainwindow.cpp b/mainwindow.cpp index c107754..d56d60e 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -381,11 +381,32 @@ void MainWindow::addNvmeLogTable(const QVector>& nvmeLogOrde QString name = key.replace("_", " "); name = toTitleCase(name); - QString raw = QString::number(pair.second); + int rawInt = pair.second; + QString raw = QString::number(rawInt); raw = QString("%1").arg(raw.toUInt(nullptr), 14, 16, QChar('0')).toUpper(); QColor statusColor; - statusColor = Qt::green; // For now leave it all green + + if (id == "01" && rawInt) { + statusColor = Qt::red; + } else if (id == "03") { + int availableSpareThreshold = nvmeLogOrdered.at(3).second; + if (availableSpareThreshold > 100) { // Thx to crystaldiskinfo for these workarounds + statusColor = Qt::green; + } else if (rawInt == 0 && availableSpareThreshold == 0) { + statusColor = Qt::green; + } else if (rawInt < availableSpareThreshold) { + statusColor = Qt::red; + } else if (availableSpareThreshold != 100 && (rawInt == availableSpareThreshold)) { + statusColor = Qt::yellow; + } else { + statusColor = Qt::green; + } + } else if (id == "05" && rawInt >= 90) { // Make this configurable, currently hardcoded to 10% + statusColor = Qt::yellow; + } else { + statusColor = Qt::green; + } QTableWidgetItem *statusItem = new QTableWidgetItem(); statusItem->setBackground(Qt::transparent);