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;
|
void resizeEvent(QResizeEvent *) override;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void diskSelected(const QString &diskName);
|
void diskSelected(int index);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString searchQuery;
|
QString searchQuery;
|
||||||
|
|||||||
@@ -34,9 +34,6 @@ GridView::GridView(QWidget *parent) : QWidget(parent) {
|
|||||||
selectedColor = palette.color(QPalette::Highlight).name();
|
selectedColor = palette.color(QPalette::Highlight).name();
|
||||||
|
|
||||||
QFrame *gridFrame = new QFrame();
|
QFrame *gridFrame = new QFrame();
|
||||||
gridFrame->setStyleSheet(QString(
|
|
||||||
"QFrame { background-color: %1; border-radius: 5px; }"
|
|
||||||
).arg(bgColor, borderColor));
|
|
||||||
|
|
||||||
scrollArea = new QScrollArea();
|
scrollArea = new QScrollArea();
|
||||||
scrollArea->setWidgetResizable(true);
|
scrollArea->setWidgetResizable(true);
|
||||||
@@ -118,7 +115,7 @@ void GridView::extracted(const QVector<DiskItem> &filteredDisks, int &cols, int
|
|||||||
temperatureLabel->setAlignment(Qt::AlignCenter);
|
temperatureLabel->setAlignment(Qt::AlignCenter);
|
||||||
temperatureLabel->setStyleSheet("font-size: 10px; color: gray;");
|
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) {
|
if (selectedButton) {
|
||||||
selectedButton->setStyleSheet(iconButton->styleSheet());
|
selectedButton->setStyleSheet(iconButton->styleSheet());
|
||||||
}
|
}
|
||||||
@@ -127,6 +124,7 @@ void GridView::extracted(const QVector<DiskItem> &filteredDisks, int &cols, int
|
|||||||
QString(
|
QString(
|
||||||
"QPushButton { border: 2px solid %1; background-color: %2; }")
|
"QPushButton { border: 2px solid %1; background-color: %2; }")
|
||||||
.arg(selectedColor, hoverColor));
|
.arg(selectedColor, hoverColor));
|
||||||
|
emit diskSelected(i);
|
||||||
});
|
});
|
||||||
|
|
||||||
diskLayout->addWidget(iconButton, 0, Qt::AlignCenter);
|
diskLayout->addWidget(iconButton, 0, Qt::AlignCenter);
|
||||||
|
|||||||
@@ -93,7 +93,8 @@ MainWindow::MainWindow(QWidget *parent)
|
|||||||
|
|
||||||
statusLabel = new QLabel;
|
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->actionIgnore_C4_Reallocation_Event_Count->setChecked(settings.value("IgnoreC4", true).toBool());
|
||||||
ui->actionHEX->setChecked(settings.value("HEX", true).toBool());
|
ui->actionHEX->setChecked(settings.value("HEX", true).toBool());
|
||||||
@@ -361,6 +362,15 @@ void MainWindow::updateUI()
|
|||||||
globalNvmeSmartOrdered = nvmeSmartOrdered;
|
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);
|
buttonStretch = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum);
|
||||||
|
|||||||
Reference in New Issue
Block a user