Revive the right block of the program
Moved the right part of the program from the old version. Slightly reworked the structure.
This commit is contained in:
@@ -2,11 +2,14 @@ package window
|
||||
|
||||
import (
|
||||
"fyne.io/fyne/v2"
|
||||
"fyne.io/fyne/v2/canvas"
|
||||
"fyne.io/fyne/v2/container"
|
||||
"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/convertor"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/utils"
|
||||
)
|
||||
|
||||
@@ -20,22 +23,26 @@ type WindowContract interface {
|
||||
type mainWindow struct {
|
||||
fyneWindow fyne.Window
|
||||
layout *fyne.Container
|
||||
itemsToConvert convertor.ItemsToConvertContract
|
||||
progressBarService application.ProgressBarContract
|
||||
queueLayout QueueLayoutContract
|
||||
}
|
||||
|
||||
func NewMainWindow(fyneWindow fyne.Window, progressBarService application.ProgressBarContract) WindowContract {
|
||||
func NewMainWindow(fyneWindow fyne.Window, progressBarService application.ProgressBarContract, itemsToConvert convertor.ItemsToConvertContract, queueLayout QueueLayoutContract) WindowContract {
|
||||
fyneWindow.Resize(fyne.Size{Width: 1039, Height: 599})
|
||||
fyneWindow.CenterOnScreen()
|
||||
|
||||
return &mainWindow{
|
||||
fyneWindow: fyneWindow,
|
||||
progressBarService: progressBarService,
|
||||
itemsToConvert: itemsToConvert,
|
||||
queueLayout: queueLayout,
|
||||
}
|
||||
}
|
||||
|
||||
func (w *mainWindow) InitLayout() {
|
||||
fyne.Do(func() {
|
||||
rContainer := newRightContainer(w.progressBarService.GetContainer())
|
||||
rContainer := newRightContainer(w.progressBarService.GetContainer(), w.itemsToConvert, w.queueLayout)
|
||||
layout := container.NewAdaptiveGrid(2, widget.NewLabel(""), rContainer.GetCanvasObject())
|
||||
w.fyneWindow.SetContent(layout)
|
||||
|
||||
@@ -72,31 +79,20 @@ func (w *mainWindow) Show() {
|
||||
type RightMainContainerContract interface {
|
||||
GetCanvasObject() fyne.CanvasObject
|
||||
GetTabs() *container.AppTabs
|
||||
GetAddedFilesContainer() *fyne.Container
|
||||
GetFileQueueContainer() *fyne.Container
|
||||
SelectFileQueueTab()
|
||||
SelectAddedFilesTab()
|
||||
}
|
||||
|
||||
type rightMainContainer struct {
|
||||
container fyne.CanvasObject
|
||||
|
||||
tabs *container.AppTabs
|
||||
|
||||
addedFilesContainer *fyne.Container
|
||||
addedFilesTab *container.TabItem
|
||||
|
||||
fileQueueContainer *fyne.Container
|
||||
fileQueueTab *container.TabItem
|
||||
container fyne.CanvasObject
|
||||
tabs *container.AppTabs
|
||||
addedFilesTab *container.TabItem
|
||||
fileQueueTab *container.TabItem
|
||||
}
|
||||
|
||||
func newRightContainer(blockProgressbar *fyne.Container) RightMainContainerContract {
|
||||
|
||||
addedFilesContainer := container.NewVBox()
|
||||
addedFilesTab := container.NewTabItem(lang.L("addedFilesTitle"), addedFilesContainer)
|
||||
|
||||
fileQueueContainer := container.NewVBox()
|
||||
fileQueueTab := container.NewTabItem(lang.L("fileQueueTitle"), fileQueueContainer)
|
||||
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,
|
||||
@@ -115,12 +111,10 @@ func newRightContainer(blockProgressbar *fyne.Container) RightMainContainerContr
|
||||
)
|
||||
|
||||
return &rightMainContainer{
|
||||
container: rightContainer,
|
||||
tabs: tabs,
|
||||
addedFilesContainer: addedFilesContainer,
|
||||
addedFilesTab: addedFilesTab,
|
||||
fileQueueContainer: fileQueueContainer,
|
||||
fileQueueTab: fileQueueTab,
|
||||
container: rightContainer,
|
||||
tabs: tabs,
|
||||
addedFilesTab: addedFilesTab,
|
||||
fileQueueTab: fileQueueTab,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,14 +126,6 @@ func (r *rightMainContainer) GetTabs() *container.AppTabs {
|
||||
return r.tabs
|
||||
}
|
||||
|
||||
func (r *rightMainContainer) GetAddedFilesContainer() *fyne.Container {
|
||||
return r.addedFilesContainer
|
||||
}
|
||||
|
||||
func (r *rightMainContainer) GetFileQueueContainer() *fyne.Container {
|
||||
return r.fileQueueContainer
|
||||
}
|
||||
|
||||
func (r *rightMainContainer) SelectFileQueueTab() {
|
||||
fyne.Do(func() {
|
||||
r.tabs.Select(r.fileQueueTab)
|
||||
@@ -151,3 +137,55 @@ func (r *rightMainContainer) SelectAddedFilesTab() {
|
||||
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(),
|
||||
)
|
||||
}
|
||||
|
Reference in New Issue
Block a user