diff options
| author | Paul Buetow <paul@buetow.org> | 2025-07-19 17:06:36 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2025-07-19 17:06:36 +0300 |
| commit | d663a312ff5f45513a23adf9eb9ffb29377bbad9 (patch) | |
| tree | f88d4beb3905cab49887081ff5559b2db7ea1c33 /internal | |
| parent | 77538381c28e4de8fa7d3f3731412c97699bb889 (diff) | |
feat: improve export functionality and fix configuration issues
- Add custom export directory selection in GUI export dialog
- Change default export directory from ~/.local/state/totalrecall to ~/Downloads
- Remove broken voice configuration from config file (voice is always random)
- Fix discrepancies between code defaults and example config
- Remove unimplemented image cache settings from example config
The voice configuration was not working due to a bug where it only read from config if
the command-line flag was set to "nova" (but default was empty string). Since voices
are randomly selected anyway, this configuration option has been removed.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
Diffstat (limited to 'internal')
| -rw-r--r-- | internal/gui/app.go | 43 |
1 files changed, 39 insertions, 4 deletions
diff --git a/internal/gui/app.go b/internal/gui/app.go index 2226eb1..7e63ab8 100644 --- a/internal/gui/app.go +++ b/internal/gui/app.go @@ -14,6 +14,7 @@ import ( "fyne.io/fyne/v2/container" "fyne.io/fyne/v2/dialog" "fyne.io/fyne/v2/layout" + "fyne.io/fyne/v2/storage" "fyne.io/fyne/v2/theme" "fyne.io/fyne/v2/widget" fynetooltip "github.com/dweymouth/fyne-tooltip" @@ -94,8 +95,11 @@ type Config struct { // DefaultConfig returns default GUI configuration func DefaultConfig() *Config { + homeDir, _ := os.UserHomeDir() + outputDir := filepath.Join(homeDir, "Downloads") + return &Config{ - OutputDir: "./anki_cards", + OutputDir: outputDir, AudioFormat: "mp3", ImageProvider: "openai", } @@ -112,7 +116,7 @@ func New(config *Config) *Application { ctx, cancel := context.WithCancel(context.Background()) - myApp := app.New() + myApp := app.NewWithID("org.codeberg.snonux.totalrecall") myApp.SetIcon(GetAppIcon()) app := &Application{ @@ -893,12 +897,43 @@ func (a *Application) onExportToAnki() { deckNameEntry := widget.NewEntry() deckNameEntry.SetPlaceHolder("Bulgarian Vocabulary") + // Export directory selection + homeDir, _ := os.UserHomeDir() + defaultExportDir := filepath.Join(homeDir, "Downloads") + selectedDir := defaultExportDir + + dirLabel := widget.NewLabel(selectedDir) + + dirButton := widget.NewButton("Browse...", func() { + folderDialog := dialog.NewFolderOpen(func(dir fyne.ListableURI, err error) { + if err != nil || dir == nil { + return + } + selectedDir = dir.Path() + dirLabel.SetText(selectedDir) + }, a.window) + + // Try to set initial directory + if uri, err := storage.ParseURI("file://" + selectedDir); err == nil { + if listableURI, ok := uri.(fyne.ListableURI); ok { + folderDialog.SetLocation(listableURI) + } + } + + folderDialog.Show() + }) + + dirContainer := container.NewBorder(nil, nil, nil, dirButton, dirLabel) + content := container.NewVBox( widget.NewLabel("Export Format:"), formatSelect, widget.NewSeparator(), widget.NewLabel("Deck Name:"), deckNameEntry, + widget.NewSeparator(), + widget.NewLabel("Export Directory:"), + dirContainer, widget.NewLabel(""), widget.NewRichTextFromMarkdown("**APKG**: Complete package with media files included\n**CSV**: Text only, requires manual media copy"), ) @@ -924,7 +959,7 @@ func (a *Application) onExportToAnki() { if isAPKG { filename = fmt.Sprintf("%s.apkg", internal.SanitizeFilename(deckName)) - outputPath = filepath.Join(a.config.OutputDir, filename) + outputPath = filepath.Join(selectedDir, filename) // Generate APKG from all cards in directory gen := anki.NewGenerator(nil) @@ -948,7 +983,7 @@ func (a *Application) onExportToAnki() { total, outputPath, withAudio, withImages)) } else { filename = "anki_import.csv" - outputPath = filepath.Join(a.config.OutputDir, filename) + outputPath = filepath.Join(selectedDir, filename) // Generate CSV from all cards in directory gen := anki.NewGenerator(&anki.GeneratorOptions{ |
