-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathcmd.go
More file actions
84 lines (73 loc) · 2.19 KB
/
Copy pathcmd.go
File metadata and controls
84 lines (73 loc) · 2.19 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
package main
import (
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/dialog"
"fyne.io/fyne/v2/widget"
)
func (w *Window) showNewCmdDialog() {
nameEntry := widget.NewEntry()
textEntry := widget.NewEntry()
textEntry.MultiLine = true
// 创建排序后的图标列表
icons := make([]string, 0, len(iconMap))
for k := range iconMap {
icons = append(icons, k)
}
iconSelect := widget.NewSelect(icons, nil)
// 添加自动提交复选框
autoSubmitCheck := widget.NewCheck("Auto Submit (press Enter automatically)", func(b bool) {})
dlg := dialog.NewForm("New Command", "OK", "Cancel", []*widget.FormItem{
widget.NewFormItem("Name", nameEntry),
widget.NewFormItem("Text", textEntry),
widget.NewFormItem("Icon", iconSelect),
widget.NewFormItem("", autoSubmitCheck),
}, func(b bool) {
if b {
cmd := &Cmd{
Name: nameEntry.Text,
Text: textEntry.Text,
Icon: iconSelect.Selected,
AutoSubmit: autoSubmitCheck.Checked,
}
w.AddCmd(cmd)
}
}, w.win)
dlg.Resize(fyne.NewSize(400, 350))
dlg.Show()
}
// showModifyCmdDialog 显示修改命令对话框
func (w *Window) showModifyCmdDialog(index int, cmd *Cmd) {
nameEntry := widget.NewEntry()
nameEntry.SetText(cmd.Name)
textEntry := widget.NewEntry()
textEntry.SetText(cmd.Text)
textEntry.MultiLine = true
// 创建排序后的图标列表
icons := make([]string, 0, len(iconMap))
for k := range iconMap {
icons = append(icons, k)
}
iconSelect := widget.NewSelect(icons, nil)
iconSelect.SetSelected(cmd.Icon)
// 添加自动提交复选框
autoSubmitCheck := widget.NewCheck("Auto Submit (press Enter automatically)", func(b bool) {})
autoSubmitCheck.SetChecked(cmd.AutoSubmit)
dlg := dialog.NewForm("Modify Command", "OK", "Cancel", []*widget.FormItem{
widget.NewFormItem("Name", nameEntry),
widget.NewFormItem("Text", textEntry),
widget.NewFormItem("Icon", iconSelect),
widget.NewFormItem("", autoSubmitCheck),
}, func(b bool) {
if b {
updatedCmd := &Cmd{
Name: nameEntry.Text,
Text: textEntry.Text,
Icon: iconSelect.Selected,
AutoSubmit: autoSubmitCheck.Checked,
}
w.UpdateCmd(index, updatedCmd)
}
}, w.win)
dlg.Resize(fyne.NewSize(400, 350))
dlg.Show()
}