mirror of
https://github.com/edisionnano/QDiskInfo.git
synced 2026-03-12 07:40:54 +03:00
Make the next prev buttons work with shortcuts + mouse buttons
This commit is contained in:
@@ -34,6 +34,8 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
|
||||
nextButton = ui->centralwidget->findChild<QPushButton*>("nextButton");
|
||||
prevButton = ui->centralwidget->findChild<QPushButton*>("previousButton");
|
||||
nextButton->setShortcut(QKeySequence::Forward);
|
||||
prevButton->setShortcut(QKeySequence::Back);
|
||||
|
||||
connect(nextButton, &QPushButton::clicked, this, &MainWindow::onNextButtonClicked);
|
||||
connect(prevButton, &QPushButton::clicked, this, &MainWindow::onPrevButtonClicked);
|
||||
@@ -92,7 +94,7 @@ void MainWindow::onPrevButtonClicked()
|
||||
updateNavigationButtons(prevIndex);
|
||||
}
|
||||
|
||||
void MainWindow::updateNavigationButtons(int currentIndex)
|
||||
void MainWindow::updateNavigationButtons(int currentIndex) // WIP: Add option to roll back instead of disabling them
|
||||
{
|
||||
prevButton->setEnabled(currentIndex > 0); // We can use setVisible if we want to mimic CrystalDiskInfo
|
||||
nextButton->setEnabled(currentIndex < buttonGroup->buttons().size() - 1);
|
||||
@@ -985,3 +987,12 @@ void MainWindow::cancelSelfTest(const QString &deviceNode)
|
||||
QMessageBox::critical(this, tr("KDiskInfo Error"), tr("Error: Something went wrong"));
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
if (event->button() == Qt::ForwardButton && nextButton->isEnabled()) {
|
||||
onNextButtonClicked();
|
||||
} else if (event->button() == Qt::BackButton && prevButton->isEnabled()) {
|
||||
onPrevButtonClicked();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user