2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-12-09 00:27:42 +00:00

General: Make use of Qt 5's signal/slot connection syntax

Allows compile-time detection of incompatible signals/slots, as opposed
to runtime errors, making the connections more type-safe.
This commit is contained in:
Lioncash
2019-08-25 20:21:03 -04:00
parent a357648a99
commit 2ccc59fc0c
3 changed files with 40 additions and 40 deletions

View File

@@ -88,12 +88,13 @@ MainWindow::MainWindow(QWidget* parent)
QPalette pal = m_updateURDEButton->palette();
pal.setColor(QPalette::Button, QColor(53, 53, 72));
m_updateURDEButton->setPalette(pal);
connect(m_updateURDEButton, SIGNAL(clicked()), this, SLOT(onUpdateURDEPressed()));
connect(m_updateURDEButton, &QPushButton::clicked, this, &MainWindow::onUpdateURDEPressed);
qDebug() << "Stored track " << m_settings.value("update_track");
int index = skUpdateTracks.indexOf(m_settings.value("update_track").toString());
const int index = skUpdateTracks.indexOf(m_settings.value("update_track").toString());
m_ui->devTrackWarning->setVisible(index == 1);
m_ui->updateTrackComboBox->setCurrentIndex(index);
connect(m_ui->updateTrackComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(onUpdateTrackChanged(int)));
connect(m_ui->updateTrackComboBox, qOverload<int>(&QComboBox::currentIndexChanged), this,
&MainWindow::onUpdateTrackChanged);
m_dlManager.connectWidgets(m_ui->downloadProgressBar, m_ui->downloadErrorLabel,
std::bind(&MainWindow::onIndexDownloaded, this, std::placeholders::_1),
@@ -128,8 +129,8 @@ void MainWindow::onExtract() {
env.insert("TERM", "xterm-color");
env.insert("ConEmuANSI", "ON");
m_heclProc.setProcessEnvironment(env);
disconnect(&m_heclProc, SIGNAL(finished(int)), nullptr, nullptr);
connect(&m_heclProc, SIGNAL(finished(int)), this, SLOT(onExtractFinished(int)));
disconnect(&m_heclProc, qOverload<int>(&QProcess::finished), nullptr, nullptr);
connect(&m_heclProc, qOverload<int>(&QProcess::finished), this, &MainWindow::onExtractFinished);
m_heclProc.start(m_heclPath, {"extract", "-y", "-g", "-o", m_path, imgPath},
QIODevice::ReadOnly | QIODevice::Unbuffered);
@@ -138,15 +139,15 @@ void MainWindow::onExtract() {
disableOperations();
m_ui->extractBtn->setText(QStringLiteral("Cancel"));
m_ui->extractBtn->setEnabled(true);
disconnect(m_ui->extractBtn, SIGNAL(clicked()), nullptr, nullptr);
connect(m_ui->extractBtn, SIGNAL(clicked()), this, SLOT(doHECLTerminate()));
disconnect(m_ui->extractBtn, &QPushButton::clicked, nullptr, nullptr);
connect(m_ui->extractBtn, &QPushButton::clicked, this, &MainWindow::doHECLTerminate);
}
void MainWindow::onExtractFinished(int returnCode) {
m_cursor.movePosition(QTextCursor::End);
m_cursor.insertBlock();
disconnect(m_ui->extractBtn, SIGNAL(clicked()), nullptr, nullptr);
connect(m_ui->extractBtn, SIGNAL(clicked()), this, SLOT(onExtract()));
disconnect(m_ui->extractBtn, &QPushButton::clicked, nullptr, nullptr);
connect(m_ui->extractBtn, &QPushButton::clicked, this, &MainWindow::onExtract);
checkDownloadedBinary();
}
@@ -161,8 +162,8 @@ void MainWindow::onPackage() {
env.insert("TERM", "xterm-color");
env.insert("ConEmuANSI", "ON");
m_heclProc.setProcessEnvironment(env);
disconnect(&m_heclProc, SIGNAL(finished(int)), nullptr, nullptr);
connect(&m_heclProc, SIGNAL(finished(int)), this, SLOT(onPackageFinished(int)));
disconnect(&m_heclProc, qOverload<int>(&QProcess::finished), nullptr, nullptr);
connect(&m_heclProc, qOverload<int>(&QProcess::finished), this, &MainWindow::onPackageFinished);
m_heclProc.start(m_heclPath, {"package", "-y", "-g"}, QIODevice::ReadOnly | QIODevice::Unbuffered);
m_ui->heclTabs->setCurrentIndex(0);
@@ -170,8 +171,8 @@ void MainWindow::onPackage() {
disableOperations();
m_ui->packageBtn->setText(QStringLiteral("Cancel"));
m_ui->packageBtn->setEnabled(true);
disconnect(m_ui->packageBtn, SIGNAL(clicked()), nullptr, nullptr);
connect(m_ui->packageBtn, SIGNAL(clicked()), this, SLOT(doHECLTerminate()));
disconnect(m_ui->packageBtn, &QPushButton::clicked, nullptr, nullptr);
connect(m_ui->packageBtn, &QPushButton::clicked, this, &MainWindow::doHECLTerminate);
QSize size = QWidget::size();
if (size.width() < 1100)
@@ -182,8 +183,8 @@ void MainWindow::onPackage() {
void MainWindow::onPackageFinished(int returnCode) {
m_cursor.movePosition(QTextCursor::End);
m_cursor.insertBlock();
disconnect(m_ui->packageBtn, SIGNAL(clicked()), nullptr, nullptr);
connect(m_ui->packageBtn, SIGNAL(clicked()), this, SLOT(onPackage()));
disconnect(m_ui->packageBtn, &QPushButton::clicked, nullptr, nullptr);
connect(m_ui->packageBtn, &QPushButton::clicked, this, &MainWindow::onPackage);
checkDownloadedBinary();
}
@@ -198,8 +199,8 @@ void MainWindow::onLaunch() {
env.insert("TERM", "xterm-color");
env.insert("ConEmuANSI", "ON");
m_heclProc.setProcessEnvironment(env);
disconnect(&m_heclProc, SIGNAL(finished(int)), nullptr, nullptr);
connect(&m_heclProc, SIGNAL(finished(int)), this, SLOT(onLaunchFinished(int)));
disconnect(&m_heclProc, qOverload<int>(&QProcess::finished), nullptr, nullptr);
connect(&m_heclProc, qOverload<int>(&QProcess::finished), this, &MainWindow::onLaunchFinished);
m_heclProc.start(m_urdePath, QStringList() << (m_path + "/out")
<< m_settings.value("urde_arguments").toStringList().join(' ').split(' '),
QIODevice::ReadOnly | QIODevice::Unbuffered);
@@ -449,9 +450,9 @@ void MainWindow::initSlots() {
setTextTermFormatting(bytes);
});
connect(m_ui->extractBtn, SIGNAL(clicked()), this, SLOT(onExtract()));
connect(m_ui->packageBtn, SIGNAL(clicked()), this, SLOT(onPackage()));
connect(m_ui->launchBtn, SIGNAL(clicked()), this, SLOT(onLaunch()));
connect(m_ui->extractBtn, &QPushButton::clicked, this, &MainWindow::onExtract);
connect(m_ui->packageBtn, &QPushButton::clicked, this, &MainWindow::onPackage);
connect(m_ui->launchBtn, &QPushButton::clicked, this, &MainWindow::onLaunch);
m_ui->launchMenuBtn->setMenu(&m_launchMenu);
connect(m_ui->browseBtn, &QPushButton::clicked, [=]() {
@@ -468,7 +469,7 @@ void MainWindow::initSlots() {
setPath(dialog.selectedFiles().at(0));
});
connect(m_ui->downloadButton, SIGNAL(clicked()), this, SLOT(onDownloadPressed()));
connect(m_ui->downloadButton, &QPushButton::clicked, this, &MainWindow::onDownloadPressed);
}
void MainWindow::setTextTermFormatting(const QString& text) {