js8call/JS8_Mainwindow/checkVersion.cpp
Chris-AC9KH 8c647b5a9e Move MainWindow member functions to external source files in
JS8_Mainwindow:
- buildQueryMap.cpp
- checkVersion.cpp
- dataSink.cpp
- displayBandActivity.cpp
- displayCallActivity.cpp
- initializeDummyDate.cpp
- initializeGroupMessage.cpp
- networkMessage.cpp
- processCommandActivity.cpp
- processDecodeEvent.cpp
- processRxActivity.cpp

reduces mainwindow.cpp from 12,482 to 8,284 lines of code
2026-01-06 22:47:39 -06:00

55 lines
2.3 KiB
C++

#include "JS8_UI/mainwindow.h"
void MainWindow::checkVersion(bool const alertOnUpToDate) {
auto m = new QNetworkAccessManager(this);
connect(m, &QNetworkAccessManager::finished, this,
[this, alertOnUpToDate](QNetworkReply *reply) {
if (reply->error()) {
qCDebug(mainwindow_js8) << "Checking for Updates Error:"
<< reply->errorString();
return;
}
QString content = reply->readAll().trimmed();
auto const currentVersion =
QVersionNumber::fromString(version());
auto const networkVersion = QVersionNumber::fromString(content);
qCDebug(mainwindow_js8) << "Checking Version" << currentVersion
<< "with" << networkVersion;
if (currentVersion < networkVersion) {
SelfDestructMessageBox *m = new SelfDestructMessageBox(
60, "New Updates Available",
QString("A new version (%1) of JS8Call is now "
"available. Please see the <a "
"href='https://github.com/JS8Call-improved/"
"JS8Call-improved/releases'>GitHub "
"Releases</a> for more details.")
.arg(content),
QMessageBox::Information, QMessageBox::Ok,
QMessageBox::Ok, false, this);
m->show();
} else if (alertOnUpToDate) {
SelfDestructMessageBox *m = new SelfDestructMessageBox(
60, "No Updates Available",
QString("Your version (%1) of JS8Call is up-to-date.")
.arg(version()),
QMessageBox::Information, QMessageBox::Ok,
QMessageBox::Ok, false, this);
m->show();
}
});
qCDebug(mainwindow_js8) << "Checking for Updates...";
QUrl url("https://github.com/JS8Call-improved/JS8Call-improved/releases/"
"latest/download/version.txt");
QNetworkRequest r(url);
m->get(r);
}