@@ -56,7 +56,7 @@ RunDeployer(args) {
56
56
opt := RABBIT_PARTIAL_MAINTENANCE
57
57
default :
58
58
res := conf.Run (command = " install" )
59
- opt := RABBIT_PARTIAL_MAINTENANCE ; TODO: check if need maintenance
59
+ opt := RABBIT_NO_MAINTENANCE
60
60
}
61
61
62
62
if args.Length > 1 {
@@ -79,10 +79,25 @@ CreateFileIfNotExist(filename) {
79
79
FileAppend ("" , filepath)
80
80
}
81
81
82
- ConfigureSwitcher (levers, switcher_settings, reconfigured ) {
82
+ ConfigureSwitcher (levers, switcher_settings, &reconfigured ) {
83
+ if ! IsSet(reconfigured)
84
+ reconfigured := false
83
85
if not levers.load_settings(switcher_settings)
84
86
return false
85
- ;
87
+ ; To mimic a dialog
88
+ result := {
89
+ yes : false
90
+ }
91
+ dialog := SwitcherSettingsDialog(switcher_settings, result)
92
+ dialog.Show()
93
+ WinWaitClose (dialog)
94
+
95
+ if result.yes {
96
+ if levers.save_settings(switcher_settings)
97
+ reconfigured := true
98
+ return true
99
+ }
100
+ return false
86
101
}
87
102
88
103
class Configurator extends Class {
@@ -105,8 +120,14 @@ 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
108
- if installing
109
- this.UpdateWorkspace()
123
+ if ! skip_switcher_settings {
124
+ ConfigureSwitcher(levers, switcher_settings, & reconfigured)
125
+ }
126
+
127
+ levers.custom_settings_destroy(switcher_settings)
128
+
129
+ if installing || reconfigured
130
+ return this.UpdateWorkspace()
110
131
111
132
return 0
112
133
}
@@ -150,3 +171,120 @@ class Configurator extends Class {
150
171
return 0
151
172
}
152
173
}
174
+
175
+ class SwitcherSettingsDialog extends Gui {
176
+ __New (settings, result ) {
177
+ super.__New (, " 【玉兔毫】方案选单设定" , this)
178
+ this.settings := settings
179
+ this.loaded := false
180
+ this.modified := false
181
+ this.api := RimeLeversApi()
182
+
183
+ this.item_data := Map()
184
+ this.result := result
185
+
186
+ ; Layout
187
+ this.MarginX := 15
188
+ this.MarginY := 15
189
+ this.AddText(, " 请勾选所需的输入方案:" )
190
+ this.schema_list := this.AddListView(" Section Checked NoSort w220 h175" , [" 方案名称" ])
191
+ this.schema_list.OnEvent(" Click" , (ctrl , lvid) => this.OnSchemaListClick(lvid))
192
+ this.schema_list.OnEvent(" ItemCheck" , (ctrl , lvid, checked ) => this.OnSchemaListItemCheck(lvid, checked ))
193
+ this.description := this.AddText(" YP w285 h175" , " 选中列表中的输入方案以查看简介" )
194
+ this.AddText(" XS" , " 在玉兔毫里,以下快捷键可唤出方案选单,以切换模式或选用其他输入方案。" )
195
+ this.hotkeys := this.AddEdit(" -Multi ReadOnly r1 w505" )
196
+ this.more_schemas := this.AddButton(" Disabled w155" , " 获取更多输入方案…" )
197
+ this.ok := this.AddButton(" X+60 YP w90" , " 中" )
198
+ this.ok.OnEvent(" Click" , (* ) => this.OnOK())
199
+
200
+ this.Populate()
201
+ }
202
+
203
+ Populate () {
204
+ if ! this.settings
205
+ return
206
+ local available := this.api.get_available_schema_list(this.settings)
207
+ local selected := this.api.get_selected_schema_list(this.settings)
208
+ this.schema_list.Delete ()
209
+
210
+ local recruited := Map()
211
+
212
+ local selected_list := selected.list
213
+ local available_list := available.list
214
+ Loop selected.size {
215
+ local schema_id := selected_list[A_Index ].schema_id
216
+ Loop available.size {
217
+ item := available_list[A_Index ]
218
+ info := RimeSchemaInfo(item)
219
+ if item.schema_id == schema_id && (! recruited.Has(info.Ptr) || recruited[info.Ptr] == false ) {
220
+ recruited[info.Ptr] := true
221
+ row := this.schema_list.Add(" Check" , item.name )
222
+ this.item_data[row] := info
223
+ break
224
+ }
225
+ }
226
+ }
227
+ Loop available.size {
228
+ item := available_list[A_Index ]
229
+ info := RimeSchemaInfo(item)
230
+ if ! recruited.Has(info.Ptr) || recruited[info.Ptr] == false {
231
+ recruited[info.Ptr] := true
232
+ row := this.schema_list.Add(, item.name )
233
+ this.item_data[row] := info
234
+ }
235
+ }
236
+ txt := this.api.get_hotkeys(this.settings)
237
+ this.hotkeys.Value := txt
238
+ this.loaded := true
239
+ this.modified := false
240
+ }
241
+
242
+ OnSchemaListClick (lvid ) {
243
+ if ! this.loaded || ! this.schema_list || lvid <= 0 || lvid > this.schema_list.GetCount() {
244
+ return
245
+ }
246
+ this.ShowDetails(this.item_data[lvid])
247
+ }
248
+
249
+ OnSchemaListItemCheck (lvid, checked ) {
250
+ if ! this.loaded || ! this.schema_list || lvid <= 0 || lvid > this.schema_list.GetCount() {
251
+ return
252
+ }
253
+ this.modified := true
254
+ }
255
+
256
+ ShowDetails (info ) {
257
+ if ! info
258
+ return
259
+ details := ""
260
+ if name := this.api.get_schema_name(info)
261
+ details .= name
262
+ if author := this.api.get_schema_author(info)
263
+ details .= " `r`n`r`n" . author
264
+ if description := this.api.get_schema_description(info)
265
+ details .= " `r`n`r`n" . description
266
+ this.description.Value := details
267
+ }
268
+
269
+ OnOK () {
270
+ if this.modified && !! this.settings && this.schema_list.GetCount() ! = 0 {
271
+ selection := []
272
+ row := 0
273
+ while row := this.schema_list.GetNext(row, " Checked" ) {
274
+ if info := this.item_data[row]
275
+ selection.Push(this.api.get_schema_id(info))
276
+ }
277
+ if selection.Length == 0 {
278
+ MsgBox (" 至少要选用一项吧。" , " 玉兔毫不是这般用法" , " Icon!" )
279
+ return
280
+ }
281
+ this.api.select_schemas(this.settings, selection)
282
+ }
283
+ this.Exit(true )
284
+ }
285
+
286
+ Exit (yes ) {
287
+ this.result.yes := yes
288
+ this.Destroy()
289
+ }
290
+ }
0 commit comments