Paragon qsettings#751
Open
mrdeadlocked wants to merge 2 commits into
Open
Conversation
…des cleanup of old values in ini.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
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.
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.