Cockatrice/libcockatrice_settings/libcockatrice/settings/settings_migration.h
BruebachL 24874b10cf
Some checks are pending
CodeQL / Analyze (cpp) (push) Waiting to run
CodeQL / Analyze (actions) (push) Waiting to run
Build Desktop / Configure (push) Waiting to run
Build Desktop / Debian 13 (push) Blocked by required conditions
Build Desktop / Debian 12 (push) Blocked by required conditions
Build Desktop / Fedora 44 (push) Blocked by required conditions
Build Desktop / Fedora 43 (push) Blocked by required conditions
Build Desktop / Servatrice_Debian 12 (push) Blocked by required conditions
Build Desktop / Ubuntu 24.04 (push) Blocked by required conditions
Build Desktop / Ubuntu 26.04 (push) Blocked by required conditions
Build Desktop / Arch (push) Blocked by required conditions
Build Desktop / Ubuntu 26.04 cover (push) Blocked by required conditions
Build Desktop / macOS 13 Intel (push) Blocked by required conditions
Build Desktop / macOS 14 (push) Blocked by required conditions
Build Desktop / macOS 15 (push) Blocked by required conditions
Build Desktop / macOS 26 Debug (push) Blocked by required conditions
Build Desktop / Windows 10 (push) Blocked by required conditions
Build Docker / Servatrice (arm) (push) Waiting to run
Build Docker / Servatrice (x86) (push) Waiting to run
Build Docker / Publish multi-platform Servatrice image (push) Blocked by required conditions
[GameSelector] Persist quick-filter toolbar edits and repair filter settings migration (#7500)
* [GameSelector] Persist quick-filter toolbar edits and repair filter settings migration

- Save game-filter parameters on toolbar changes, debounced with flush on close
- Repair pre-camelCase gamefilters.ini keys in place on startup
- Map the legacy creator-name filter to hostNameFilter
- Balance begin/endFilterChange in GamesProxyModel::refresh
- Align the hideIgnoredUserGames default between model and settings
- Cover the migration with regression tests

* [Review] Address RickyRister comments on filter persistence

- Rename game-type prefix constants to SCREAMING_SNAKE to match
  MIGRATION_SENTINEL_KEY and project style
- Document why GameSelector destructor flushes a pending debounced
  filter save (toolbar path has no other writer)

---------

Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
2026-10-13 07:45:08 +02:00

35 lines
1.4 KiB
C++

#ifndef SETTINGS_MIGRATION_H
#define SETTINGS_MIGRATION_H
#include <QString>
class SettingsMigration
{
public:
static bool migrateSettingsFromGlobalIni(const QString &settingsPath);
static bool migrateLegacySettings(const QString &settingsPath);
/**
* Moves pre-camelCase gamefilters.ini keys (snake_case, game_type/<hash>) to the camelCase
* keys used since #7084, for profiles that already migrated before that rename and therefore
* never pass through migrateLegacySettings again. Copies values only where the new key is
* absent, never deletes the old keys, and returns true when anything was copied. Idempotent,
* so it runs on every startup.
*/
static bool migrateGameFiltersToCamelCase(const QString &settingsPath);
/**
* Returns true when at least one of the two migrations would still do work, i.e. when a
* backup of the settings directory is worth taking before they run.
*/
static bool isMigrationPending(const QString &settingsPath);
/**
* Copies the whole settings directory to a timestamped sibling folder, so a migration that
* overwrites per-domain files can be undone by hand. Returns the backup path, or an empty
* string when there was nothing to back up or the copy failed. Never aborts the migration.
*/
static QString backupSettingsDirectory(const QString &settingsPath);
};
#endif // SETTINGS_MIGRATION_H