check for client updates on startup

This commit is contained in:
RickyRister 2024-12-27 23:02:33 -08:00
parent fac5058e7a
commit fa1334fb4a
2 changed files with 24 additions and 0 deletions

View file

@ -40,6 +40,7 @@
#include "../../settings/cache_settings.h" #include "../../settings/cache_settings.h"
#include "../../utility/logger.h" #include "../../utility/logger.h"
#include "../get_text_with_max.h" #include "../get_text_with_max.h"
#include "../network/client_update_checker.h"
#include "../tabs/tab_game.h" #include "../tabs/tab_game.h"
#include "../tabs/tab_supervisor.h" #include "../tabs/tab_supervisor.h"
#include "pb/event_connection_closed.pb.h" #include "pb/event_connection_closed.pb.h"
@ -879,6 +880,10 @@ MainWindow::MainWindow(QWidget *parent)
void MainWindow::startupConfigCheck() void MainWindow::startupConfigCheck()
{ {
if (SettingsCache::instance().getCheckUpdatesOnStartup()) {
actCheckClientUpdates();
}
if (SettingsCache::instance().getClientVersion() == CLIENT_INFO_NOT_SET) { if (SettingsCache::instance().getClientVersion() == CLIENT_INFO_NOT_SET) {
// no config found, 99% new clean install // no config found, 99% new clean install
qDebug() << "Startup: old client version empty, assuming first start after clean install"; qDebug() << "Startup: old client version empty, assuming first start after clean install";
@ -1223,6 +1228,21 @@ void MainWindow::actCheckServerUpdates()
connect(hps, &HandlePublicServers::sigPublicServersDownloadedSuccessfully, [=]() { hps->deleteLater(); }); connect(hps, &HandlePublicServers::sigPublicServersDownloadedSuccessfully, [=]() { hps->deleteLater(); });
} }
void MainWindow::actCheckClientUpdates()
{
auto checker = new ClientUpdateChecker(this);
connect(checker, &ClientUpdateChecker::finishedCheck, this, &MainWindow::checkClientUpdatesFinished);
checker->check();
}
void MainWindow::checkClientUpdatesFinished(bool needToUpdate, bool /* isCompatible */, Release * /* release */)
{
if (needToUpdate) {
DlgUpdate dlg(this);
dlg.exec();
}
}
void MainWindow::refreshShortcuts() void MainWindow::refreshShortcuts()
{ {
ShortcutsSettings &shortcuts = SettingsCache::instance().shortcuts(); ShortcutsSettings &shortcuts = SettingsCache::instance().shortcuts();

View file

@ -30,6 +30,7 @@
#include <QSystemTrayIcon> #include <QSystemTrayIcon>
#include <QtNetwork> #include <QtNetwork>
class Release;
class DlgConnect; class DlgConnect;
class DlgViewLog; class DlgViewLog;
class GameReplay; class GameReplay;
@ -49,6 +50,7 @@ class MainWindow : public QMainWindow
public slots: public slots:
void actCheckCardUpdates(); void actCheckCardUpdates();
void actCheckServerUpdates(); void actCheckServerUpdates();
void actCheckClientUpdates();
private slots: private slots:
void updateTabMenu(const QList<QMenu *> &newMenuList); void updateTabMenu(const QList<QMenu *> &newMenuList);
void statusChanged(ClientStatus _status); void statusChanged(ClientStatus _status);
@ -95,6 +97,8 @@ private slots:
void cardDatabaseNewSetsFound(int numUnknownSets, QStringList unknownSetsNames); void cardDatabaseNewSetsFound(int numUnknownSets, QStringList unknownSetsNames);
void cardDatabaseAllNewSetsEnabled(); void cardDatabaseAllNewSetsEnabled();
void checkClientUpdatesFinished(bool needToUpdate, bool isCompatible, Release *release);
void actOpenCustomFolder(); void actOpenCustomFolder();
void actOpenCustomsetsFolder(); void actOpenCustomsetsFolder();
void actAddCustomSet(); void actAddCustomSet();