From 61a2923f4056322e15258716d5e190963bb1bacd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20Br=C3=BCbach?= Date: Sun, 11 Oct 2026 17:46:33 +0200 Subject: [PATCH] [Tutorial] Seed tutorialCompleted for existing installs at startup --- cockatrice/src/client/settings/cache_settings.cpp | 12 ++++++++++++ .../libcockatrice/settings/interface_settings.cpp | 8 -------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/cockatrice/src/client/settings/cache_settings.cpp b/cockatrice/src/client/settings/cache_settings.cpp index 15a41e7e1..1df35068d 100644 --- a/cockatrice/src/client/settings/cache_settings.cpp +++ b/cockatrice/src/client/settings/cache_settings.cpp @@ -113,6 +113,12 @@ SettingsCache::SettingsCache() QString settingsPath = getSettingsPath(); + // Decide once, before any migration writes new files, whether this is an + // existing install. Fresh installs have no *.ini files and no legacy + // NativeFormat keys; upgrades have one or the other. + const bool hadExistingSettings = + !QDir(settingsPath).entryList({"*.ini"}, QDir::Files).isEmpty() || !QSettings().allKeys().isEmpty(); + settings = new QSettings(settingsPath + "global.ini", QSettings::IniFormat, this); // Both migrations below overwrite per-domain files in place, so snapshot the whole settings @@ -154,6 +160,12 @@ SettingsCache::SettingsCache() personalSettings = new PersonalSettings(settingsPath, this); cardsDisplaySettings = new CardsDisplaySettings(settingsPath, this); interfaceSettings = new InterfaceSettings(settingsPath, this); + if (hadExistingSettings) { + QSettings iface(settingsPath + "interface.ini", QSettings::IniFormat); + if (!iface.contains("interface/tutorialCompleted")) { + interfaceSettings->setTutorialCompleted(true); + } + } deckEditorSettings = new DeckEditorSettings(settingsPath, this); pathsSettings = new PathsSettings(settingsPath, this); visualDeckStorageSettings = new VisualDeckStorageSettings(settingsPath, this); diff --git a/libcockatrice_settings/libcockatrice/settings/interface_settings.cpp b/libcockatrice_settings/libcockatrice/settings/interface_settings.cpp index fe934fd8f..e516d3a59 100644 --- a/libcockatrice_settings/libcockatrice/settings/interface_settings.cpp +++ b/libcockatrice_settings/libcockatrice/settings/interface_settings.cpp @@ -205,14 +205,6 @@ bool InterfaceSettings::getShowGameSelectorFilterToolbar() const bool InterfaceSettings::getTutorialCompleted() const { - // Upgrading users have settings files but no tutorial key yet: treat the tutorial as seen so they are - // not overlaid on upgrade. Genuinely new installs have no settings files at all, so they still get it. - if (!getSettings().contains("interface/tutorialCompleted")) { - QDir settingsDir = QFileInfo(settingPath).dir(); - if (!settingsDir.entryList({"*.ini"}, QDir::Files).isEmpty()) { - return true; - } - } return getValue("tutorialCompleted", QString(), QString(), false).toBool(); }