diff --git a/author_module.go b/author_module.go index e43d8f3..fb99ec8 100644 --- a/author_module.go +++ b/author_module.go @@ -161,7 +161,18 @@ func buildAuthorView(state *appState) fyne.CanvasObject { }) clearCompletedBtn.Importance = widget.LowImportance - topBar := ui.TintedBar(authorColor, container.NewHBox(backBtn, layout.NewSpacer(), clearCompletedBtn, queueBtn)) + cancelBtn := widget.NewButton("Cancel Job", func() { + if state.jobQueue != nil { + if job := state.jobQueue.CurrentRunning(); job != nil && job.Type == queue.JobTypeAuthor { + state.jobQueue.Cancel(job.ID) + } + } + }) + cancelBtn.Importance = widget.DangerImportance + state.authorCancelBtn = cancelBtn + state.updateAuthorCancelButton() + + topBar := ui.TintedBar(authorColor, container.NewHBox(backBtn, layout.NewSpacer(), cancelBtn, clearCompletedBtn, queueBtn)) bottomBar := moduleFooter(authorColor, layout.NewSpacer(), state.statsBar) tabs := container.NewAppTabs( @@ -1397,6 +1408,22 @@ func (s *appState) setAuthorProgress(percent float64) { } } +func (s *appState) updateAuthorCancelButton() { + if s.authorCancelBtn == nil { + return + } + if s.jobQueue == nil { + s.authorCancelBtn.Hide() + return + } + job := s.jobQueue.CurrentRunning() + if job != nil && job.Type == queue.JobTypeAuthor { + s.authorCancelBtn.Show() + } else { + s.authorCancelBtn.Hide() + } +} + func (s *appState) startAuthorGeneration(startNow bool) { if s.authorVideoTSPath != "" { title := authorOutputTitle(s) diff --git a/main.go b/main.go index a342b3a..d0b0c40 100644 --- a/main.go +++ b/main.go @@ -974,6 +974,7 @@ type appState struct { authorProgress float64 authorProgressBar *widget.ProgressBar authorStatusLabel *widget.Label + authorCancelBtn *widget.Button authorVideoTSPath string // Rip module state