Introduce a new layout system for managing main window content and tabs. Integrate file selection and drag-and-drop functionality for adding files to the conversion list, with automatic tab switching to "Added Files". Refactor existing components to support these features.
65 lines
1.5 KiB
Go
65 lines
1.5 KiB
Go
package controller
|
|
|
|
import (
|
|
"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"
|
|
)
|
|
|
|
func (c *controller) convertor() {
|
|
content := view.Convertor(c.window, c.addFileForConversion)
|
|
c.window.SetContent(content)
|
|
}
|
|
|
|
func (c *controller) addFileForConversion(file ffmpeg.File) {
|
|
c.app.GetItemsToConvert().Add(&file)
|
|
c.window.GetLayout().GetRContainer().SelectAddedFilesTab()
|
|
}
|
|
|
|
func (c *controller) settingConvertor(isAllowCancellation bool) {
|
|
ffmpegPath := c.app.GetFFmpegService().GetFFmpegPath()
|
|
ffprobePath := c.app.GetFFmpegService().GetFFprobePath()
|
|
ffplayPath := c.app.GetFFmpegService().GetFFplayPath()
|
|
|
|
var cancel func()
|
|
cancel = nil
|
|
if isAllowCancellation {
|
|
cancel = func() {
|
|
c.convertor()
|
|
}
|
|
}
|
|
|
|
content := view.ConfiguringFFmpegUtilities(
|
|
c.window,
|
|
ffmpegPath,
|
|
ffprobePath,
|
|
ffplayPath,
|
|
c.saveSettingConvertor,
|
|
cancel,
|
|
service.DownloadFFmpeg(c.app, c.saveSettingConvertor),
|
|
)
|
|
c.window.SetContent(content)
|
|
}
|
|
|
|
func (c *controller) saveSettingConvertor(ffmpegPath string, ffprobePath string, ffplayPath string) error {
|
|
var err error
|
|
|
|
err = c.app.GetFFmpegService().ChangeFFmpeg(ffmpegPath)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
c.app.GetFFmpegService().ChangeFFprobe(ffprobePath)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
c.app.GetFFmpegService().ChangeFFplay(ffplayPath)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
c.convertor()
|
|
return nil
|
|
}
|