Replaced the `i18n` and `toml` dependencies with Fyne's built-in language system for localization management. Updated the `Localizer` implementation to handle translations using JSON files and embed functionality. Simplified language selection and persisted settings via Fyne's preferences API.
61 lines
1.5 KiB
Go
61 lines
1.5 KiB
Go
package convertor
|
|
|
|
import (
|
|
"fyne.io/fyne/v2"
|
|
"fyne.io/fyne/v2/canvas"
|
|
"fyne.io/fyne/v2/container"
|
|
"fyne.io/fyne/v2/widget"
|
|
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/convertor/view"
|
|
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/kernel"
|
|
"image/color"
|
|
)
|
|
|
|
type ViewContract interface {
|
|
Main(
|
|
formConversion view.ConversionContract,
|
|
)
|
|
SelectFFPath(
|
|
ffmpegPath string,
|
|
ffprobePath string,
|
|
ffplayPath string,
|
|
save func(ffmpegPath string, ffprobePath string, ffplayPath string) error,
|
|
cancel func(),
|
|
donwloadFFmpeg func(progressBar *widget.ProgressBar, progressMessage *canvas.Text) error,
|
|
)
|
|
}
|
|
|
|
type View struct {
|
|
app kernel.AppContract
|
|
downloadFFmpeg *downloadFFmpeg
|
|
}
|
|
|
|
type downloadFFmpeg struct {
|
|
isDownloadFFmpeg bool
|
|
blockDownloadFFmpegContainer *fyne.Container
|
|
}
|
|
|
|
func NewView(app kernel.AppContract) *View {
|
|
return &View{
|
|
app: app,
|
|
downloadFFmpeg: &downloadFFmpeg{
|
|
blockDownloadFFmpegContainer: nil,
|
|
},
|
|
}
|
|
}
|
|
|
|
func (v View) Main(formConversion view.ConversionContract) {
|
|
converterVideoFilesTitle := v.app.GetLocalizerService().GetMessage("converterVideoFilesTitle")
|
|
v.app.GetWindow().SetContent(widget.NewCard(converterVideoFilesTitle, "", container.NewVScroll(formConversion.GetContent())))
|
|
formConversion.AfterViewContent()
|
|
}
|
|
|
|
func setStringErrorStyle(text *canvas.Text) {
|
|
text.Color = color.RGBA{R: 255, G: 0, B: 0, A: 255}
|
|
text.Refresh()
|
|
}
|
|
|
|
func setStringSuccessStyle(text *canvas.Text) {
|
|
text.Color = color.RGBA{R: 49, G: 127, B: 114, A: 255}
|
|
text.Refresh()
|
|
}
|