mirror of
https://github.com/edisionnano/QDiskInfo.git
synced 2026-04-18 16:11:28 +03:00
Fix saving to a file
This commit is contained in:
@@ -136,22 +136,22 @@ void MainWindow::scanDevices()
|
|||||||
}
|
}
|
||||||
|
|
||||||
QJsonDocument localDoc = QJsonDocument::fromJson(allOutput.toUtf8());
|
QJsonDocument localDoc = QJsonDocument::fromJson(allOutput.toUtf8());
|
||||||
deviceJson = localDoc.object();
|
QJsonObject localObj = localDoc.object();
|
||||||
|
|
||||||
QString modelName = deviceJson["model_name"].toString();
|
QString modelName = localObj["model_name"].toString();
|
||||||
QJsonArray attributes = deviceJson["ata_smart_attributes"].toObject()["table"].toArray();
|
QJsonArray attributes = localObj["ata_smart_attributes"].toObject()["table"].toArray();
|
||||||
QJsonObject nvmeLog = deviceJson["nvme_smart_health_information_log"].toObject();
|
QJsonObject nvmeLog = localObj["nvme_smart_health_information_log"].toObject();
|
||||||
QString temperature = "-- °C";
|
QString temperature = "-- °C";
|
||||||
bool healthPassed = deviceJson["smart_status"].toObject()["passed"].toBool();
|
bool healthPassed = localObj["smart_status"].toObject()["passed"].toBool();
|
||||||
bool caution = false;
|
bool caution = false;
|
||||||
bool bad = false;
|
bool bad = false;
|
||||||
QString health;
|
QString health;
|
||||||
QColor healthColor;
|
QColor healthColor;
|
||||||
|
|
||||||
QString protocol = deviceJson["device"].toObject()["protocol"].toString();
|
QString protocol = localObj["device"].toObject()["protocol"].toString();
|
||||||
bool isNvme = (protocol == "NVMe");
|
bool isNvme = (protocol == "NVMe");
|
||||||
|
|
||||||
int temperatureInt = deviceJson["temperature"].toObject()["current"].toInt();
|
int temperatureInt = localObj["temperature"].toObject()["current"].toInt();
|
||||||
if (temperatureInt > 0) {
|
if (temperatureInt > 0) {
|
||||||
temperature = QString::number(temperatureInt) + " °C";
|
temperature = QString::number(temperatureInt) + " °C";
|
||||||
}
|
}
|
||||||
@@ -219,15 +219,15 @@ void MainWindow::scanDevices()
|
|||||||
|
|
||||||
connect(button, &QPushButton::clicked, this, [=]() {
|
connect(button, &QPushButton::clicked, this, [=]() {
|
||||||
if (isNvme) {
|
if (isNvme) {
|
||||||
populateWindow(deviceJson, health, nvmeSmartOrdered);
|
populateWindow(localObj, health, nvmeSmartOrdered);
|
||||||
} else {
|
} else {
|
||||||
populateWindow(deviceJson, health);
|
populateWindow(localObj, health);
|
||||||
}
|
}
|
||||||
updateNavigationButtons(buttonGroup->buttons().indexOf(button));
|
updateNavigationButtons(buttonGroup->buttons().indexOf(button));
|
||||||
});
|
});
|
||||||
|
|
||||||
if (firstTime) {
|
if (firstTime) {
|
||||||
globalObj = deviceJson;
|
globalObj = localObj;
|
||||||
globalHealth = health;
|
globalHealth = health;
|
||||||
button->setChecked(true);
|
button->setChecked(true);
|
||||||
firstTime = false;
|
firstTime = false;
|
||||||
@@ -268,6 +268,8 @@ void MainWindow::populateWindow(const QJsonObject &localObj, const QString &heal
|
|||||||
|
|
||||||
bool isNvme = (protocol == "NVMe");
|
bool isNvme = (protocol == "NVMe");
|
||||||
|
|
||||||
|
deviceJson = localObj;
|
||||||
|
|
||||||
diskName->setText("<html><head/><body><p><span style='font-size:14pt; font-weight:bold;'>" + modelName + " " + userCapacityString + "</span></p></body></html>");
|
diskName->setText("<html><head/><body><p><span style='font-size:14pt; font-weight:bold;'>" + modelName + " " + userCapacityString + "</span></p></body></html>");
|
||||||
firmwareLineEdit->setText(firmwareVersion);
|
firmwareLineEdit->setText(firmwareVersion);
|
||||||
serialNumberLineEdit->setText(serialNumber);
|
serialNumberLineEdit->setText(serialNumber);
|
||||||
|
|||||||
Reference in New Issue
Block a user