Shorten queue descriptions and wrap text to keep controls visible

This commit is contained in:
Stu Leak 2025-12-08 18:13:18 -05:00
parent 4f6746594a
commit 6ad72ecc46
3 changed files with 25 additions and 1 deletions

View File

@ -119,6 +119,7 @@ func buildJobItem(
descLabel := widget.NewLabel(job.Description)
descLabel.TextStyle = fyne.TextStyle{Italic: true}
descLabel.Wrapping = fyne.TextWrapWord
// Progress bar (for running jobs)
progress := widget.NewProgressBar()

View File

@ -8,6 +8,7 @@ import (
"path/filepath"
"strconv"
"strings"
"unicode/utf8"
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/widget"
@ -51,6 +52,28 @@ func FirstNonEmpty(values ...string) string {
return "--"
}
// ShortenMiddle shortens a string to max runes, keeping start and end with ellipsis in the middle.
func ShortenMiddle(s string, max int) string {
if max <= 0 {
return ""
}
if utf8.RuneCountInString(s) <= max {
return s
}
ellipsis := "…"
keep := max - utf8.RuneCountInString(ellipsis)
if keep <= 0 {
return s[:max]
}
left := keep / 2
right := keep - left
runes := []rune(s)
if left+right >= len(runes) {
return s
}
return string(runes[:left]) + ellipsis + string(runes[len(runes)-right:])
}
// Parsing utilities
// ParseFloat parses a float64 from a string

View File

@ -918,7 +918,7 @@ func (s *appState) addConvertToQueue() error {
job := &queue.Job{
Type: queue.JobTypeConvert,
Title: fmt.Sprintf("Convert %s", filepath.Base(src.Path)),
Description: fmt.Sprintf("Output: %s → %s", filepath.Base(src.Path), filepath.Base(outPath)),
Description: fmt.Sprintf("Output: %s → %s", utils.ShortenMiddle(filepath.Base(src.Path), 40), utils.ShortenMiddle(filepath.Base(outPath), 40)),
InputFile: src.Path,
OutputFile: outPath,
Config: config,