-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathmain.go
More file actions
102 lines (87 loc) · 3.05 KB
/
main.go
File metadata and controls
102 lines (87 loc) · 3.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
// Package main provides various examples of Fyne API capabilities.
package main
import (
"code/gen/page"
"code/gen/resource/images"
"code/gen/runner"
"code/gen/util/logger"
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/app"
"fyne.io/fyne/v2/driver/desktop"
"fyne.io/fyne/v2/widget"
"github.com/sirupsen/logrus"
"net/url"
"os"
)
var a fyne.App
var Loading fyne.Window
func init() {
a = app.NewWithID("com.idmiss.generator")
driver := fyne.CurrentApp().Driver()
if drv, ok := driver.(desktop.Driver); ok {
Loading = drv.CreateSplashWindow()
Loading.SetContent(widget.NewLabelWithStyle("正在加载……",
fyne.TextAlignCenter, fyne.TextStyle{Bold: true}))
Loading.Hide()
}
runner.Runner()
}
const preferenceCurrentTutorial = "currentTutorial"
var topWindow fyne.Window
func shortcutFocused(s fyne.Shortcut, w fyne.Window) {
if focused, ok := w.Canvas().Focused().(fyne.Shortcutable); ok {
focused.TypedShortcut(s)
}
}
func main() {
a.Settings().SetTheme(page.MyTheme{})
a.SetIcon(images.ResourceIdmisstxPng)
w := a.NewWindow("Golang 代码生成器")
w.SetFixedSize(true)
topWindow = w
tutorial := page.Pages["welcome"].SetView(w)
databaseItem := fyne.NewMenuItem("数据库配置", func() {
logger.Log.WithFields(logrus.Fields{"data": ""}).Info("数据库配置")
//tutorial = container.NewBorder(container.NewVBox(widget.NewLabelWithStyle(page.Pages["database"].Title, fyne.TextAlignCenter, fyne.TextStyle{Bold: true}), widget.NewSeparator()), nil, nil, nil,page.Pages["database"].View(w))
tutorial = page.Pages["database"].SetView(w)
w.SetContent(tutorial)
})
projectItem := fyne.NewMenuItem("项目配置", func() {
tutorial = page.Pages["project"].SetView(w)
w.SetContent(tutorial)
logger.Log.WithFields(logrus.Fields{"data": ""}).Info("项目配置")
})
fileItem := fyne.NewMenuItem("模板文件", func() {
pwd, _ := os.Getwd()
u, _ := url.Parse(pwd + "/resource/temp/")
_ = a.OpenURL(u)
})
helpMenu := fyne.NewMenu("帮助",
fyne.NewMenuItem("查看文档", func() {
u, _ := url.Parse("http://www.idmiss.com/709")
_ = a.OpenURL(u)
}))
welcome := fyne.NewMenuItem("首页", func() {
//tutorial := container.NewBorder(container.NewVBox(widget.NewLabelWithStyle(page.Pages["welcome"].Title, fyne.TextAlignCenter, fyne.TextStyle{Bold: true}), widget.NewSeparator()), nil, nil, nil,page.Pages["welcome"].View(w))
tutorial = page.Pages["welcome"].SetView(w)
w.SetContent(tutorial)
})
autocodeMenu := fyne.NewMenuItem("代码生成", func() {
tutorial = page.Pages["autocode"].SetView(w)
w.SetContent(tutorial)
logger.Log.WithFields(logrus.Fields{"data": ""}).Info("代码生成")
})
mainMenu := fyne.NewMainMenu(
// a quit item will be appended to our first menu
fyne.NewMenu("文件", welcome),
fyne.NewMenu("设置", databaseItem, fyne.NewMenuItemSeparator(), projectItem, fyne.NewMenuItemSeparator(), fileItem),
fyne.NewMenu("生成器", autocodeMenu),
helpMenu,
)
w.SetMainMenu(mainMenu)
w.SetMaster()
w.SetContent(tutorial)
w.Resize(fyne.NewSize(640, 460))
w.ShowAndRun()
//os.Unsetenv("FYNE_FONT")
}