mirror of
https://github.com/edisionnano/QDiskInfo.git
synced 2026-04-08 04:11:28 +03:00
Lay the groundwork for selftesting
This commit is contained in:
@@ -41,6 +41,11 @@ MainWindow::MainWindow(QWidget *parent)
|
|||||||
nextButton->setFocusPolicy(Qt::NoFocus);
|
nextButton->setFocusPolicy(Qt::NoFocus);
|
||||||
prevButton->setFocusPolicy(Qt::NoFocus);
|
prevButton->setFocusPolicy(Qt::NoFocus);
|
||||||
|
|
||||||
|
selfTestButton = ui->centralwidget->findChild<QToolButton*>("selfTestButton");
|
||||||
|
toolMenu = new QMenu(selfTestButton);
|
||||||
|
selfTestButton->setMenu(toolMenu);
|
||||||
|
toolMenu->setToolTipsVisible(true);
|
||||||
|
|
||||||
goodColor = QColor(Qt::green);
|
goodColor = QColor(Qt::green);
|
||||||
cautionColor = QColor(Qt::yellow);
|
cautionColor = QColor(Qt::yellow);
|
||||||
badColor = QColor(Qt::red);
|
badColor = QColor(Qt::red);
|
||||||
@@ -268,6 +273,7 @@ void MainWindow::updateUI()
|
|||||||
void MainWindow::populateWindow(const QJsonObject &localObj, const QString &health, const QVector<QPair<QString, int>>& nvmeLogOrdered)
|
void MainWindow::populateWindow(const QJsonObject &localObj, const QString &health, const QVector<QPair<QString, int>>& nvmeLogOrdered)
|
||||||
{
|
{
|
||||||
QJsonArray attributes = localObj["ata_smart_attributes"].toObject()["table"].toArray();
|
QJsonArray attributes = localObj["ata_smart_attributes"].toObject()["table"].toArray();
|
||||||
|
QJsonObject pollingMinutes = localObj["ata_smart_data"].toObject()["self_test"].toObject()["polling_minutes"].toObject();
|
||||||
QJsonObject nvmeLog = localObj["nvme_smart_health_information_log"].toObject();
|
QJsonObject nvmeLog = localObj["nvme_smart_health_information_log"].toObject();
|
||||||
QString modelName = localObj["model_name"].toString();
|
QString modelName = localObj["model_name"].toString();
|
||||||
QString firmwareVersion = localObj["firmware_version"].toString();
|
QString firmwareVersion = localObj["firmware_version"].toString();
|
||||||
@@ -294,6 +300,11 @@ void MainWindow::populateWindow(const QJsonObject &localObj, const QString &heal
|
|||||||
protocolLineEdit->setText(protocol);
|
protocolLineEdit->setText(protocol);
|
||||||
deviceNodeLineEdit->setText(name);
|
deviceNodeLineEdit->setText(name);
|
||||||
|
|
||||||
|
QStringList keys = pollingMinutes.keys();
|
||||||
|
std::sort(keys.begin(), keys.end(), [&pollingMinutes](const QString& key1, const QString& key2) {
|
||||||
|
return pollingMinutes[key1].toInt() < pollingMinutes[key2].toInt();
|
||||||
|
});
|
||||||
|
|
||||||
int rotationRateInt = localObj["rotation_rate"].toInt(-1);
|
int rotationRateInt = localObj["rotation_rate"].toInt(-1);
|
||||||
QString rotationRate;
|
QString rotationRate;
|
||||||
if (rotationRateInt > 0) {
|
if (rotationRateInt > 0) {
|
||||||
@@ -480,8 +491,21 @@ void MainWindow::populateWindow(const QJsonObject &localObj, const QString &heal
|
|||||||
|
|
||||||
if (protocol != "NVMe") {
|
if (protocol != "NVMe") {
|
||||||
addSmartAttributesTable(attributes);
|
addSmartAttributesTable(attributes);
|
||||||
|
selfTestButton->setEnabled(true);
|
||||||
|
toolMenu->clear();
|
||||||
|
|
||||||
|
int i = 0;
|
||||||
|
for (const QString& key : keys) {
|
||||||
|
QString minutes = QString::number(static_cast<int>(pollingMinutes[key].toInt()));
|
||||||
|
QString actionLabel = key + " (" + minutes + tr(" Min.)");
|
||||||
|
actionLabel[0] = actionLabel[0].toUpper();
|
||||||
|
QAction *action = new QAction(actionLabel, this);
|
||||||
|
toolMenu->addAction(action);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
addNvmeLogTable(nvmeLogOrdered);
|
addNvmeLogTable(nvmeLogOrdered);
|
||||||
|
selfTestButton->setDisabled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -575,7 +599,7 @@ void MainWindow::addNvmeLogTable(const QVector<QPair<QString, int>>& nvmeLogOrde
|
|||||||
++row;
|
++row;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!warningMessage.isEmpty()) {
|
if (!warningMessage.isEmpty()) {
|
||||||
QMessageBox::warning(nullptr, tr("Critical Warning"), warningMessage);
|
QMessageBox::warning(nullptr, tr("Critical Warning"), warningMessage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,6 +67,8 @@ private:
|
|||||||
QJsonObject deviceJson;
|
QJsonObject deviceJson;
|
||||||
QSpacerItem *buttonStretch;
|
QSpacerItem *buttonStretch;
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
|
QToolButton *selfTestButton;
|
||||||
|
QMenu *toolMenu;
|
||||||
|
|
||||||
QJsonArray devices;
|
QJsonArray devices;
|
||||||
QStringList deviceOutputs;
|
QStringList deviceOutputs;
|
||||||
|
|||||||
160
mainwindow.ui
160
mainwindow.ui
@@ -26,70 +26,6 @@
|
|||||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||||
<item>
|
<item>
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<item row="0" column="0">
|
|
||||||
<layout class="QHBoxLayout" name="disks">
|
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout"/>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="0">
|
|
||||||
<layout class="QHBoxLayout" name="navigation">
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="previousButton">
|
|
||||||
<property name="text">
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
<property name="icon">
|
|
||||||
<iconset theme="go-previous"/>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer name="horizontalSpacer_2">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Orientation::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>40</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="diskName">
|
|
||||||
<property name="text">
|
|
||||||
<string><html><head/><body><p align="center"><span style=" font-size:14pt; font-weight:700;">Hard Drive Name</span></p></body></html></string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer name="horizontalSpacer">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Orientation::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>40</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="nextButton">
|
|
||||||
<property name="text">
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
<property name="icon">
|
|
||||||
<iconset theme="go-next"/>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="0">
|
<item row="2" column="0">
|
||||||
<layout class="QHBoxLayout" name="info">
|
<layout class="QHBoxLayout" name="info">
|
||||||
<item>
|
<item>
|
||||||
@@ -300,6 +236,70 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<layout class="QHBoxLayout" name="disks">
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout"/>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<layout class="QHBoxLayout" name="navigation">
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="previousButton">
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset theme="go-previous"/>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer_2">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Orientation::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="diskName">
|
||||||
|
<property name="text">
|
||||||
|
<string><html><head/><body><p align="center"><span style=" font-size:14pt; font-weight:700;">Hard Drive Name</span></p></body></html></string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Orientation::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="nextButton">
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset theme="go-next"/>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
<item row="3" column="0">
|
<item row="3" column="0">
|
||||||
<widget class="QTableWidget" name="dataTable">
|
<widget class="QTableWidget" name="dataTable">
|
||||||
<property name="autoFillBackground">
|
<property name="autoFillBackground">
|
||||||
@@ -316,6 +316,33 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="4" column="0">
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||||
|
<item>
|
||||||
|
<widget class="QToolButton" name="selfTestButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>Start Self-test</string>
|
||||||
|
</property>
|
||||||
|
<property name="popupMode">
|
||||||
|
<enum>QToolButton::ToolButtonPopupMode::InstantPopup</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer_3">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Orientation::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
@@ -434,6 +461,11 @@
|
|||||||
<string>&Use Fahrenheit</string>
|
<string>&Use Fahrenheit</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action name="actionSelf_Test">
|
||||||
|
<property name="text">
|
||||||
|
<string>&Self Test</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections/>
|
<connections/>
|
||||||
|
|||||||
Reference in New Issue
Block a user