summaryrefslogtreecommitdiff
path: root/internal/gui
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2025-07-19 23:35:44 +0300
committerPaul Buetow <paul@buetow.org>2025-07-19 23:35:44 +0300
commit6038d6e29d4878cccb46bf35bb9885ec7d376422 (patch)
treef7861a731ba20db54e4ca578d6cd586ad8a87ab0 /internal/gui
parent3a6c690230f769ad33bc26e2fc5d5662e38fe3d6 (diff)
feat: improve flashcard storage and audio regenerationv0.6.0
- Change default card storage from ~/Downloads to ~/.local/state/totalrecall/cards/ - Keep .apkg exports in ~/Downloads for user convenience - Fix audio regeneration to use random voice and speed (0.9-1.0) - Fix GNOME dock icon by updating StartupWMClass to "Totalrecall" - Fix navigation to properly find cards in new XDG state directory - Ensure config defaults are properly filled when using GUI mode - Bump version to 0.6.0 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Diffstat (limited to 'internal/gui')
-rw-r--r--internal/gui/app.go15
-rw-r--r--internal/gui/generator.go15
2 files changed, 25 insertions, 5 deletions
diff --git a/internal/gui/app.go b/internal/gui/app.go
index 4e70970..3e256b8 100644
--- a/internal/gui/app.go
+++ b/internal/gui/app.go
@@ -100,7 +100,8 @@ type Config struct {
// DefaultConfig returns default GUI configuration
func DefaultConfig() *Config {
homeDir, _ := os.UserHomeDir()
- outputDir := filepath.Join(homeDir, "Downloads")
+ // Use XDG Base Directory specification for state data
+ outputDir := filepath.Join(homeDir, ".local", "state", "totalrecall", "cards")
return &Config{
OutputDir: outputDir,
@@ -113,6 +114,18 @@ func DefaultConfig() *Config {
func New(config *Config) *Application {
if config == nil {
config = DefaultConfig()
+ } else {
+ // Fill in missing fields with defaults
+ defaults := DefaultConfig()
+ if config.OutputDir == "" {
+ config.OutputDir = defaults.OutputDir
+ }
+ if config.AudioFormat == "" {
+ config.AudioFormat = defaults.AudioFormat
+ }
+ if config.ImageProvider == "" {
+ config.ImageProvider = defaults.ImageProvider
+ }
}
// Ensure output directory exists
diff --git a/internal/gui/generator.go b/internal/gui/generator.go
index 316cab8..6cd0fca 100644
--- a/internal/gui/generator.go
+++ b/internal/gui/generator.go
@@ -115,12 +115,19 @@ func (a *Application) generateAudio(ctx context.Context, word string) (string, e
speed = 1.0
}
- // Update audio config with selected voice and speed
- a.audioConfig.OpenAIVoice = voice
- a.audioConfig.OpenAISpeed = speed
+ // Create a copy of audio config with selected voice and speed
+ audioConfig := *a.audioConfig
+ audioConfig.OpenAIVoice = voice
+ audioConfig.OpenAISpeed = speed
+ audioConfig.OutputDir = a.config.OutputDir // Ensure correct output directory
+
+ // Log the regeneration details
+ if isRegeneration {
+ fmt.Printf("Regenerating audio for '%s' with voice: %s, speed: %.2f\n", word, voice, speed)
+ }
// Create audio provider
- provider, err := audio.NewProvider(a.audioConfig)
+ provider, err := audio.NewProvider(&audioConfig)
if err != nil {
return "", err
}