优化打开方式
This commit is contained in:
parent
d9c76b18e7
commit
37780c4694
@ -19,6 +19,7 @@ import (
|
||||
"fyne.io/fyne/v2/data/binding"
|
||||
"fyne.io/fyne/v2/dialog"
|
||||
"fyne.io/fyne/v2/layout"
|
||||
"fyne.io/fyne/v2/storage"
|
||||
"fyne.io/fyne/v2/theme"
|
||||
"fyne.io/fyne/v2/widget"
|
||||
"github.com/sirupsen/logrus"
|
||||
@ -97,15 +98,38 @@ func (this *appGen) LazyInit(obs observer.Observer) error {
|
||||
tmpDir.Text = gt.TmpDir
|
||||
}
|
||||
|
||||
// 打开目录
|
||||
openFolder := func(entry *widget.Entry) {
|
||||
dConf := dialog.NewFolderOpen(func(lu fyne.ListableURI, err error) {
|
||||
if lu == nil {
|
||||
return
|
||||
}
|
||||
entry.Text = lu.Path()
|
||||
entry.Refresh()
|
||||
}, toolWin.w)
|
||||
luri, _ := storage.ListerForURI(storage.NewFileURI("."))
|
||||
dConf.SetLocation(luri)
|
||||
dConf.SetConfirmText("打开")
|
||||
dConf.SetDismissText("取消")
|
||||
dConf.Resize(fyne.NewSize(750, 500))
|
||||
dConf.Show()
|
||||
}
|
||||
|
||||
form := widget.NewForm(
|
||||
widget.NewFormItem("服务地址", serverAddr),
|
||||
widget.NewFormItem("项目目录", projectDir),
|
||||
widget.NewFormItem("工作目录", workDir),
|
||||
widget.NewFormItem("项目目录", container.NewBorder(nil, nil, nil, widget.NewButtonWithIcon("", theme.FolderIcon(), func() {
|
||||
openFolder(projectDir)
|
||||
}), projectDir)),
|
||||
widget.NewFormItem("工作目录", container.NewBorder(nil, nil, nil, widget.NewButtonWithIcon("", theme.FolderIcon(), func() {
|
||||
openFolder(workDir)
|
||||
}), workDir)),
|
||||
widget.NewFormItem("LuBan Cli", client),
|
||||
widget.NewFormItem("输入目录", inputDir),
|
||||
widget.NewFormItem("输出Code目录", outputCodeDir),
|
||||
widget.NewFormItem("输出JSON目录", outputJsonDir),
|
||||
widget.NewFormItem("临时目录", tmpDir),
|
||||
widget.NewFormItem("临时目录", container.NewBorder(nil, nil, nil, widget.NewButtonWithIcon("", theme.FolderIcon(), func() {
|
||||
openFolder(tmpDir)
|
||||
}), tmpDir)),
|
||||
widget.NewFormItem("生成类型", genType),
|
||||
)
|
||||
|
||||
|
@ -18,6 +18,7 @@ import (
|
||||
"fyne.io/fyne/v2/data/binding"
|
||||
"fyne.io/fyne/v2/dialog"
|
||||
"fyne.io/fyne/v2/layout"
|
||||
"fyne.io/fyne/v2/storage"
|
||||
"fyne.io/fyne/v2/theme"
|
||||
"fyne.io/fyne/v2/widget"
|
||||
"github.com/sirupsen/logrus"
|
||||
@ -40,6 +41,23 @@ func (this *appPbGen) LazyInit(obs observer.Observer) error {
|
||||
pcm := service.GetDbService().GetPbConf()
|
||||
logrus.Debugf("%v", pcm)
|
||||
|
||||
// 打开目录
|
||||
openFolder := func(entry *widget.Entry) {
|
||||
dConf := dialog.NewFolderOpen(func(lu fyne.ListableURI, err error) {
|
||||
if lu == nil {
|
||||
return
|
||||
}
|
||||
entry.Text = lu.Path()
|
||||
entry.Refresh()
|
||||
}, toolWin.w)
|
||||
luri, _ := storage.ListerForURI(storage.NewFileURI("."))
|
||||
dConf.SetLocation(luri)
|
||||
dConf.SetConfirmText("打开")
|
||||
dConf.SetDismissText("取消")
|
||||
dConf.Resize(fyne.NewSize(750, 500))
|
||||
dConf.Show()
|
||||
}
|
||||
|
||||
content := container.NewMax()
|
||||
content.Objects = []fyne.CanvasObject{}
|
||||
|
||||
@ -54,8 +72,13 @@ func (this *appPbGen) LazyInit(obs observer.Observer) error {
|
||||
outDir.PlaceHolder = "go输出目录"
|
||||
|
||||
form := widget.NewForm(
|
||||
widget.NewFormItem("proto目录", protoDir),
|
||||
widget.NewFormItem("输出目录", outDir),
|
||||
widget.NewFormItem("proto目录", container.NewBorder(nil, nil, nil, widget.NewButtonWithIcon("", theme.FolderIcon(), func() {
|
||||
openFolder(protoDir)
|
||||
this.folderList.initItem(protoDir.Text)
|
||||
}), protoDir)),
|
||||
widget.NewFormItem("输出目录", container.NewBorder(nil, nil, nil, widget.NewButtonWithIcon("", theme.FolderIcon(), func() {
|
||||
openFolder(outDir)
|
||||
}), outDir)),
|
||||
)
|
||||
|
||||
if pcm != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user