diff --git a/include/gridview.h b/include/gridview.h index 42c3755..628eebf 100644 --- a/include/gridview.h +++ b/include/gridview.h @@ -18,7 +18,7 @@ protected: void resizeEvent(QResizeEvent *) override; signals: - void diskSelected(const QString &diskName); + void diskSelected(int index); private: QString searchQuery; diff --git a/src/gridview.cpp b/src/gridview.cpp index e805f17..2b00ad2 100644 --- a/src/gridview.cpp +++ b/src/gridview.cpp @@ -34,9 +34,6 @@ GridView::GridView(QWidget *parent) : QWidget(parent) { selectedColor = palette.color(QPalette::Highlight).name(); QFrame *gridFrame = new QFrame(); - gridFrame->setStyleSheet(QString( - "QFrame { background-color: %1; border-radius: 5px; }" - ).arg(bgColor, borderColor)); scrollArea = new QScrollArea(); scrollArea->setWidgetResizable(true); @@ -118,7 +115,7 @@ void GridView::extracted(const QVector &filteredDisks, int &cols, int temperatureLabel->setAlignment(Qt::AlignCenter); temperatureLabel->setStyleSheet("font-size: 10px; color: gray;"); - connect(iconButton, &QPushButton::clicked, this, [this, iconButton]() { + connect(iconButton, &QPushButton::clicked, this, [this, iconButton, disk, i]() { if (selectedButton) { selectedButton->setStyleSheet(iconButton->styleSheet()); } @@ -127,6 +124,7 @@ void GridView::extracted(const QVector &filteredDisks, int &cols, int QString( "QPushButton { border: 2px solid %1; background-color: %2; }") .arg(selectedColor, hoverColor)); + emit diskSelected(i); }); diskLayout->addWidget(iconButton, 0, Qt::AlignCenter); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 38f297c..56e8524 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -93,7 +93,8 @@ MainWindow::MainWindow(QWidget *parent) statusLabel = new QLabel; - gridView = new GridView(nullptr); + gridView = new GridView(this); + gridView->setWindowFlag(Qt::Window); ui->actionIgnore_C4_Reallocation_Event_Count->setChecked(settings.value("IgnoreC4", true).toBool()); ui->actionHEX->setChecked(settings.value("HEX", true).toBool()); @@ -361,6 +362,15 @@ void MainWindow::updateUI() globalNvmeSmartOrdered = nvmeSmartOrdered; } } + + connect(gridView, &GridView::diskSelected, this, [=](int selectedIndex) { + if (selectedIndex >= 0 && selectedIndex < buttonGroup->buttons().size()) { + auto *gridButton = qobject_cast(buttonGroup->buttons().at(selectedIndex)); + if (gridButton) { + gridButton->click(); + } + } + }); } buttonStretch = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum);