refactor(config): consolidate settings into one grouped settings.json
App preferences were spread across six flat plain-text files (settings.txt,
recent.txt, recent_limit.txt, statusbar.txt, ribbon.txt, plot.txt), each with a
bespoke line parser and no grouping. Replace them with a single grouped JSON,
serialized via serde (enabling the derive feature; serde_json was already a
dependency).
- New app/config.rs: AppConfig { settings, recent, statusbar, ribbon, plot } →
<config>/settings.json (pretty JSON), load()/save().
- Make UserSettings, StatusBarConfig/StatusPill, CollapseMode and
PlotDialogState serde-derived; #[serde(skip)] marks the plot dialog's runtime
fields so only print preferences persist. Their bespoke .txt load/save is
removed.
- App gains current_config/apply_config/save_config: one AppConfig::load at
startup distributes into live state; every settings-change site
(persist_settings_if_changed, recent add/remove/limit, status-bar pill
toggle, ribbon density, plot commit) routes through save_config, which diffs
against the last write to avoid thrashing.
- Clean start: the old flat files are ignored (no migration). ocad.pgp stays a
separate hand-editable file.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
256f9a282b
commit
dc7117f203
12 changed files with 227 additions and 410 deletions
|
|
@ -641,6 +641,7 @@ impl OpenCADStudio {
|
|||
Message::SetRibbonCollapseMode(mode) => {
|
||||
self.ribbon.set_collapse_mode(mode);
|
||||
self.ribbon.close_dropdown();
|
||||
self.save_config();
|
||||
Task::none()
|
||||
}
|
||||
|
||||
|
|
@ -1674,6 +1675,7 @@ impl OpenCADStudio {
|
|||
Message::ToggleStatusPill(pill) => {
|
||||
// Keep the menu open so several pills can be toggled in a row.
|
||||
self.statusbar_config.toggle(pill);
|
||||
self.save_config();
|
||||
Task::none()
|
||||
}
|
||||
Message::ToggleCleanScreen => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue