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.
78 lines
1.7 KiB
Go
78 lines
1.7 KiB
Go
package controller
|
|
|
|
import (
|
|
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/application"
|
|
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/application/setting"
|
|
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/gui/view"
|
|
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/gui/window"
|
|
)
|
|
|
|
type ControllerContract interface {
|
|
Start()
|
|
}
|
|
|
|
type controller struct {
|
|
app application.AppContract
|
|
window window.WindowContract
|
|
}
|
|
|
|
func NewController(app application.AppContract) ControllerContract {
|
|
fyneWindow := app.FyneApp().NewWindow(app.FyneApp().Metadata().Name)
|
|
queueLayout := window.NewQueueLayout()
|
|
app.GetQueueService().AddListener(queueLayout)
|
|
|
|
return &controller{
|
|
app: app,
|
|
window: window.NewMainWindow(
|
|
fyneWindow,
|
|
app.GetProgressBarService(),
|
|
app.GetItemsToConvert(),
|
|
queueLayout,
|
|
),
|
|
}
|
|
}
|
|
|
|
func (c *controller) Start() {
|
|
isDefault, err := c.initLanguage()
|
|
if err != nil {
|
|
c.startWithError(err)
|
|
c.window.Show()
|
|
return
|
|
}
|
|
|
|
if isDefault {
|
|
languages := c.app.GetSetting().GetLanguages()
|
|
content := view.StartWithoutSupportLang(languages, func(lang setting.Lang) {
|
|
err = c.app.GetSetting().SetLang(lang)
|
|
if err != nil {
|
|
c.startWithError(err)
|
|
return
|
|
}
|
|
c.window.InitLayout()
|
|
c.verificareaFFmpeg()
|
|
})
|
|
c.window.SetContent(content)
|
|
c.window.Show()
|
|
return
|
|
}
|
|
|
|
c.window.InitLayout()
|
|
c.verificareaFFmpeg()
|
|
c.window.Show()
|
|
}
|
|
|
|
func (c *controller) verificareaFFmpeg() {
|
|
if !c.app.GetFFmpegService().UtilityCheck() {
|
|
c.settingConvertor(false)
|
|
return
|
|
}
|
|
|
|
c.convertor()
|
|
}
|
|
|
|
func (c *controller) initLanguage() (isDefault bool, err error) {
|
|
lang, isDefault := c.app.GetSetting().GetCurrentLangOrDefaultLang()
|
|
err = setting.ChangeLang(lang)
|
|
return isDefault, err
|
|
}
|