2024-01-14 16:31:07 +06:00
|
|
|
package error
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fyne.io/fyne/v2/container"
|
|
|
|
"fyne.io/fyne/v2/widget"
|
2024-02-17 19:08:58 +06:00
|
|
|
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/kernel"
|
2024-02-12 22:21:47 +06:00
|
|
|
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/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-02-17 19:08:58 +06:00
|
|
|
app kernel.AppContract
|
2024-01-14 16:31:07 +06:00
|
|
|
}
|
|
|
|
|
2024-02-17 19:08:58 +06:00
|
|
|
func NewView(app kernel.AppContract) *View {
|
2024-01-28 22:01:16 +06:00
|
|
|
return &View{
|
2024-02-17 19:08:58 +06:00
|
|
|
app: app,
|
2024-01-28 22:01:16 +06:00
|
|
|
}
|
2024-01-14 16:31:07 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
func (v View) PanicError(err error) {
|
2024-02-17 19:08:58 +06:00
|
|
|
messageHead := v.app.GetLocalizerService().GetMessage(&i18n.LocalizeConfig{
|
2024-01-28 22:01:16 +06:00
|
|
|
MessageID: "error",
|
|
|
|
})
|
|
|
|
|
2024-02-17 19:08:58 +06:00
|
|
|
v.app.GetWindow().SetContent(container.NewBorder(
|
2024-01-28 22:01:16 +06:00
|
|
|
container.NewVBox(
|
|
|
|
widget.NewLabel(messageHead),
|
|
|
|
widget.NewLabel(err.Error()),
|
|
|
|
),
|
|
|
|
nil,
|
|
|
|
nil,
|
|
|
|
nil,
|
2024-02-17 19:08:58 +06:00
|
|
|
localizer.LanguageSelectionForm(v.app.GetLocalizerService(), func(lang kernel.Lang) {
|
2024-01-28 22:01:16 +06:00
|
|
|
v.PanicError(err)
|
|
|
|
}),
|
|
|
|
))
|
|
|
|
}
|
|
|
|
|
|
|
|
func (v View) PanicErrorWriteDirectoryData() {
|
2024-02-17 19:08:58 +06:00
|
|
|
message := v.app.GetLocalizerService().GetMessage(&i18n.LocalizeConfig{
|
2024-01-28 22:01:16 +06:00
|
|
|
MessageID: "errorDatabase",
|
|
|
|
})
|
2024-02-17 19:08:58 +06:00
|
|
|
messageHead := v.app.GetLocalizerService().GetMessage(&i18n.LocalizeConfig{
|
2024-01-28 22:01:16 +06:00
|
|
|
MessageID: "error",
|
|
|
|
})
|
|
|
|
|
2024-02-17 19:08:58 +06:00
|
|
|
v.app.GetWindow().SetContent(container.NewBorder(
|
2024-01-28 22:01:16 +06:00
|
|
|
container.NewVBox(
|
|
|
|
widget.NewLabel(messageHead),
|
|
|
|
widget.NewLabel(message),
|
|
|
|
),
|
|
|
|
nil,
|
|
|
|
nil,
|
|
|
|
nil,
|
2024-02-17 19:08:58 +06:00
|
|
|
localizer.LanguageSelectionForm(v.app.GetLocalizerService(), func(lang kernel.Lang) {
|
2024-01-28 22:01:16 +06:00
|
|
|
v.PanicErrorWriteDirectoryData()
|
|
|
|
}),
|
2024-01-14 16:31:07 +06:00
|
|
|
))
|
|
|
|
}
|