Made it so that files for conversion are added to the queue.
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fyne.io/fyne/v2/lang"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/ffmpeg"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/ffmpeg/download/service"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/gui/view"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/utils"
|
||||
)
|
||||
|
||||
func (c *controller) convertor() {
|
||||
@@ -19,6 +22,7 @@ func (c *controller) convertor() {
|
||||
c.app.GetSetting().GetDirectoryForSaving(),
|
||||
c.setDirectoryForSaving,
|
||||
formats,
|
||||
c.addToConversion,
|
||||
)
|
||||
c.window.SetContent(content)
|
||||
}
|
||||
@@ -32,6 +36,33 @@ func (c *controller) setDirectoryForSaving(path string) {
|
||||
c.app.GetSetting().SetDirectoryForSaving(path)
|
||||
}
|
||||
|
||||
func (c *controller) addToConversion(convertSetting view.ConvertSetting) error {
|
||||
if len(c.app.GetItemsToConvert().GetItems()) == 0 {
|
||||
return errors.New(lang.L("errorNoFilesAddedForConversion"))
|
||||
}
|
||||
c.window.GetLayout().GetRContainer().SelectFileQueueTab()
|
||||
for _, item := range c.app.GetItemsToConvert().GetItems() {
|
||||
file := item.GetFile()
|
||||
if file == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
c.app.GetQueueService().Add(&ffmpeg.ConvertSetting{
|
||||
FileInput: *file,
|
||||
FileOut: ffmpeg.File{
|
||||
Path: convertSetting.DirectoryForSave + utils.PathSeparator() + file.Name + "." + convertSetting.Format,
|
||||
Name: file.Name,
|
||||
Ext: "." + convertSetting.Format,
|
||||
},
|
||||
OverwriteOutputFiles: convertSetting.OverwriteOutputFiles,
|
||||
Encoder: convertSetting.Encoder,
|
||||
})
|
||||
}
|
||||
c.app.GetItemsToConvert().AfterAddingQueue()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *controller) settingConvertor(isAllowCancellation bool) {
|
||||
ffmpegPath := c.app.GetFFmpegService().GetFFmpegPath()
|
||||
ffprobePath := c.app.GetFFmpegService().GetFFprobePath()
|
||||
|
Reference in New Issue
Block a user