This commit is contained in:
LimeGradient 2024-05-01 07:38:52 +01:00 committed by GitHub
commit 642b583605
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 32 additions and 1 deletions

View File

@ -14,6 +14,7 @@
#include <QtConcurrent/QtConcurrentRun>
#include <QtGui>
#include <QtWidgets>
#include <QtNetwork/QtNetwork>
#include <fmt/format.h>
#ifdef __APPLE__
#include <unistd.h> // for chdir
@ -197,6 +198,7 @@ GMainWindow::GMainWindow(Core::System& system_)
InitializeRecentFileMenuActions();
InitializeSaveStateMenuActions();
InitializeHotkeys();
ShowUpdatePopup();
#if ENABLE_QT_UPDATER
ShowUpdaterWidgets();
#else
@ -272,7 +274,6 @@ GMainWindow::GMainWindow(Core::System& system_)
CheckForUpdates();
}
#endif
QStringList args = QApplication::arguments();
if (args.size() < 2) {
return;
@ -1070,6 +1071,35 @@ void GMainWindow::ShowUpdaterWidgets() {
}
#endif
void GMainWindow::ShowUpdatePopup() {
QNetworkAccessManager* manager = new QNetworkAccessManager();
QObject::connect(manager, &QNetworkAccessManager::finished, this, [&](QNetworkReply *reply) {
if (reply->error()) {
QByteArray ba = reply->errorString().toLocal8Bit();
QMessageBox::information(
this, tr("New Lime3DS Version"),
tr( ba.data()
));
manager->clearAccessCache();
return;
} else {
QJsonObject jsonObject = QJsonDocument::fromJson(reply->readAll()).object();
QString jsonTag = jsonObject[QStringLiteral("tag_name")].toString();
if (jsonTag != QString::fromUtf8(Common::g_build_fullname)) {
QMessageBox::information(
this, tr("New Lime3DS Version"),
tr( " "
"A New Version of Lime3DS is Available!"
"Download <a href='https://github.com/Lime3DS/Lime3DS/releases'>here</a>"
));
}
}
});
QUrl url(QStringLiteral("https://api.github.com/repos/Lime3DS/Lime3DS/releases/latest"));
QNetworkRequest networkRequest(url);
manager->get(networkRequest);
}
#if defined(HAVE_SDL2) && defined(__unix__) && !defined(__APPLE__)
static std::optional<QDBusObjectPath> HoldWakeLockLinux(u32 window_id = 0) {
if (!QDBusConnection::sessionBus().isConnected()) {

View File

@ -161,6 +161,7 @@ private:
void ShowNoUpdatePrompt();
void CheckForUpdates();
#endif
void ShowUpdatePopup();
/**
* Stores the filename in the recently loaded files list.