@@ -54,6 +54,9 @@ RunDeployer(args) {
54
54
case " sync" :
55
55
res := conf.SyncUserData()
56
56
opt := RABBIT_PARTIAL_MAINTENANCE
57
+ case " test" :
58
+ res := conf.Test()
59
+ return res
57
60
default :
58
61
res := conf.Run (command = " install" )
59
62
opt := RABBIT_PARTIAL_MAINTENANCE ; TODO: check if need maintenance
@@ -79,10 +82,22 @@ CreateFileIfNotExist(filename) {
79
82
FileAppend ("" , filepath)
80
83
}
81
84
82
- ConfigureSwitcher (levers, switcher_settings, reconfigured ) {
85
+ ConfigureSwitcher (levers, switcher_settings, & reconfigured ) {
83
86
if not levers.load_settings(switcher_settings)
84
87
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
86
101
}
87
102
88
103
class Configurator extends Class {
@@ -105,12 +120,30 @@ class Configurator extends Class {
105
120
switcher_settings := levers.switcher_settings_init()
106
121
skip_switcher_settings := installing && ! levers.is_first_run(switcher_settings)
107
122
123
+ ; (skip_switcher_settings || ConfigureSwitcher(levers, switcher_settings, &reconfigured) &&
124
+ ; (skip_ui_style_settings || ConfigureUI(levers, &ui_style_settings, &reconfigured)))
125
+
108
126
if installing
109
127
this.UpdateWorkspace()
110
128
111
129
return 0
112
130
}
113
131
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
+
114
147
UpdateWorkspace (report_errors := false ) {
115
148
mutex := RabbitMutex()
116
149
if not mutex.Create() {
@@ -150,3 +183,32 @@ class Configurator extends Class {
150
183
return 0
151
184
}
152
185
}
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