mirror of
https://github.com/edisionnano/QDiskInfo.git
synced 2026-04-14 16:41:28 +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");
|
nextButton = ui->centralwidget->findChild<QPushButton*>("nextButton");
|
||||||
prevButton = ui->centralwidget->findChild<QPushButton*>("previousButton");
|
prevButton = ui->centralwidget->findChild<QPushButton*>("previousButton");
|
||||||
|
nextButton->setShortcut(QKeySequence::Forward);
|
||||||
|
prevButton->setShortcut(QKeySequence::Back);
|
||||||
|
|
||||||
connect(nextButton, &QPushButton::clicked, this, &MainWindow::onNextButtonClicked);
|
connect(nextButton, &QPushButton::clicked, this, &MainWindow::onNextButtonClicked);
|
||||||
connect(prevButton, &QPushButton::clicked, this, &MainWindow::onPrevButtonClicked);
|
connect(prevButton, &QPushButton::clicked, this, &MainWindow::onPrevButtonClicked);
|
||||||
@@ -92,7 +94,7 @@ void MainWindow::onPrevButtonClicked()
|
|||||||
updateNavigationButtons(prevIndex);
|
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
|
prevButton->setEnabled(currentIndex > 0); // We can use setVisible if we want to mimic CrystalDiskInfo
|
||||||
nextButton->setEnabled(currentIndex < buttonGroup->buttons().size() - 1);
|
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"));
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
|
#include <QMouseEvent>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
#include "statusdot.h"
|
#include "statusdot.h"
|
||||||
@@ -92,5 +93,6 @@ private:
|
|||||||
void clearButtonGroup();
|
void clearButtonGroup();
|
||||||
QString initiateSelfTest(const QString &testType, const QString &deviceNode);
|
QString initiateSelfTest(const QString &testType, const QString &deviceNode);
|
||||||
void cancelSelfTest(const QString &deviceNode);
|
void cancelSelfTest(const QString &deviceNode);
|
||||||
|
void mousePressEvent(QMouseEvent*);
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user