diff options
| author | Paul Buetow <paul@buetow.org> | 2025-07-16 20:38:22 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2025-07-16 20:38:22 +0300 |
| commit | d46669426aa6b0ece71d0d05d0b6f2966686b17a (patch) | |
| tree | 9f927c3a8bc763943764ad63e3badafe8a9a7f62 /internal/gui/navigation.go | |
| parent | e49ecfe601c924fa68671477331a860acf8a62f7 (diff) | |
feat: add custom image prompt support and keyboard shortcuts
- Add text area next to image display for custom image generation prompts
- Users can specify their own prompts or leave empty for auto-generation
- Display the used prompt in the text area after generation
- Load prompts from attribution files when navigating to existing cards
- Add keyboard shortcuts for all GUI buttons:
- G: Generate, N: New Word, I: Regenerate Image, A: Regenerate Audio
- R: Regenerate All, D: Delete, P: Play audio
- Left/Right arrows: Navigate between words
- Y/N: Confirm/cancel delete dialog
- Update UI layout with equal 50/50 split between image and prompt
- Enable text wrapping in prompt text area
- Add 25% chance to ask OpenAI for creative photo style suggestions
- Fix concurrent processing to properly use custom prompts
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
Diffstat (limited to 'internal/gui/navigation.go')
| -rw-r--r-- | internal/gui/navigation.go | 61 |
1 files changed, 55 insertions, 6 deletions
diff --git a/internal/gui/navigation.go b/internal/gui/navigation.go index f24dcc1..e59b817 100644 --- a/internal/gui/navigation.go +++ b/internal/gui/navigation.go @@ -258,6 +258,28 @@ func (a *Application) loadExistingFiles(word string) { fyne.Do(func() { a.imageDisplay.SetImages(a.currentImages) }) + + // Try to load the prompt from attribution file if using OpenAI + if a.config.ImageProvider == "openai" && len(a.currentImages) > 0 { + // Look for attribution file + baseImagePath := a.currentImages[0] + attrPath := strings.TrimSuffix(baseImagePath, filepath.Ext(baseImagePath)) + "_attribution.txt" + if data, err := os.ReadFile(attrPath); err == nil { + // Parse prompt from attribution file + content := string(data) + lines := strings.Split(content, "\n") + for i, line := range lines { + if strings.HasPrefix(line, "Prompt used:") && i+1 < len(lines) { + // The prompt is on the next line + prompt := strings.TrimSpace(lines[i+1]) + fyne.Do(func() { + a.imagePromptEntry.SetText(prompt) + }) + break + } + } + } + } } fyne.Do(func() { @@ -271,14 +293,41 @@ func (a *Application) onDelete() { return } - // Confirm deletion - dialog.ShowConfirm("Delete Word", - fmt.Sprintf("Delete all files for '%s'?", a.currentWord), - func(confirm bool) { - if confirm { + // Create custom confirmation dialog with keyboard support + message := fmt.Sprintf("Delete all files for '%s'?\n\nPress Y to confirm or N to cancel", a.currentWord) + confirmDialog := dialog.NewConfirm("Delete Word", message, func(confirm bool) { + a.deleteConfirming = false + if confirm { + a.deleteCurrentWord() + } + }, a.window) + + // Set up keyboard handler for the dialog + a.deleteConfirming = true + + // Create a custom key handler for the dialog window + oldKeyHandler := a.window.Canvas().OnTypedKey() + a.window.Canvas().SetOnTypedKey(func(ev *fyne.KeyEvent) { + if a.deleteConfirming { + switch ev.Name { + case fyne.KeyY: + confirmDialog.Hide() + a.deleteConfirming = false a.deleteCurrentWord() + // Restore original key handler + a.window.Canvas().SetOnTypedKey(oldKeyHandler) + case fyne.KeyN, fyne.KeyEscape: + confirmDialog.Hide() + a.deleteConfirming = false + // Restore original key handler + a.window.Canvas().SetOnTypedKey(oldKeyHandler) } - }, a.window) + } else if oldKeyHandler != nil { + oldKeyHandler(ev) + } + }) + + confirmDialog.Show() } // deleteCurrentWord deletes all files for the current word |
