Add layout system and file selection logic
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.
This commit is contained in:
parent
6e8b148c81
commit
394824ce88
@ -10,7 +10,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type ItemsToConvertContract interface {
|
type ItemsToConvertContract interface {
|
||||||
Add(file *File)
|
Add(file *ffmpeg.File)
|
||||||
Clear()
|
Clear()
|
||||||
GetItems() map[int]ItemToConvertContract
|
GetItems() map[int]ItemToConvertContract
|
||||||
GetItemsContainer() *fyne.Container
|
GetItemsContainer() *fyne.Container
|
||||||
@ -41,7 +41,7 @@ func (items *itemsToConvert) GetItemsContainer() *fyne.Container {
|
|||||||
return items.itemsContainer
|
return items.itemsContainer
|
||||||
}
|
}
|
||||||
|
|
||||||
func (items *itemsToConvert) Add(file *File) {
|
func (items *itemsToConvert) Add(file *ffmpeg.File) {
|
||||||
nextId := items.nextId
|
nextId := items.nextId
|
||||||
var content *fyne.Container
|
var content *fyne.Container
|
||||||
var buttonPlay *widget.Button
|
var buttonPlay *widget.Button
|
||||||
@ -49,9 +49,15 @@ func (items *itemsToConvert) Add(file *File) {
|
|||||||
buttonPlay = widget.NewButtonWithIcon("", theme.Icon(theme.IconNameMediaPlay), func() {
|
buttonPlay = widget.NewButtonWithIcon("", theme.Icon(theme.IconNameMediaPlay), func() {
|
||||||
buttonPlay.Disable()
|
buttonPlay.Disable()
|
||||||
go func() {
|
go func() {
|
||||||
//_ = items.ffplayService.Run(FFplaySetting{
|
ffplay, err := items.ffmpeg.GetFFplay()
|
||||||
// PathToFile: file.Path,
|
if err != nil {
|
||||||
//})
|
fyne.Do(func() {
|
||||||
|
buttonPlay.Enable()
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
_ = ffplay.Play(file)
|
||||||
fyne.Do(func() {
|
fyne.Do(func() {
|
||||||
buttonPlay.Enable()
|
buttonPlay.Enable()
|
||||||
})
|
})
|
||||||
@ -108,23 +114,23 @@ func (items *itemsToConvert) Clear() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type ItemToConvertContract interface {
|
type ItemToConvertContract interface {
|
||||||
GetFile() *File
|
GetFile() *ffmpeg.File
|
||||||
GetContent() *fyne.Container
|
GetContent() *fyne.Container
|
||||||
}
|
}
|
||||||
|
|
||||||
type itemToConvert struct {
|
type itemToConvert struct {
|
||||||
file *File
|
file *ffmpeg.File
|
||||||
content *fyne.Container
|
content *fyne.Container
|
||||||
}
|
}
|
||||||
|
|
||||||
func newItemToConvert(file *File, content *fyne.Container) ItemToConvertContract {
|
func newItemToConvert(file *ffmpeg.File, content *fyne.Container) ItemToConvertContract {
|
||||||
return &itemToConvert{
|
return &itemToConvert{
|
||||||
file: file,
|
file: file,
|
||||||
content: content,
|
content: content,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (item *itemToConvert) GetFile() *File {
|
func (item *itemToConvert) GetFile() *ffmpeg.File {
|
||||||
return item.file
|
return item.file
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
package convertor
|
package convertor
|
||||||
|
|
||||||
import "errors"
|
import (
|
||||||
|
"errors"
|
||||||
|
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/ffmpeg"
|
||||||
|
)
|
||||||
|
|
||||||
type Queue struct {
|
type Queue struct {
|
||||||
Setting *ConvertSetting
|
Setting *ffmpeg.ConvertSetting
|
||||||
Status StatusContract
|
Status StatusContract
|
||||||
Error error
|
Error error
|
||||||
}
|
}
|
||||||
@ -46,7 +49,7 @@ type QueueListenerContract interface {
|
|||||||
type QueueListContract interface {
|
type QueueListContract interface {
|
||||||
AddListener(queueListener QueueListenerContract)
|
AddListener(queueListener QueueListenerContract)
|
||||||
GetItems() map[int]*Queue
|
GetItems() map[int]*Queue
|
||||||
Add(setting *ConvertSetting)
|
Add(setting *ffmpeg.ConvertSetting)
|
||||||
EventChangeQueue(key int, queue *Queue)
|
EventChangeQueue(key int, queue *Queue)
|
||||||
Remove(key int)
|
Remove(key int)
|
||||||
GetItem(key int) (*Queue, error)
|
GetItem(key int) (*Queue, error)
|
||||||
@ -72,7 +75,7 @@ func (l *queueList) GetItems() map[int]*Queue {
|
|||||||
return l.items
|
return l.items
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *queueList) Add(setting *ConvertSetting) {
|
func (l *queueList) Add(setting *ffmpeg.ConvertSetting) {
|
||||||
queue := Queue{
|
queue := Queue{
|
||||||
Setting: setting,
|
Setting: setting,
|
||||||
Status: StatusType(Waiting),
|
Status: StatusType(Waiting),
|
||||||
|
@ -1,15 +1,21 @@
|
|||||||
package controller
|
package controller
|
||||||
|
|
||||||
import (
|
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/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/gui/view"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (c *controller) convertor() {
|
func (c *controller) convertor() {
|
||||||
content := view.Convertor()
|
content := view.Convertor(c.window, c.addFileForConversion)
|
||||||
c.window.SetContent(content)
|
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) {
|
func (c *controller) settingConvertor(isAllowCancellation bool) {
|
||||||
ffmpegPath := c.app.GetFFmpegService().GetFFmpegPath()
|
ffmpegPath := c.app.GetFFmpegService().GetFFmpegPath()
|
||||||
ffprobePath := c.app.GetFFmpegService().GetFFprobePath()
|
ffprobePath := c.app.GetFFmpegService().GetFFprobePath()
|
||||||
|
@ -23,7 +23,12 @@ func NewController(app application.AppContract) ControllerContract {
|
|||||||
|
|
||||||
return &controller{
|
return &controller{
|
||||||
app: app,
|
app: app,
|
||||||
window: window.NewMainWindow(fyneWindow, app.GetProgressBarService(), app.GetItemsToConvert(), queueLayout),
|
window: window.NewMainWindow(
|
||||||
|
fyneWindow,
|
||||||
|
app.GetProgressBarService(),
|
||||||
|
app.GetItemsToConvert(),
|
||||||
|
queueLayout,
|
||||||
|
),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,14 +1,24 @@
|
|||||||
package view
|
package view
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"fyne.io/fyne/v2"
|
"fyne.io/fyne/v2"
|
||||||
|
"fyne.io/fyne/v2/canvas"
|
||||||
"fyne.io/fyne/v2/container"
|
"fyne.io/fyne/v2/container"
|
||||||
"fyne.io/fyne/v2/lang"
|
"fyne.io/fyne/v2/lang"
|
||||||
|
"fyne.io/fyne/v2/storage"
|
||||||
"fyne.io/fyne/v2/widget"
|
"fyne.io/fyne/v2/widget"
|
||||||
|
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/ffmpeg"
|
||||||
|
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/gui/window"
|
||||||
|
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/utils"
|
||||||
|
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/kernel"
|
||||||
|
"image/color"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Convertor() fyne.CanvasObject {
|
func Convertor(window window.WindowContract, addFileForConversion func(file ffmpeg.File)) fyne.CanvasObject {
|
||||||
form := newFormConvertor()
|
form := newFormConvertor(window, addFileForConversion)
|
||||||
|
|
||||||
converterVideoFilesTitle := lang.L("converterVideoFilesTitle")
|
converterVideoFilesTitle := lang.L("converterVideoFilesTitle")
|
||||||
return widget.NewCard(converterVideoFilesTitle, "", container.NewVScroll(form.getForm()))
|
return widget.NewCard(converterVideoFilesTitle, "", container.NewVScroll(form.getForm()))
|
||||||
@ -17,17 +27,146 @@ func Convertor() fyne.CanvasObject {
|
|||||||
type formConvertor struct {
|
type formConvertor struct {
|
||||||
form *widget.Form
|
form *widget.Form
|
||||||
items []*widget.FormItem
|
items []*widget.FormItem
|
||||||
|
|
||||||
|
window window.WindowContract
|
||||||
|
addFileForConversion func(file ffmpeg.File)
|
||||||
}
|
}
|
||||||
|
|
||||||
func newFormConvertor() *formConvertor {
|
func newFormConvertor(window window.WindowContract, addFileForConversion func(file ffmpeg.File)) *formConvertor {
|
||||||
f := widget.NewForm()
|
f := widget.NewForm()
|
||||||
f.SubmitText = lang.L("converterVideoFilesSubmitTitle")
|
f.SubmitText = lang.L("converterVideoFilesSubmitTitle")
|
||||||
|
|
||||||
return &formConvertor{
|
formConvertor := &formConvertor{
|
||||||
form: f,
|
form: f,
|
||||||
|
window: window,
|
||||||
|
addFileForConversion: addFileForConversion,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fileForConversion := formConvertor.newFileForConversion()
|
||||||
|
|
||||||
|
items := []*widget.FormItem{
|
||||||
|
{
|
||||||
|
Text: lang.L("fileForConversionTitle"),
|
||||||
|
Widget: fileForConversion.button,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Widget: container.NewHScroll(fileForConversion.message),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
formConvertor.form.Items = items
|
||||||
|
formConvertor.items = items
|
||||||
|
|
||||||
|
return formConvertor
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *formConvertor) getForm() *widget.Form {
|
func (f *formConvertor) getForm() *widget.Form {
|
||||||
return f.form
|
return f.form
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type fileForConversion struct {
|
||||||
|
button *widget.Button
|
||||||
|
message *canvas.Text
|
||||||
|
file *kernel.File
|
||||||
|
|
||||||
|
changeCallbacks map[int]func(err error)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *formConvertor) newFileForConversion() *fileForConversion {
|
||||||
|
message := canvas.NewText("", color.RGBA{R: 255, G: 0, B: 0, A: 255})
|
||||||
|
fileForConversion := &fileForConversion{
|
||||||
|
message: message,
|
||||||
|
|
||||||
|
changeCallbacks: map[int]func(err error){},
|
||||||
|
}
|
||||||
|
|
||||||
|
buttonTitle := lang.L("choose") + "\n" +
|
||||||
|
lang.L("or") + "\n" +
|
||||||
|
lang.L("dragAndDropFiles")
|
||||||
|
|
||||||
|
var locationURI fyne.ListableURI
|
||||||
|
|
||||||
|
fileForConversion.button = widget.NewButton(buttonTitle, func() {
|
||||||
|
f.window.NewFileOpen(func(r fyne.URIReadCloser, err error) {
|
||||||
|
fyne.Do(func() {
|
||||||
|
fileForConversion.message.Text = ""
|
||||||
|
fileForConversion.message.Refresh()
|
||||||
|
})
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
fyne.Do(func() {
|
||||||
|
fileForConversion.message.Text = err.Error()
|
||||||
|
fileForConversion.message.Refresh()
|
||||||
|
})
|
||||||
|
fileForConversion.eventSelectFile(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if r == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
f.addFileForConversion(ffmpeg.File{
|
||||||
|
Path: r.URI().Path(),
|
||||||
|
Name: r.URI().Name(),
|
||||||
|
Ext: r.URI().Extension(),
|
||||||
|
})
|
||||||
|
|
||||||
|
fileForConversion.eventSelectFile(nil)
|
||||||
|
|
||||||
|
listableURI := storage.NewFileURI(filepath.Dir(r.URI().Path()))
|
||||||
|
locationURI, _ = storage.ListerForURI(listableURI)
|
||||||
|
}, locationURI)
|
||||||
|
})
|
||||||
|
|
||||||
|
f.window.SetOnDropped(func(position fyne.Position, uris []fyne.URI) {
|
||||||
|
if len(uris) == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
isError := false
|
||||||
|
for _, uri := range uris {
|
||||||
|
info, err := os.Stat(uri.Path())
|
||||||
|
if err != nil {
|
||||||
|
isError = true
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if info.IsDir() {
|
||||||
|
isError = true
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
f.addFileForConversion(ffmpeg.File{
|
||||||
|
Path: uri.Path(),
|
||||||
|
Name: uri.Name(),
|
||||||
|
Ext: uri.Extension(),
|
||||||
|
})
|
||||||
|
|
||||||
|
fileForConversion.eventSelectFile(nil)
|
||||||
|
|
||||||
|
listableURI := storage.NewFileURI(filepath.Dir(uri.Path()))
|
||||||
|
locationURI, _ = storage.ListerForURI(listableURI)
|
||||||
|
}
|
||||||
|
|
||||||
|
if isError {
|
||||||
|
fileForConversion.message.Text = lang.L("errorDragAndDropFile")
|
||||||
|
utils.SetStringErrorStyle(fileForConversion.message)
|
||||||
|
fileForConversion.eventSelectFile(errors.New(fileForConversion.message.Text))
|
||||||
|
} else {
|
||||||
|
fyne.Do(func() {
|
||||||
|
fileForConversion.message.Text = ""
|
||||||
|
fileForConversion.message.Refresh()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
return fileForConversion
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *fileForConversion) addChangeCallback(callback func(err error)) {
|
||||||
|
c.changeCallbacks[len(c.changeCallbacks)] = callback
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *fileForConversion) eventSelectFile(err error) {
|
||||||
|
for _, changeCallback := range c.changeCallbacks {
|
||||||
|
changeCallback(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
173
internal/gui/window/layout.go
Normal file
173
internal/gui/window/layout.go
Normal file
@ -0,0 +1,173 @@
|
|||||||
|
package window
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fyne.io/fyne/v2"
|
||||||
|
"fyne.io/fyne/v2/canvas"
|
||||||
|
"fyne.io/fyne/v2/container"
|
||||||
|
"fyne.io/fyne/v2/lang"
|
||||||
|
"fyne.io/fyne/v2/theme"
|
||||||
|
"fyne.io/fyne/v2/widget"
|
||||||
|
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/application"
|
||||||
|
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/application/convertor"
|
||||||
|
)
|
||||||
|
|
||||||
|
type LayoutContract interface {
|
||||||
|
SetContent(content fyne.CanvasObject) fyne.CanvasObject
|
||||||
|
GetRContainer() RightMainContainerContract
|
||||||
|
}
|
||||||
|
|
||||||
|
type layout struct {
|
||||||
|
layoutContainer *fyne.Container
|
||||||
|
rContainer RightMainContainerContract
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewLayout(progressBarService application.ProgressBarContract, itemsToConvert convertor.ItemsToConvertContract, queueLayout QueueLayoutContract) LayoutContract {
|
||||||
|
rContainer := newRightContainer(progressBarService.GetContainer(), itemsToConvert, queueLayout)
|
||||||
|
layoutContainer := container.NewAdaptiveGrid(2, widget.NewLabel(""), rContainer.GetCanvasObject())
|
||||||
|
|
||||||
|
return &layout{
|
||||||
|
layoutContainer: layoutContainer,
|
||||||
|
rContainer: rContainer,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l *layout) SetContent(content fyne.CanvasObject) fyne.CanvasObject {
|
||||||
|
l.layoutContainer.Objects[0] = content
|
||||||
|
return l.layoutContainer
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l *layout) GetRContainer() RightMainContainerContract {
|
||||||
|
return l.rContainer
|
||||||
|
}
|
||||||
|
|
||||||
|
type RightMainContainerContract interface {
|
||||||
|
GetCanvasObject() fyne.CanvasObject
|
||||||
|
GetTabs() *container.AppTabs
|
||||||
|
SelectFileQueueTab()
|
||||||
|
SelectAddedFilesTab()
|
||||||
|
}
|
||||||
|
|
||||||
|
type rightMainContainer struct {
|
||||||
|
container fyne.CanvasObject
|
||||||
|
tabs *container.AppTabs
|
||||||
|
addedFilesTab *container.TabItem
|
||||||
|
fileQueueTab *container.TabItem
|
||||||
|
}
|
||||||
|
|
||||||
|
func newRightContainer(blockProgressbar *fyne.Container, itemsToConvert convertor.ItemsToConvertContract, queueLayout QueueLayoutContract) RightMainContainerContract {
|
||||||
|
addedFilesTab := container.NewTabItem(lang.L("addedFilesTitle"), addedFilesContainer(itemsToConvert))
|
||||||
|
fileQueueTab := container.NewTabItem(lang.L("fileQueueTitle"), fileQueueContainer(queueLayout))
|
||||||
|
|
||||||
|
tabs := container.NewAppTabs(
|
||||||
|
addedFilesTab,
|
||||||
|
fileQueueTab,
|
||||||
|
)
|
||||||
|
|
||||||
|
rightContainer := container.NewBorder(
|
||||||
|
container.NewVBox(
|
||||||
|
blockProgressbar,
|
||||||
|
widget.NewSeparator(),
|
||||||
|
),
|
||||||
|
nil,
|
||||||
|
nil,
|
||||||
|
nil,
|
||||||
|
tabs,
|
||||||
|
)
|
||||||
|
|
||||||
|
return &rightMainContainer{
|
||||||
|
container: rightContainer,
|
||||||
|
tabs: tabs,
|
||||||
|
addedFilesTab: addedFilesTab,
|
||||||
|
fileQueueTab: fileQueueTab,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *rightMainContainer) GetCanvasObject() fyne.CanvasObject {
|
||||||
|
return r.container
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *rightMainContainer) GetTabs() *container.AppTabs {
|
||||||
|
return r.tabs
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *rightMainContainer) SelectFileQueueTab() {
|
||||||
|
fyne.Do(func() {
|
||||||
|
r.tabs.Select(r.fileQueueTab)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *rightMainContainer) SelectAddedFilesTab() {
|
||||||
|
fyne.Do(func() {
|
||||||
|
r.tabs.Select(r.addedFilesTab)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func addedFilesContainer(itemsToConvert convertor.ItemsToConvertContract) *fyne.Container {
|
||||||
|
line := canvas.NewLine(theme.Color(theme.ColorNameFocus))
|
||||||
|
line.StrokeWidth = 5
|
||||||
|
checkboxAutoRemove := widget.NewCheck(
|
||||||
|
lang.L("autoClearAfterAddingToQueue"),
|
||||||
|
func(checked bool) {
|
||||||
|
itemsToConvert.SetIsAutoRemove(checked)
|
||||||
|
},
|
||||||
|
)
|
||||||
|
checkboxAutoRemove.SetChecked(itemsToConvert.GetIsAutoRemove())
|
||||||
|
|
||||||
|
buttonClear := widget.NewButton(
|
||||||
|
lang.L("clearAll"),
|
||||||
|
func() {
|
||||||
|
itemsToConvert.Clear()
|
||||||
|
},
|
||||||
|
)
|
||||||
|
buttonClear.Importance = widget.DangerImportance
|
||||||
|
return container.NewBorder(
|
||||||
|
container.NewVBox(
|
||||||
|
container.NewPadded(),
|
||||||
|
container.NewBorder(nil, nil, nil, buttonClear, container.NewHScroll(checkboxAutoRemove)),
|
||||||
|
container.NewPadded(),
|
||||||
|
line,
|
||||||
|
), nil, nil, nil,
|
||||||
|
container.NewVScroll(
|
||||||
|
container.NewBorder(
|
||||||
|
nil, nil, nil, container.NewPadded(),
|
||||||
|
container.NewVBox(
|
||||||
|
container.NewPadded(),
|
||||||
|
itemsToConvert.GetItemsContainer(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
func fileQueueContainer(queueLayout QueueLayoutContract) *fyne.Container {
|
||||||
|
title := widget.NewLabel(lang.L("queue"))
|
||||||
|
title.TextStyle.Bold = true
|
||||||
|
|
||||||
|
line := canvas.NewLine(theme.Color(theme.ColorNameFocus))
|
||||||
|
line.StrokeWidth = 5
|
||||||
|
|
||||||
|
queueLayout.GetQueueStatistics().GetWaiting().SetTitle(lang.L("waitingQueue"))
|
||||||
|
queueLayout.GetQueueStatistics().GetInProgress().SetTitle(lang.L("inProgressQueue"))
|
||||||
|
queueLayout.GetQueueStatistics().GetCompleted().SetTitle(lang.L("completedQueue"))
|
||||||
|
queueLayout.GetQueueStatistics().GetError().SetTitle(lang.L("errorQueue"))
|
||||||
|
queueLayout.GetQueueStatistics().GetTotal().SetTitle(lang.L("total"))
|
||||||
|
|
||||||
|
return container.NewBorder(
|
||||||
|
container.NewVBox(
|
||||||
|
container.NewPadded(),
|
||||||
|
container.NewHBox(title, queueLayout.GetQueueStatistics().GetCompleted().GetCheckbox(), queueLayout.GetQueueStatistics().GetError().GetCheckbox()),
|
||||||
|
container.NewHBox(queueLayout.GetQueueStatistics().GetInProgress().GetCheckbox(), queueLayout.GetQueueStatistics().GetWaiting().GetCheckbox(), queueLayout.GetQueueStatistics().GetTotal().GetCheckbox()),
|
||||||
|
container.NewPadded(),
|
||||||
|
line,
|
||||||
|
), nil, nil, nil,
|
||||||
|
container.NewVScroll(
|
||||||
|
container.NewBorder(
|
||||||
|
nil, nil, nil, container.NewPadded(),
|
||||||
|
container.NewVBox(
|
||||||
|
container.NewPadded(),
|
||||||
|
queueLayout.GetItemsContainer(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
}
|
@ -2,12 +2,7 @@ package window
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fyne.io/fyne/v2"
|
"fyne.io/fyne/v2"
|
||||||
"fyne.io/fyne/v2/canvas"
|
|
||||||
"fyne.io/fyne/v2/container"
|
|
||||||
"fyne.io/fyne/v2/dialog"
|
"fyne.io/fyne/v2/dialog"
|
||||||
"fyne.io/fyne/v2/lang"
|
|
||||||
"fyne.io/fyne/v2/theme"
|
|
||||||
"fyne.io/fyne/v2/widget"
|
|
||||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/application"
|
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/application"
|
||||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/application/convertor"
|
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/application/convertor"
|
||||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/utils"
|
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/utils"
|
||||||
@ -18,17 +13,25 @@ type WindowContract interface {
|
|||||||
Show()
|
Show()
|
||||||
InitLayout()
|
InitLayout()
|
||||||
NewFileOpen(callback func(fyne.URIReadCloser, error), location fyne.ListableURI) *dialog.FileDialog
|
NewFileOpen(callback func(fyne.URIReadCloser, error), location fyne.ListableURI) *dialog.FileDialog
|
||||||
|
NewFolderOpen(callback func(fyne.ListableURI, error), location fyne.ListableURI) *dialog.FileDialog
|
||||||
|
SetOnDropped(callback func(position fyne.Position, uris []fyne.URI))
|
||||||
|
GetLayout() LayoutContract
|
||||||
}
|
}
|
||||||
|
|
||||||
type mainWindow struct {
|
type mainWindow struct {
|
||||||
fyneWindow fyne.Window
|
fyneWindow fyne.Window
|
||||||
layout *fyne.Container
|
layout LayoutContract
|
||||||
itemsToConvert convertor.ItemsToConvertContract
|
itemsToConvert convertor.ItemsToConvertContract
|
||||||
progressBarService application.ProgressBarContract
|
progressBarService application.ProgressBarContract
|
||||||
queueLayout QueueLayoutContract
|
queueLayout QueueLayoutContract
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewMainWindow(fyneWindow fyne.Window, progressBarService application.ProgressBarContract, itemsToConvert convertor.ItemsToConvertContract, queueLayout QueueLayoutContract) WindowContract {
|
func NewMainWindow(
|
||||||
|
fyneWindow fyne.Window,
|
||||||
|
progressBarService application.ProgressBarContract,
|
||||||
|
itemsToConvert convertor.ItemsToConvertContract,
|
||||||
|
queueLayout QueueLayoutContract,
|
||||||
|
) WindowContract {
|
||||||
fyneWindow.Resize(fyne.Size{Width: 1039, Height: 599})
|
fyneWindow.Resize(fyne.Size{Width: 1039, Height: 599})
|
||||||
fyneWindow.CenterOnScreen()
|
fyneWindow.CenterOnScreen()
|
||||||
|
|
||||||
@ -42,14 +45,14 @@ func NewMainWindow(fyneWindow fyne.Window, progressBarService application.Progre
|
|||||||
|
|
||||||
func (w *mainWindow) InitLayout() {
|
func (w *mainWindow) InitLayout() {
|
||||||
fyne.Do(func() {
|
fyne.Do(func() {
|
||||||
rContainer := newRightContainer(w.progressBarService.GetContainer(), w.itemsToConvert, w.queueLayout)
|
w.layout = NewLayout(w.progressBarService, w.itemsToConvert, w.queueLayout)
|
||||||
layout := container.NewAdaptiveGrid(2, widget.NewLabel(""), rContainer.GetCanvasObject())
|
|
||||||
w.fyneWindow.SetContent(layout)
|
|
||||||
|
|
||||||
w.layout = layout
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (w *mainWindow) GetLayout() LayoutContract {
|
||||||
|
return w.layout
|
||||||
|
}
|
||||||
|
|
||||||
func (w *mainWindow) NewFileOpen(callback func(fyne.URIReadCloser, error), location fyne.ListableURI) *dialog.FileDialog {
|
func (w *mainWindow) NewFileOpen(callback func(fyne.URIReadCloser, error), location fyne.ListableURI) *dialog.FileDialog {
|
||||||
fileDialog := dialog.NewFileOpen(callback, w.fyneWindow)
|
fileDialog := dialog.NewFileOpen(callback, w.fyneWindow)
|
||||||
utils.FileDialogResize(fileDialog, w.fyneWindow)
|
utils.FileDialogResize(fileDialog, w.fyneWindow)
|
||||||
@ -60,6 +63,16 @@ func (w *mainWindow) NewFileOpen(callback func(fyne.URIReadCloser, error), locat
|
|||||||
return fileDialog
|
return fileDialog
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (w *mainWindow) NewFolderOpen(callback func(fyne.ListableURI, error), location fyne.ListableURI) *dialog.FileDialog {
|
||||||
|
fileDialog := dialog.NewFolderOpen(callback, w.fyneWindow)
|
||||||
|
utils.FileDialogResize(fileDialog, w.fyneWindow)
|
||||||
|
fileDialog.Show()
|
||||||
|
if location != nil {
|
||||||
|
fileDialog.SetLocation(location)
|
||||||
|
}
|
||||||
|
return fileDialog
|
||||||
|
}
|
||||||
|
|
||||||
func (w *mainWindow) SetContent(content fyne.CanvasObject) {
|
func (w *mainWindow) SetContent(content fyne.CanvasObject) {
|
||||||
fyne.Do(func() {
|
fyne.Do(func() {
|
||||||
if w.layout == nil {
|
if w.layout == nil {
|
||||||
@ -67,8 +80,7 @@ func (w *mainWindow) SetContent(content fyne.CanvasObject) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
w.layout.Objects[0] = content
|
w.fyneWindow.SetContent(w.layout.SetContent(content))
|
||||||
w.fyneWindow.SetContent(w.layout)
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,116 +88,8 @@ func (w *mainWindow) Show() {
|
|||||||
w.fyneWindow.Show()
|
w.fyneWindow.Show()
|
||||||
}
|
}
|
||||||
|
|
||||||
type RightMainContainerContract interface {
|
func (w *mainWindow) SetOnDropped(callback func(position fyne.Position, uris []fyne.URI)) {
|
||||||
GetCanvasObject() fyne.CanvasObject
|
|
||||||
GetTabs() *container.AppTabs
|
|
||||||
SelectFileQueueTab()
|
|
||||||
SelectAddedFilesTab()
|
|
||||||
}
|
|
||||||
|
|
||||||
type rightMainContainer struct {
|
|
||||||
container fyne.CanvasObject
|
|
||||||
tabs *container.AppTabs
|
|
||||||
addedFilesTab *container.TabItem
|
|
||||||
fileQueueTab *container.TabItem
|
|
||||||
}
|
|
||||||
|
|
||||||
func newRightContainer(blockProgressbar *fyne.Container, itemsToConvert convertor.ItemsToConvertContract, queueLayout QueueLayoutContract) RightMainContainerContract {
|
|
||||||
addedFilesTab := container.NewTabItem(lang.L("addedFilesTitle"), addedFilesContainer(itemsToConvert))
|
|
||||||
fileQueueTab := container.NewTabItem(lang.L("fileQueueTitle"), fileQueueContainer(queueLayout))
|
|
||||||
|
|
||||||
tabs := container.NewAppTabs(
|
|
||||||
addedFilesTab,
|
|
||||||
fileQueueTab,
|
|
||||||
)
|
|
||||||
|
|
||||||
rightContainer := container.NewBorder(
|
|
||||||
container.NewVBox(
|
|
||||||
blockProgressbar,
|
|
||||||
widget.NewSeparator(),
|
|
||||||
),
|
|
||||||
nil,
|
|
||||||
nil,
|
|
||||||
nil,
|
|
||||||
tabs,
|
|
||||||
)
|
|
||||||
|
|
||||||
return &rightMainContainer{
|
|
||||||
container: rightContainer,
|
|
||||||
tabs: tabs,
|
|
||||||
addedFilesTab: addedFilesTab,
|
|
||||||
fileQueueTab: fileQueueTab,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r *rightMainContainer) GetCanvasObject() fyne.CanvasObject {
|
|
||||||
return r.container
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r *rightMainContainer) GetTabs() *container.AppTabs {
|
|
||||||
return r.tabs
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r *rightMainContainer) SelectFileQueueTab() {
|
|
||||||
fyne.Do(func() {
|
fyne.Do(func() {
|
||||||
r.tabs.Select(r.fileQueueTab)
|
w.fyneWindow.SetOnDropped(callback)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *rightMainContainer) SelectAddedFilesTab() {
|
|
||||||
fyne.Do(func() {
|
|
||||||
r.tabs.Select(r.addedFilesTab)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
func addedFilesContainer(itemsToConvert convertor.ItemsToConvertContract) *fyne.Container {
|
|
||||||
line := canvas.NewLine(theme.Color(theme.ColorNameFocus))
|
|
||||||
line.StrokeWidth = 5
|
|
||||||
checkboxAutoRemove := widget.NewCheck(
|
|
||||||
lang.L("autoClearAfterAddingToQueue"),
|
|
||||||
func(checked bool) {
|
|
||||||
itemsToConvert.SetIsAutoRemove(checked)
|
|
||||||
},
|
|
||||||
)
|
|
||||||
checkboxAutoRemove.SetChecked(itemsToConvert.GetIsAutoRemove())
|
|
||||||
|
|
||||||
buttonClear := widget.NewButton(
|
|
||||||
lang.L("clearAll"),
|
|
||||||
func() {
|
|
||||||
itemsToConvert.Clear()
|
|
||||||
},
|
|
||||||
)
|
|
||||||
buttonClear.Importance = widget.DangerImportance
|
|
||||||
return container.NewVBox(
|
|
||||||
container.NewPadded(),
|
|
||||||
container.NewBorder(nil, nil, nil, buttonClear, container.NewHScroll(checkboxAutoRemove)),
|
|
||||||
container.NewPadded(),
|
|
||||||
line,
|
|
||||||
container.NewPadded(),
|
|
||||||
itemsToConvert.GetItemsContainer(),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
func fileQueueContainer(queueLayout QueueLayoutContract) *fyne.Container {
|
|
||||||
title := widget.NewLabel(lang.L("queue"))
|
|
||||||
title.TextStyle.Bold = true
|
|
||||||
|
|
||||||
line := canvas.NewLine(theme.Color(theme.ColorNameFocus))
|
|
||||||
line.StrokeWidth = 5
|
|
||||||
|
|
||||||
queueLayout.GetQueueStatistics().GetWaiting().SetTitle(lang.L("waitingQueue"))
|
|
||||||
queueLayout.GetQueueStatistics().GetInProgress().SetTitle(lang.L("inProgressQueue"))
|
|
||||||
queueLayout.GetQueueStatistics().GetCompleted().SetTitle(lang.L("completedQueue"))
|
|
||||||
queueLayout.GetQueueStatistics().GetError().SetTitle(lang.L("errorQueue"))
|
|
||||||
queueLayout.GetQueueStatistics().GetTotal().SetTitle(lang.L("total"))
|
|
||||||
|
|
||||||
return container.NewVBox(
|
|
||||||
container.NewPadded(),
|
|
||||||
container.NewHBox(title, queueLayout.GetQueueStatistics().GetCompleted().GetCheckbox(), queueLayout.GetQueueStatistics().GetError().GetCheckbox()),
|
|
||||||
container.NewHBox(queueLayout.GetQueueStatistics().GetInProgress().GetCheckbox(), queueLayout.GetQueueStatistics().GetWaiting().GetCheckbox(), queueLayout.GetQueueStatistics().GetTotal().GetCheckbox()),
|
|
||||||
container.NewPadded(),
|
|
||||||
line,
|
|
||||||
container.NewPadded(),
|
|
||||||
queueLayout.GetItemsContainer(),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user