diff --git a/cockatrice/src/client/ui/window_main.cpp b/cockatrice/src/client/ui/window_main.cpp index 2a847423d..6f4212a34 100644 --- a/cockatrice/src/client/ui/window_main.cpp +++ b/cockatrice/src/client/ui/window_main.cpp @@ -40,6 +40,7 @@ #include "../../settings/cache_settings.h" #include "../../utility/logger.h" #include "../get_text_with_max.h" +#include "../network/client_update_checker.h" #include "../tabs/tab_game.h" #include "../tabs/tab_supervisor.h" #include "pb/event_connection_closed.pb.h" @@ -879,6 +880,10 @@ MainWindow::MainWindow(QWidget *parent) void MainWindow::startupConfigCheck() { + if (SettingsCache::instance().getCheckUpdatesOnStartup()) { + actCheckClientUpdates(); + } + if (SettingsCache::instance().getClientVersion() == CLIENT_INFO_NOT_SET) { // no config found, 99% new 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(); }); } +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() { ShortcutsSettings &shortcuts = SettingsCache::instance().shortcuts(); diff --git a/cockatrice/src/client/ui/window_main.h b/cockatrice/src/client/ui/window_main.h index 2b240beb1..0c52200ce 100644 --- a/cockatrice/src/client/ui/window_main.h +++ b/cockatrice/src/client/ui/window_main.h @@ -30,6 +30,7 @@ #include #include +class Release; class DlgConnect; class DlgViewLog; class GameReplay; @@ -49,6 +50,7 @@ class MainWindow : public QMainWindow public slots: void actCheckCardUpdates(); void actCheckServerUpdates(); + void actCheckClientUpdates(); private slots: void updateTabMenu(const QList &newMenuList); void statusChanged(ClientStatus _status); @@ -95,6 +97,8 @@ private slots: void cardDatabaseNewSetsFound(int numUnknownSets, QStringList unknownSetsNames); void cardDatabaseAllNewSetsEnabled(); + void checkClientUpdatesFinished(bool needToUpdate, bool isCompatible, Release *release); + void actOpenCustomFolder(); void actOpenCustomsetsFolder(); void actAddCustomSet();