mirror of
https://github.com/edisionnano/QDiskInfo.git
synced 2026-03-11 15:20:52 +03:00
Lay the groundwork for selftesting
This commit is contained in:
@@ -41,6 +41,11 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
nextButton->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);
|
||||
cautionColor = QColor(Qt::yellow);
|
||||
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)
|
||||
{
|
||||
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();
|
||||
QString modelName = localObj["model_name"].toString();
|
||||
QString firmwareVersion = localObj["firmware_version"].toString();
|
||||
@@ -294,6 +300,11 @@ void MainWindow::populateWindow(const QJsonObject &localObj, const QString &heal
|
||||
protocolLineEdit->setText(protocol);
|
||||
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);
|
||||
QString rotationRate;
|
||||
if (rotationRateInt > 0) {
|
||||
@@ -480,8 +491,21 @@ void MainWindow::populateWindow(const QJsonObject &localObj, const QString &heal
|
||||
|
||||
if (protocol != "NVMe") {
|
||||
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 {
|
||||
addNvmeLogTable(nvmeLogOrdered);
|
||||
selfTestButton->setDisabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -575,7 +599,7 @@ void MainWindow::addNvmeLogTable(const QVector<QPair<QString, int>>& nvmeLogOrde
|
||||
++row;
|
||||
}
|
||||
|
||||
if(!warningMessage.isEmpty()) {
|
||||
if (!warningMessage.isEmpty()) {
|
||||
QMessageBox::warning(nullptr, tr("Critical Warning"), warningMessage);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,6 +67,8 @@ private:
|
||||
QJsonObject deviceJson;
|
||||
QSpacerItem *buttonStretch;
|
||||
QSettings settings;
|
||||
QToolButton *selfTestButton;
|
||||
QMenu *toolMenu;
|
||||
|
||||
QJsonArray devices;
|
||||
QStringList deviceOutputs;
|
||||
|
||||
160
mainwindow.ui
160
mainwindow.ui
@@ -26,70 +26,6 @@
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<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">
|
||||
<layout class="QHBoxLayout" name="info">
|
||||
<item>
|
||||
@@ -300,6 +236,70 @@
|
||||
</item>
|
||||
</layout>
|
||||
</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">
|
||||
<widget class="QTableWidget" name="dataTable">
|
||||
<property name="autoFillBackground">
|
||||
@@ -316,6 +316,33 @@
|
||||
</property>
|
||||
</widget>
|
||||
</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>
|
||||
</item>
|
||||
</layout>
|
||||
@@ -434,6 +461,11 @@
|
||||
<string>&Use Fahrenheit</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionSelf_Test">
|
||||
<property name="text">
|
||||
<string>&Self Test</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
|
||||
Reference in New Issue
Block a user