Track current convert filenames to label UI correctly
This commit is contained in:
parent
ab79c79208
commit
50293d8af7
85
main.go
85
main.go
|
|
@ -154,35 +154,37 @@ func (c convertConfig) CoverLabel() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
type appState struct {
|
type appState struct {
|
||||||
window fyne.Window
|
window fyne.Window
|
||||||
active string
|
active string
|
||||||
lastModule string
|
lastModule string
|
||||||
source *videoSource
|
source *videoSource
|
||||||
loadedVideos []*videoSource // Multiple loaded videos for navigation
|
loadedVideos []*videoSource // Multiple loaded videos for navigation
|
||||||
currentIndex int // Current video index in loadedVideos
|
currentIndex int // Current video index in loadedVideos
|
||||||
anim *previewAnimator
|
anim *previewAnimator
|
||||||
convert convertConfig
|
convert convertConfig
|
||||||
currentFrame string
|
currentFrame string
|
||||||
player player.Controller
|
player player.Controller
|
||||||
playerReady bool
|
playerReady bool
|
||||||
playerVolume float64
|
playerVolume float64
|
||||||
playerMuted bool
|
playerMuted bool
|
||||||
lastVolume float64
|
lastVolume float64
|
||||||
playerPaused bool
|
playerPaused bool
|
||||||
playerPos float64
|
playerPos float64
|
||||||
playerLast time.Time
|
playerLast time.Time
|
||||||
progressQuit chan struct{}
|
progressQuit chan struct{}
|
||||||
convertCancel context.CancelFunc
|
convertCancel context.CancelFunc
|
||||||
playerSurf *playerSurface
|
playerSurf *playerSurface
|
||||||
convertBusy bool
|
convertBusy bool
|
||||||
convertStatus string
|
convertStatus string
|
||||||
convertProgress float64
|
convertActiveIn string
|
||||||
playSess *playSession
|
convertActiveOut string
|
||||||
jobQueue *queue.Queue
|
convertProgress float64
|
||||||
statsBar *ui.ConversionStatsBar
|
playSess *playSession
|
||||||
queueBtn *widget.Button
|
jobQueue *queue.Queue
|
||||||
queueScroll *container.Scroll
|
statsBar *ui.ConversionStatsBar
|
||||||
queueOffset fyne.Position
|
queueBtn *widget.Button
|
||||||
|
queueScroll *container.Scroll
|
||||||
|
queueOffset fyne.Position
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *appState) stopPreview() {
|
func (s *appState) stopPreview() {
|
||||||
|
|
@ -214,7 +216,11 @@ func (s *appState) updateStatsBar() {
|
||||||
} else if s.convertBusy {
|
} else if s.convertBusy {
|
||||||
// Reflect direct conversion as an active job in the stats bar
|
// Reflect direct conversion as an active job in the stats bar
|
||||||
running = 1
|
running = 1
|
||||||
jobTitle = fmt.Sprintf("Direct convert: %s", filepath.Base(s.source.Path))
|
in := filepath.Base(s.convertActiveIn)
|
||||||
|
if in == "" && s.source != nil {
|
||||||
|
in = filepath.Base(s.source.Path)
|
||||||
|
}
|
||||||
|
jobTitle = fmt.Sprintf("Direct convert: %s", in)
|
||||||
progress = s.convertProgress
|
progress = s.convertProgress
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -456,12 +462,17 @@ func (s *appState) refreshQueueView() {
|
||||||
jobs := s.jobQueue.List()
|
jobs := s.jobQueue.List()
|
||||||
// If a direct conversion is running but not represented in the queue, surface it as a pseudo job.
|
// If a direct conversion is running but not represented in the queue, surface it as a pseudo job.
|
||||||
if s.convertBusy {
|
if s.convertBusy {
|
||||||
|
in := filepath.Base(s.convertActiveIn)
|
||||||
|
if in == "" && s.source != nil {
|
||||||
|
in = filepath.Base(s.source.Path)
|
||||||
|
}
|
||||||
|
out := filepath.Base(s.convertActiveOut)
|
||||||
jobs = append([]*queue.Job{{
|
jobs = append([]*queue.Job{{
|
||||||
ID: "active-convert",
|
ID: "active-convert",
|
||||||
Type: queue.JobTypeConvert,
|
Type: queue.JobTypeConvert,
|
||||||
Status: queue.JobStatusRunning,
|
Status: queue.JobStatusRunning,
|
||||||
Title: fmt.Sprintf("Direct convert: %s", filepath.Base(s.source.Path)),
|
Title: fmt.Sprintf("Direct convert: %s", in),
|
||||||
Description: fmt.Sprintf("Output: %s", s.convert.OutputFile()),
|
Description: fmt.Sprintf("Output: %s", out),
|
||||||
Progress: s.convertProgress,
|
Progress: s.convertProgress,
|
||||||
}}, jobs...)
|
}}, jobs...)
|
||||||
}
|
}
|
||||||
|
|
@ -3698,6 +3709,8 @@ func (s *appState) startConvert(status *widget.Label, btn, cancelBtn *widget.But
|
||||||
logging.Debug(logging.CatFFMPEG, "convert command: ffmpeg %s", strings.Join(args, " "))
|
logging.Debug(logging.CatFFMPEG, "convert command: ffmpeg %s", strings.Join(args, " "))
|
||||||
s.convertBusy = true
|
s.convertBusy = true
|
||||||
s.convertProgress = 0
|
s.convertProgress = 0
|
||||||
|
s.convertActiveIn = src.Path
|
||||||
|
s.convertActiveOut = outPath
|
||||||
setStatus("Preparing conversion…")
|
setStatus("Preparing conversion…")
|
||||||
// Widget states will be updated by the UI refresh ticker
|
// Widget states will be updated by the UI refresh ticker
|
||||||
|
|
||||||
|
|
@ -3801,6 +3814,8 @@ func (s *appState) startConvert(status *widget.Label, btn, cancelBtn *widget.But
|
||||||
logging.Debug(logging.CatFFMPEG, "convert cancelled")
|
logging.Debug(logging.CatFFMPEG, "convert cancelled")
|
||||||
fyne.CurrentApp().Driver().DoFromGoroutine(func() {
|
fyne.CurrentApp().Driver().DoFromGoroutine(func() {
|
||||||
s.convertBusy = false
|
s.convertBusy = false
|
||||||
|
s.convertActiveIn = ""
|
||||||
|
s.convertActiveOut = ""
|
||||||
s.convertProgress = 0
|
s.convertProgress = 0
|
||||||
setStatus("Cancelled")
|
setStatus("Cancelled")
|
||||||
}, false)
|
}, false)
|
||||||
|
|
@ -3811,6 +3826,8 @@ func (s *appState) startConvert(status *widget.Label, btn, cancelBtn *widget.But
|
||||||
fyne.CurrentApp().Driver().DoFromGoroutine(func() {
|
fyne.CurrentApp().Driver().DoFromGoroutine(func() {
|
||||||
s.showErrorWithCopy("Conversion Failed", fmt.Errorf("convert failed: %w", err))
|
s.showErrorWithCopy("Conversion Failed", fmt.Errorf("convert failed: %w", err))
|
||||||
s.convertBusy = false
|
s.convertBusy = false
|
||||||
|
s.convertActiveIn = ""
|
||||||
|
s.convertActiveOut = ""
|
||||||
s.convertProgress = 0
|
s.convertProgress = 0
|
||||||
setStatus("Failed")
|
setStatus("Failed")
|
||||||
}, false)
|
}, false)
|
||||||
|
|
@ -3825,6 +3842,8 @@ func (s *appState) startConvert(status *widget.Label, btn, cancelBtn *widget.But
|
||||||
fyne.CurrentApp().Driver().DoFromGoroutine(func() {
|
fyne.CurrentApp().Driver().DoFromGoroutine(func() {
|
||||||
s.showErrorWithCopy("Conversion Failed", fmt.Errorf("conversion output is invalid: %w", probeErr))
|
s.showErrorWithCopy("Conversion Failed", fmt.Errorf("conversion output is invalid: %w", probeErr))
|
||||||
s.convertBusy = false
|
s.convertBusy = false
|
||||||
|
s.convertActiveIn = ""
|
||||||
|
s.convertActiveOut = ""
|
||||||
s.convertProgress = 0
|
s.convertProgress = 0
|
||||||
setStatus("Failed")
|
setStatus("Failed")
|
||||||
}, false)
|
}, false)
|
||||||
|
|
@ -3835,6 +3854,8 @@ func (s *appState) startConvert(status *widget.Label, btn, cancelBtn *widget.But
|
||||||
fyne.CurrentApp().Driver().DoFromGoroutine(func() {
|
fyne.CurrentApp().Driver().DoFromGoroutine(func() {
|
||||||
dialog.ShowInformation("Convert", fmt.Sprintf("Saved %s", outPath), s.window)
|
dialog.ShowInformation("Convert", fmt.Sprintf("Saved %s", outPath), s.window)
|
||||||
s.convertBusy = false
|
s.convertBusy = false
|
||||||
|
s.convertActiveIn = ""
|
||||||
|
s.convertActiveOut = ""
|
||||||
s.convertProgress = 100
|
s.convertProgress = 100
|
||||||
setStatus("Done")
|
setStatus("Done")
|
||||||
}, false)
|
}, false)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user