Skip to content

Paragon qsettings#751

Open
mrdeadlocked wants to merge 2 commits into
d4lfteam:mainfrom
mrdeadlocked:paragon_qsettings
Open

Paragon qsettings#751
mrdeadlocked wants to merge 2 commits into
d4lfteam:mainfrom
mrdeadlocked:paragon_qsettings

Conversation

@mrdeadlocked
Copy link
Copy Markdown
Contributor

The transition of the Paragon Overlay settings from a legacy INI file (params.ini) to QSettings was designed to standardize how UI state is persisted across the application, moving it into the Windows Registry (or native platform equivalent) while ensuring a seamless transition for existing users.

Here is a breakdown of the key components of those changes:

  1. Standardization with QSettings
    Previously, the Paragon overlay stored its coordinates, cell sizes, and toggle states in the [paragon_overlay] section of params.ini. By switching to QSettings("d4lf", "ParagonOverlay"), we:

Reduced File I/O: QSettings is optimized for frequent UI updates (like saving a position after a drag).
Cleaned up Configs: params.ini is now reserved for high-level user configurations, while ephemeral UI state (like zoom levels) is handled by the system registry.
2. The One-Time Migration Logic
To prevent users from losing their carefully calibrated grid positions, we implemented a migration check in _load_overlay_settings:

The Trigger: We use a specific key, migration_done, in the registry. If this key is missing or false, the overlay attempts to find your old settings.
Path Detection: The code was updated to aggressively look for params.ini in the standard ~/.d4lf/ directory, ensuring it finds the legacy data regardless of whether you are running from source or an executable.
3. Automatic Cleanup
The _import_settings_from_ini function does more than just copy data. Once it successfully reads the legacy [paragon_overlay] section and writes those values into QSettings, it:

Removes the [paragon_overlay] section from your params.ini.
Writes the cleaned params.ini back to disk.
Sets migration_done to true in the registry and calls qs.sync() to force an immediate save.
4. Robust Parsing and Defaulting
The new _load_overlay_settings uses a local parse helper that safely handles type conversions. This is important because QSettings sometimes returns strings for boolean values if they were just migrated from an INI file. It ensures that even if a value in the registry is malformed, the overlay falls back to a sensible default rather than crashing.

  1. Explicit Synchronization
    In _save_overlay_settings, we added qs.sync(). While QSettings eventually flushes data to the registry automatically, calling sync() explicitly ensures that if the application or overlay crashes shortly after a change, your grid position and settings are guaranteed to be saved.

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