2024-01-14 16:31:07 +06:00
|
|
|
package error
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fyne.io/fyne/v2"
|
|
|
|
"fyne.io/fyne/v2/container"
|
|
|
|
"fyne.io/fyne/v2/widget"
|
2024-02-04 21:00:55 +06:00
|
|
|
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/src/localizer"
|
2024-01-28 22:01:16 +06:00
|
|
|
"github.com/nicksnyder/go-i18n/v2/i18n"
|
2024-01-14 16:31:07 +06:00
|
|
|
)
|
|
|
|
|
|
|
|
type ViewContract interface {
|
|
|
|
PanicError(err error)
|
|
|
|
}
|
|
|
|
|
|
|
|
type View struct {
|
2024-01-28 22:01:16 +06:00
|
|
|
w fyne.Window
|
|
|
|
localizerService localizer.ServiceContract
|
2024-01-14 16:31:07 +06:00
|
|
|
}
|
|
|
|
|
2024-01-28 22:01:16 +06:00
|
|
|
func NewView(w fyne.Window, localizerService localizer.ServiceContract) *View {
|
|
|
|
return &View{
|
|
|
|
w: w,
|
|
|
|
localizerService: localizerService,
|
|
|
|
}
|
2024-01-14 16:31:07 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
func (v View) PanicError(err error) {
|
2024-01-28 22:01:16 +06:00
|
|
|
messageHead := v.localizerService.GetMessage(&i18n.LocalizeConfig{
|
|
|
|
MessageID: "error",
|
|
|
|
})
|
|
|
|
|
|
|
|
v.w.SetContent(container.NewBorder(
|
|
|
|
container.NewVBox(
|
|
|
|
widget.NewLabel(messageHead),
|
|
|
|
widget.NewLabel(err.Error()),
|
|
|
|
),
|
|
|
|
nil,
|
|
|
|
nil,
|
|
|
|
nil,
|
|
|
|
localizer.LanguageSelectionForm(v.localizerService, func(lang localizer.Lang) {
|
|
|
|
v.PanicError(err)
|
|
|
|
}),
|
|
|
|
))
|
|
|
|
}
|
|
|
|
|
|
|
|
func (v View) PanicErrorWriteDirectoryData() {
|
|
|
|
message := v.localizerService.GetMessage(&i18n.LocalizeConfig{
|
|
|
|
MessageID: "errorDatabase",
|
|
|
|
})
|
|
|
|
messageHead := v.localizerService.GetMessage(&i18n.LocalizeConfig{
|
|
|
|
MessageID: "error",
|
|
|
|
})
|
|
|
|
|
|
|
|
v.w.SetContent(container.NewBorder(
|
|
|
|
container.NewVBox(
|
|
|
|
widget.NewLabel(messageHead),
|
|
|
|
widget.NewLabel(message),
|
|
|
|
),
|
|
|
|
nil,
|
|
|
|
nil,
|
|
|
|
nil,
|
|
|
|
localizer.LanguageSelectionForm(v.localizerService, func(lang localizer.Lang) {
|
|
|
|
v.PanicErrorWriteDirectoryData()
|
|
|
|
}),
|
2024-01-14 16:31:07 +06:00
|
|
|
))
|
|
|
|
}
|