From 3416cc7ac19b25bb78eab135cf5e0b281e506de0 Mon Sep 17 00:00:00 2001 From: Spiros Date: Thu, 8 May 2025 14:02:47 +0300 Subject: [PATCH] Fix 4 issues Fixes #48 Fixes CustomButton doesn't get highlighted when clicking a radio button Fixes issue where disksGroup actions were not being cleared Fixes some warnings --- src/jsonparser.cpp | 2 ++ src/mainwindow.cpp | 20 ++++++++++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/jsonparser.cpp b/src/jsonparser.cpp index 05acd27..98e2317 100644 --- a/src/jsonparser.cpp +++ b/src/jsonparser.cpp @@ -29,6 +29,8 @@ QVector> JsonParser::parse(const QString &json) if (found) { if (trimmedLine.contains("}")) { break; + } else if (trimmedLine.contains("nsid")) { // smartctl now adds an nsid field, skip it for now + continue; } qsizetype colonPos = trimmedLine.indexOf(":"); if (colonPos != -1) { diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 4d9fb71..9765168 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -176,6 +176,13 @@ void MainWindow::updateUI() bool firstTime = true; globalIsNvme = false; + QList oldActions = disksGroup->actions(); + for (QAction *action : std::as_const(oldActions)) { + disksGroup->removeAction(action); + menuDisk->removeAction(action); + delete action; + } + for (int i = 0; i < devices.size(); ++i) { QJsonObject device = devices[i].toObject(); QString deviceName = device["name"].toString(); @@ -244,7 +251,12 @@ void MainWindow::updateUI() } } else if (isScsi) { QJsonObject scsiErrorCounterLog = localObj.value("scsi_error_counter_log").toObject(); - for (const QString key : {"read", "write", "verify"}) { + static const QString keys[] = { + QStringLiteral("read"), + QStringLiteral("write"), + QStringLiteral("verify") + }; + for (const QString& key : keys) { if (scsiErrorCounterLog.value(key).toObject().value("total_uncorrected_errors").toInt() != 0) { caution = true; } @@ -329,6 +341,7 @@ void MainWindow::updateUI() connect(diskAction, &QAction::triggered, this, [=]() { updateWindow(); + button->setChecked(true); }); if (firstTime) { @@ -960,6 +973,9 @@ void MainWindow::addNvmeLogTable(const QVector>& nvmeLogOrde QString key = pair.first; QString name = key.replace("_", " "); + if (name == "nsid") { // smartctl now adds an nsid field, skip it for now + continue; + } name = Utils.toTitleCase(name); int rawInt = pair.second; @@ -1372,7 +1388,7 @@ void MainWindow::on_actionASCII_View_triggered() QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Save | QDialogButtonBox::Close, asciiViewDialog); connect(buttonBox, &QDialogButtonBox::rejected, asciiViewDialog, &QDialog::close); - connect(buttonBox->button(QDialogButtonBox::Save), &QPushButton::clicked, [binaryData, this, deviceNodePath]() { + connect(buttonBox->button(QDialogButtonBox::Save), &QPushButton::clicked, this, [binaryData, this, deviceNodePath]() { QString filePath = QFileDialog::getSaveFileName(this, tr("Save Binary Data"), deviceNodePath.section('/', -1) + ".bin", tr("Binary Files (*.bin);;All Files (*)")); if (!filePath.isEmpty()) { QFile file(filePath);