aboutsummaryrefslogtreecommitdiff
path: root/gui/internal/model/prefs.go
diff options
context:
space:
mode:
authorLukasz Kasprzak <lukas@labunix.xyz>2026-09-17 14:16:19 +0200
committerLukasz Kasprzak <lukas@labunix.xyz>2026-09-17 14:16:19 +0200
commitf74a02254ac15a84d38c9a254ead293ebaad2377 (patch)
treea5e4139e91aa2afea5769dff856d887cda735a83 /gui/internal/model/prefs.go
parent6d28cf285f9944eb26c7ed0efcce558521b51cb9 (diff)
downloadkrino-f74a02254ac15a84d38c9a254ead293ebaad2377.tar.gz
krino-f74a02254ac15a84d38c9a254ead293ebaad2377.zip
Settings changes take effect, and keep this copy respects the plan
Five of the Settings window's controls - the sort order, the three column toggles and the preview height - were read when it built its new preferences but never connected to anything, so changing them did nothing until some other control happened to fire, and then they all landed at once out of nowhere. Every control is connected now. The same closure composed a whole Prefs from its own widgets, which wrote the remembered divider positions back as zeros: dragging the panes to taste and then ticking any checkbox threw them away. A settings change is now applied over the preferences as they are, by model.Prefs.WithDisplay - which is where it can be tested, and is. "Keep this copy, replace the other" wrote a Displaces straight into the chain. internal/plan refuses to build two steps that displace one path, because the second destroys what the first put there; the window went round that code, so choosing it for two duplicates of one file left both rows saying "done" with the first file in the Trash. It now refuses the second, naming the file that has the place.
Diffstat (limited to 'gui/internal/model/prefs.go')
-rw-r--r--gui/internal/model/prefs.go38
1 files changed, 38 insertions, 0 deletions
diff --git a/gui/internal/model/prefs.go b/gui/internal/model/prefs.go
index f5ffee5..9ae79a0 100644
--- a/gui/internal/model/prefs.go
+++ b/gui/internal/model/prefs.go
@@ -112,3 +112,41 @@ func (p Prefs) Save() error {
}
return os.WriteFile(file, append(data, '\n'), 0o644)
}
+
+// Display is everything the Settings window can change about the window
+// itself. It deliberately leaves out the divider positions: those are set
+// by dragging, and a settings change must not disturb them. Composing a
+// whole Prefs in the Settings window instead is what used to write
+// PreviewWidth, ListWidth and ListHeight back as zeros, so dragging the
+// panes to taste and then ticking any checkbox threw the panes away.
+type Display struct {
+ Sort string
+ Layout string
+ ShowSize bool
+ ShowAge bool
+ ShowRule bool
+ Colours bool
+ Preview bool
+ SelectAll bool
+ PreviewHeight int
+}
+
+// DisplayOf is the part of p the Settings window shows.
+func (p Prefs) DisplayOf() Display {
+ return Display{
+ Sort: p.Sort, Layout: p.Layout,
+ ShowSize: p.ShowSize, ShowAge: p.ShowAge, ShowRule: p.ShowRule,
+ Colours: p.Colours, Preview: p.Preview, SelectAll: p.SelectAll,
+ PreviewHeight: p.PreviewHeight,
+ }
+}
+
+// WithDisplay is p with d applied and everything else - where each divider
+// was left - kept as it was.
+func (p Prefs) WithDisplay(d Display) Prefs {
+ p.Sort, p.Layout = d.Sort, d.Layout
+ p.ShowSize, p.ShowAge, p.ShowRule = d.ShowSize, d.ShowAge, d.ShowRule
+ p.Colours, p.Preview, p.SelectAll = d.Colours, d.Preview, d.SelectAll
+ p.PreviewHeight = d.PreviewHeight
+ return p
+}