Skip to content

Global Settings: user-selectable storage location for user data (settings JSON, bug reports, screenshots) - #1562

Draft
Gin890 wants to merge 1 commit into
mainfrom
user-data-storage-location
Draft

Gin890 wants to merge 1 commit into
mainfrom
user-data-storage-location

Conversation

@Gin890

@Gin890 Gin890 commented Oct 12, 2026

Copy link
Copy Markdown
Collaborator

The program stores user data (user setting JSON, bug reports, screenshots, ...) at a single fixed location: the current working directory on Windows/Linux, or the user application data folder on macOS. Each has a drawback: local storage is good when running multiple program installs for multiple Switches, while the user app folder survives program updates.

This PR adds UI in the Global Settings panel for the user to control this.

UI (Global Settings panel, new "Data Storage" section at the top)

  • User Data & Bug Reports Location — where the user setting JSON file and bug (error) reports are saved.
  • Screenshots Location — where screenshots are saved.

Each is a dropdown with two options: User app (the OS user application data folder, e.g. %APPDATA%/<name> on Windows, ~/Library/Application Support/<name> on macOS, ~/.local/share/<name> on Linux) and Local (the folder the program runs from; on macOS, the folder that hosts the app).

Default behavior

When these new settings are not in the setting JSON file yet, the program keeps the current platform behavior: local on Windows and Linux, user app folder on macOS. (Linux previously had no user-app-path behavior; it now defaults to local, same as before.)

How it works

  • GlobalAutoPaths gains a UserDataStorageLocation enum plus per-category location state. SETTINGS_PATH(), PROGRAM_SETTING_JSON_PATH(), ERROR_PATH(), and the error-report folders now follow the "user data" location; SCREENSHOTS_PATH() follows the "screenshots" location. All other paths (debug dumps, user files, log file, downloaded resources, ML data) keep the platform-default base.
  • At startup, DETECT_SETTINGS_STORAGE_LOCATION() (called in Main.cpp before the settings are read) checks both candidate setting JSON files and reads from the one that exists; if both exist it uses the most recently modified one, and if neither exists it uses the platform default. This way a choice made in a previous session is honored when reading the settings.
  • The two new options are persisted in the setting JSON under USER_DATA_STORAGE / SCREENSHOTS_STORAGE and keep the GlobalAutoPaths state in sync (on load and on change); switching location while running creates the folders at the new location so data can be saved there immediately.

Misc

  • Error reports now use absolute paths for the unsent/sent folders (previously CWD-relative, which did not resolve to the user app folder on macOS).
  • PersistentSettings::write() creates the setting folder if it is missing.

Testing

  • The full Qt project does not build in this sandbox, so this is a draft for review.
  • The new GlobalAutoPaths storage-location/detection logic was exercised with a standalone harness built from the real GlobalAutoPaths.cpp + Common/Cpp/Filesystem sources (all cases passed: neither file present, one file present, both present with different mtimes, runtime location switch).
  • The JSON round-trip of the new EnumDropdownOption<UserDataStorageLocation> values (default, slug load, to_json, unknown slug ignored) was verified against the real options framework.

Please review the per-OS path choices (Filesystem_Windows.h / Filesystem_Mac.h / Filesystem_Linux.h) in particular.

The program previously stored user data (user setting JSON, bug reports,
screenshots, ...) at a single location: the current working directory on
Windows/Linux, or the user application data folder on macOS.

Add a new "Data Storage" section at the top of the Global Settings panel
with two dropdown menus, each with two options ("User app" / "Local"):

- User Data & Bug Reports Location: where the user setting JSON file and
  bug (error) reports are saved.
- Screenshots Location: where screenshots are saved.

When the new settings are not in the setting JSON file yet, the program
defaults to the previous platform behavior: local on Windows and Linux,
user app folder on macOS.

Implementation:
- Filesystem: new application_user_data_path() per OS (Windows:
  %APPDATA%/<name>, macOS: ~/Library/Application Support/<name>,
  Linux: $XDG_DATA_HOME or ~/.local/share/<name>) and a
  last_write_time() wrapper.
- GlobalAutoPaths: new UserDataStorageLocation enum and per-category
  storage location state; SETTINGS_PATH/PROGRAM_SETTING_JSON_PATH/
  ERROR_PATH/error report paths follow the user data location, and
  SCREENSHOTS_PATH follows the screenshots location. All other paths
  (debug dumps, user files, downloaded resources, ML) keep the
  platform default base.
- Startup: DETECT_SETTINGS_STORAGE_LOCATION() picks the storage location
  holding the newest setting JSON file (platform default if neither
  exists or on a tie), so a choice made in a previous session is honored
  when reading the settings.
- GlobalSettings: the two new EnumDropdownOption values are persisted
  under the keys USER_DATA_STORAGE / SCREENSHOTS_STORAGE, and keep the
  GlobalAutoPaths state in sync on load and on change.
- Error reports now use absolute paths (fixes the CWD-relative sent/
  unsent folders on macOS).
- PersistentSettings::write() creates the setting folder if missing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant