window size saved to config, smaller font in track-list

This commit is contained in:
2026-02-16 03:48:53 -05:00
parent f97e8c4840
commit 6fbe16a84b
5 changed files with 271 additions and 198 deletions
+14
View File
@@ -23,6 +23,8 @@ type Config struct {
serveMux *http.ServeMux
filePath string // required
Library *library.Config `form:"Library" schema:"library,required"`
Window *WindowConfig `toml:"Window"`
}
// NewConfig creates a new config by loading it from disk.
@@ -36,6 +38,7 @@ func NewConfig(logger *slog.Logger) (*Config, error) {
filePath: path.Join(confDir, "config.toml"),
serveMux: http.NewServeMux(),
}
conf.applyDefaults()
conf.logger = logger.WithGroup("config").With("config", conf)
conf.serveMux.HandleFunc("/", conf.handle)
@@ -99,6 +102,8 @@ func (c *Config) Load() error {
return fmt.Errorf("problem parsing config file %s: %w", c.filePath, err)
}
c.applyDefaults()
// validate the config
if err = c.Validate(); err != nil {
return fmt.Errorf("invalid config file at %s: %w", c.filePath, err)
@@ -130,6 +135,15 @@ func (c *Config) Save() error {
return nil
}
// applyDefaults ensures all config sections have valid defaults.
func (c *Config) applyDefaults() {
if c.Window == nil {
c.Window = NewDefaultWindowConfig()
} else {
c.Window.applyDefaults()
}
}
// SetContext sets the Wails runtime context for event emission.
func (c *Config) SetContext(ctx context.Context) {
c.ctx = ctx