mirror of
https://github.com/edisionnano/QDiskInfo.git
synced 2026-03-10 06:40:53 +03:00
Lay the groundwork for NVMe support
This commit is contained in:
79
.gitignore
vendored
79
.gitignore
vendored
@@ -1,32 +1,57 @@
|
||||
# Prerequisites
|
||||
*.d
|
||||
|
||||
# Compiled Object files
|
||||
# C++ objects and libs
|
||||
*.slo
|
||||
*.lo
|
||||
*.o
|
||||
*.obj
|
||||
|
||||
# Precompiled Headers
|
||||
*.gch
|
||||
*.pch
|
||||
|
||||
# Compiled Dynamic libraries
|
||||
*.so
|
||||
*.dylib
|
||||
*.dll
|
||||
|
||||
# Fortran module files
|
||||
*.mod
|
||||
*.smod
|
||||
|
||||
# Compiled Static libraries
|
||||
*.lai
|
||||
*.la
|
||||
*.a
|
||||
*.lib
|
||||
*.la
|
||||
*.lai
|
||||
*.so
|
||||
*.so.*
|
||||
*.dll
|
||||
*.dylib
|
||||
|
||||
# Executables
|
||||
*.exe
|
||||
*.out
|
||||
*.app
|
||||
# Qt-es
|
||||
object_script.*.Release
|
||||
object_script.*.Debug
|
||||
*_plugin_import.cpp
|
||||
/.qmake.cache
|
||||
/.qmake.stash
|
||||
*.pro.user
|
||||
*.pro.user.*
|
||||
*.qbs.user
|
||||
*.qbs.user.*
|
||||
*.moc
|
||||
moc_*.cpp
|
||||
moc_*.h
|
||||
qrc_*.cpp
|
||||
ui_*.h
|
||||
*.qmlc
|
||||
*.jsc
|
||||
Makefile*
|
||||
*build-*
|
||||
*.qm
|
||||
*.prl
|
||||
|
||||
# Qt unit tests
|
||||
target_wrapper.*
|
||||
|
||||
# QtCreator
|
||||
*.autosave
|
||||
|
||||
# QtCreator Qml
|
||||
*.qmlproject.user
|
||||
*.qmlproject.user.*
|
||||
|
||||
# QtCreator CMake
|
||||
CMakeLists.txt.user*
|
||||
|
||||
# QtCreator 4.8< compilation database
|
||||
compile_commands.json
|
||||
|
||||
# QtCreator local machine specific files for imported projects
|
||||
*creator.user*
|
||||
|
||||
*_qmlcache.qrc
|
||||
|
||||
# The entire build directory
|
||||
build/
|
||||
|
||||
@@ -69,6 +69,7 @@ void MainWindow::scanDevices()
|
||||
QJsonObject localObj = localDoc.object();
|
||||
|
||||
QJsonArray attributes = localObj["ata_smart_attributes"].toObject()["table"].toArray();
|
||||
QJsonArray nvmeLog = localObj["nvme_smart_health_information_log"].toArray();
|
||||
QString temperature = "N/A";
|
||||
bool healthPassed = localObj["smart_status"].toObject()["passed"].toBool();
|
||||
bool caution = false;
|
||||
@@ -86,11 +87,13 @@ void MainWindow::scanDevices()
|
||||
temperature = QString::number(temperatureInt) + " °C";
|
||||
}
|
||||
|
||||
for (const QJsonValue &attr : attributes) {
|
||||
QJsonObject attrObj = attr.toObject();
|
||||
if (!isNvme && (attrObj["id"] == 5 || attrObj["id"] == 197 || attrObj["id"] == 198) && (attrObj["raw"].toObject()["value"].toInt() != 0)) {
|
||||
caution = true;
|
||||
break;
|
||||
if (!isNvme) {
|
||||
for (const QJsonValue &attr : attributes) {
|
||||
QJsonObject attrObj = attr.toObject();
|
||||
if (!isNvme && (attrObj["id"] == 5 || attrObj["id"] == 197 || attrObj["id"] == 198) && (attrObj["raw"].toObject()["value"].toInt() != 0)) {
|
||||
caution = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,9 +124,8 @@ void MainWindow::scanDevices()
|
||||
globalObj = localObj;
|
||||
globalHealth = health;
|
||||
button->setChecked(true);
|
||||
firstTime = false;
|
||||
}
|
||||
|
||||
firstTime = false;
|
||||
}
|
||||
horizontalLayout->addStretch();
|
||||
populateWindow(globalObj, globalHealth);
|
||||
@@ -132,6 +134,7 @@ void MainWindow::scanDevices()
|
||||
void MainWindow::populateWindow(const QJsonObject &localObj, const QString &health)
|
||||
{
|
||||
QJsonArray attributes = localObj["ata_smart_attributes"].toObject()["table"].toArray();
|
||||
QJsonArray nvmeLog = localObj["nvme_smart_health_information_log"].toArray();
|
||||
QString modelName = localObj["model_name"].toString();
|
||||
QString firmwareVersion = localObj["firmware_version"].toString();
|
||||
float userCapacityGB = localObj.value("user_capacity").toObject().value("bytes").toDouble() / 1e9;
|
||||
@@ -195,9 +198,19 @@ void MainWindow::populateWindow(const QJsonObject &localObj, const QString &heal
|
||||
for (const QJsonValue &attr : attributes) { //Need different logic for NVMe
|
||||
QJsonObject attrObj = attr.toObject();
|
||||
if (attrObj["id"] == 241 && !isNvme) {
|
||||
totalWrites = QString::number(attrObj["raw"].toObject()["value"].toInt()) + " GB";
|
||||
if (attrObj["name"] == "Host_Writes_32MiB") {
|
||||
totalWrites = QString::number(attrObj["raw"].toObject()["value"].toInt()) + " GB";
|
||||
} else if (attrObj["name"] == "Host_Writes_32MiB") {
|
||||
double gibibytes = (attrObj["raw"].toObject()["value"].toInt() * 32 * 1024.0 * 1024.0) / 1e9;
|
||||
totalWrites = QString::number(static_cast<int>(gibibytes)) + " GB";
|
||||
}
|
||||
} else if (attrObj["id"] == 242 && !isNvme) {
|
||||
totalReads = QString::number(attrObj["raw"].toObject()["value"].toInt()) + " GB";
|
||||
if (attrObj["name"] == "Total_Reads_GB") {
|
||||
totalReads = QString::number(attrObj["raw"].toObject()["value"].toInt()) + " GB";
|
||||
} else if (attrObj["name"] == "Host_Reads_32MiB") {
|
||||
double gibibytes = (attrObj["raw"].toObject()["value"].toInt() * 32 * 1024.0 * 1024.0) / 1e9;
|
||||
totalReads = QString::number(static_cast<int>(gibibytes)) + " GB";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -323,7 +336,7 @@ QString MainWindow::getSmartctlOutput(const QStringList &arguments, bool root)
|
||||
QProcess process;
|
||||
QString command;
|
||||
QStringList commandArgs;
|
||||
if(root) {
|
||||
if (root) {
|
||||
command = "pkexec";
|
||||
commandArgs = {"smartctl"};
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user