Skip to content

Commit 58da551

Browse files
committed
working on setting dialogs
1 parent af38db3 commit 58da551

File tree

1 file changed

+64
-2
lines changed

1 file changed

+64
-2
lines changed

RabbitDeployer.ahk

+64-2
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ RunDeployer(args) {
5454
case "sync":
5555
res := conf.SyncUserData()
5656
opt := RABBIT_PARTIAL_MAINTENANCE
57+
case "test":
58+
res := conf.Test()
59+
return res
5760
default:
5861
res := conf.Run(command = "install")
5962
opt := RABBIT_PARTIAL_MAINTENANCE ; TODO: check if need maintenance
@@ -79,10 +82,22 @@ CreateFileIfNotExist(filename) {
7982
FileAppend("", filepath)
8083
}
8184

82-
ConfigureSwitcher(levers, switcher_settings, reconfigured) {
85+
ConfigureSwitcher(levers, switcher_settings, &reconfigured) {
8386
if not levers.load_settings(switcher_settings)
8487
return false
85-
;
88+
; To mimic a dialog
89+
result := {
90+
yes : false
91+
}
92+
dialog := SwitcherSettingsDialog(switcher_settings, result)
93+
dialog.Show()
94+
WinWaitClose(dialog)
95+
96+
if result.yes {
97+
; save settings
98+
return true
99+
}
100+
return false
86101
}
87102

88103
class Configurator extends Class {
@@ -105,12 +120,30 @@ class Configurator extends Class {
105120
switcher_settings := levers.switcher_settings_init()
106121
skip_switcher_settings := installing && !levers.is_first_run(switcher_settings)
107122

123+
; (skip_switcher_settings || ConfigureSwitcher(levers, switcher_settings, &reconfigured) &&
124+
; (skip_ui_style_settings || ConfigureUI(levers, &ui_style_settings, &reconfigured)))
125+
108126
if installing
109127
this.UpdateWorkspace()
110128

111129
return 0
112130
}
113131

132+
Test() {
133+
levers := RimeLeversApi()
134+
if !levers
135+
return 1
136+
137+
switcher_settings := levers.switcher_settings_init()
138+
skip_switcher_settings := !levers.is_first_run(switcher_settings)
139+
140+
if !skip_switcher_settings {
141+
ConfigureSwitcher(levers, switcher_settings, &reconfigured)
142+
}
143+
144+
return 0
145+
}
146+
114147
UpdateWorkspace(report_errors := false) {
115148
mutex := RabbitMutex()
116149
if not mutex.Create() {
@@ -150,3 +183,32 @@ class Configurator extends Class {
150183
return 0
151184
}
152185
}
186+
187+
class SwitcherSettingsDialog extends Gui {
188+
__New(settings, result) {
189+
super.__New(, "【玉兔毫】方案选单设定", this)
190+
this.settings := settings
191+
this.loaded := false
192+
this.modified := false
193+
this.api := RimeLeversApi()
194+
195+
this.result := result
196+
197+
; Layout
198+
this.AddText("", "请勾选所需的输入方案:")
199+
this.lv := this.AddListView("Section Checked", ["方案名称"])
200+
{
201+
this.lv.Add(, "星空键道")
202+
}
203+
this.introduction := this.AddText("YP", "选中列表中的输入方案以查看简介")
204+
this.AddText("XS", "在玉兔毫里,以下快捷键可唤出方案选单,以切换模式或选用其他输入方案。")
205+
this.AddEdit("-Multi ReadOnly r1 w480", "Control+quoteright, Control+Shift+space")
206+
this.ok := this.AddButton(, "确定")
207+
this.ok.OnEvent("Click", (*) => this.exit(true))
208+
}
209+
210+
exit(yes) {
211+
this.result.yes := yes
212+
this.Destroy()
213+
}
214+
}

0 commit comments

Comments
 (0)