From 691727a9927858f871781baa5c492150943b4800 Mon Sep 17 00:00:00 2001 From: Spiros Date: Mon, 10 Jun 2024 16:24:35 +0300 Subject: [PATCH] Move self test to QMenuBar --- mainwindow.cpp | 13 +-- mainwindow.h | 3 +- mainwindow.ui | 213 +++++++++++++++++++++++-------------------------- 3 files changed, 110 insertions(+), 119 deletions(-) diff --git a/mainwindow.cpp b/mainwindow.cpp index 3f0d15f..100a2e0 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -41,9 +41,9 @@ MainWindow::MainWindow(QWidget *parent) nextButton->setFocusPolicy(Qt::NoFocus); prevButton->setFocusPolicy(Qt::NoFocus); - selfTestButton = ui->centralwidget->findChild("selfTestButton"); - toolMenu = new QMenu(selfTestButton); - selfTestButton->setMenu(toolMenu); + menuDisk = ui->menuDisk; + toolMenu = new QMenu("Self Test", this); + menuDisk->addMenu(toolMenu); toolMenu->setToolTipsVisible(true); goodColor = QColor(Qt::green); @@ -491,7 +491,7 @@ void MainWindow::populateWindow(const QJsonObject &localObj, const QString &heal if (protocol != "NVMe") { addSmartAttributesTable(attributes); - selfTestButton->show(); + toolMenu->setEnabled(true); toolMenu->clear(); int i = 0; @@ -501,11 +501,14 @@ void MainWindow::populateWindow(const QJsonObject &localObj, const QString &heal actionLabel[0] = actionLabel[0].toUpper(); QAction *action = new QAction(actionLabel, this); toolMenu->addAction(action); + connect(action, &QAction::triggered, this, [this]() { + QMessageBox::warning(this, "Warning", "This is a warning message."); + }); i++; } } else { addNvmeLogTable(nvmeLogOrdered); - selfTestButton->hide(); + toolMenu->setDisabled(true); } } diff --git a/mainwindow.h b/mainwindow.h index 2a3ce5c..18061c9 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -67,7 +67,8 @@ private: QJsonObject deviceJson; QSpacerItem *buttonStretch; QSettings settings; - QToolButton *selfTestButton; + + QMenu *menuDisk; QMenu *toolMenu; QJsonArray devices; diff --git a/mainwindow.ui b/mainwindow.ui index 5a0c8e8..9a3be40 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -26,6 +26,86 @@ + + + + + + + + + + + false + + + QFrame::Shadow::Raised + + + true + + + true + + + + + + + + + + + + + + + + + + + Qt::Orientation::Horizontal + + + + 40 + 20 + + + + + + + + <html><head/><body><p align="center"><span style=" font-size:14pt; font-weight:700;">Hard Drive Name</span></p></body></html> + + + + + + + Qt::Orientation::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + + + + @@ -236,113 +316,6 @@ - - - - - - - - - - - - - - - - - - - - - - - Qt::Orientation::Horizontal - - - - 40 - 20 - - - - - - - - <html><head/><body><p align="center"><span style=" font-size:14pt; font-weight:700;">Hard Drive Name</span></p></body></html> - - - - - - - Qt::Orientation::Horizontal - - - - 40 - 20 - - - - - - - - - - - - - - - - - - - - false - - - QFrame::Shadow::Raised - - - true - - - true - - - - - - - - - Start Self-test - - - QToolButton::ToolButtonPopupMode::InstantPopup - - - - - - - Qt::Orientation::Horizontal - - - - 40 - 20 - - - - - - @@ -363,17 +336,15 @@ - + - Function + Settings - - - + &Help @@ -381,9 +352,17 @@ + + + Disk + + + + + + - @@ -417,6 +396,9 @@ &Rescan and Refresh + + F5 + @@ -461,6 +443,11 @@ &Use Fahrenheit + + + Self Test + +