mirror of
https://github.com/edisionnano/QDiskInfo.git
synced 2026-03-07 20:09:55 +03:00
Connect grid view buttons
This commit is contained in:
@@ -18,7 +18,7 @@ protected:
|
||||
void resizeEvent(QResizeEvent *) override;
|
||||
|
||||
signals:
|
||||
void diskSelected(const QString &diskName);
|
||||
void diskSelected(int index);
|
||||
|
||||
private:
|
||||
QString searchQuery;
|
||||
|
||||
@@ -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<DiskItem> &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<DiskItem> &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);
|
||||
|
||||
@@ -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<QPushButton *>(buttonGroup->buttons().at(selectedIndex));
|
||||
if (gridButton) {
|
||||
gridButton->click();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
buttonStretch = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum);
|
||||
|
||||
Reference in New Issue
Block a user