Skip to content

Commit a706257

Browse files
authored
scroll mode: configurable max column count and cell width (#272)
1 parent 5c20f4c commit a706257

File tree

4 files changed

+89
-71
lines changed

4 files changed

+89
-71
lines changed

assets/po/zh_CN.po

Lines changed: 70 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ msgstr "闪烁"
111111
msgid "Static"
112112
msgstr "静止"
113113

114-
#: webpanel/webpanel.h:30 webpanel/webpanel.h:34 webpanel/webpanel.h:286
114+
#: webpanel/webpanel.h:30 webpanel/webpanel.h:34 webpanel/webpanel.h:289
115115
msgid "Text"
116116
msgstr "文本"
117117

@@ -244,249 +244,257 @@ msgid "Max row count"
244244
msgstr "最大行数"
245245

246246
#: webpanel/webpanel.h:206
247+
msgid "Max column count"
248+
msgstr "最大列数"
249+
250+
#: webpanel/webpanel.h:208
247251
msgid "Expand"
248252
msgstr "展开"
249253

250-
#: webpanel/webpanel.h:208
254+
#: webpanel/webpanel.h:210
251255
msgid "Collapse"
252256
msgstr "折叠"
253257

254-
#: webpanel/webpanel.h:210
258+
#: webpanel/webpanel.h:212
255259
msgid "Up"
256260
msgstr "上"
257261

258-
#: webpanel/webpanel.h:212
262+
#: webpanel/webpanel.h:214
259263
msgid "Down"
260264
msgstr "下"
261265

262-
#: webpanel/webpanel.h:213
266+
#: webpanel/webpanel.h:215
263267
msgid "Left"
264268
msgstr "左"
265269

266-
#: webpanel/webpanel.h:214
270+
#: webpanel/webpanel.h:216
267271
msgid "Right"
268272
msgstr "右"
269273

270-
#: webpanel/webpanel.h:216
274+
#: webpanel/webpanel.h:218
271275
msgid "Row start"
272276
msgstr "行首"
273277

274-
#: webpanel/webpanel.h:217
278+
#: webpanel/webpanel.h:219
275279
msgid "Row end"
276280
msgstr "行尾"
277281

278-
#: webpanel/webpanel.h:219
282+
#: webpanel/webpanel.h:221
279283
msgid "Page up"
280284
msgstr "上一页"
281285

282-
#: webpanel/webpanel.h:221
286+
#: webpanel/webpanel.h:223
283287
msgid "Page down"
284288
msgstr "下一页"
285289

286-
#: webpanel/webpanel.h:222
290+
#: webpanel/webpanel.h:224
287291
msgid "Commit"
288292
msgstr "提交"
289293

290-
#: webpanel/webpanel.h:225
294+
#: webpanel/webpanel.h:228
291295
msgid "Select candidate"
292296
msgstr "选词"
293297

294-
#: webpanel/webpanel.h:230
298+
#: webpanel/webpanel.h:233
295299
msgid "Optimize for Hyper key"
296300
msgstr "针对 Hyper 键优化"
297301

298-
#: webpanel/webpanel.h:236
302+
#: webpanel/webpanel.h:239
299303
msgid "Layout"
300304
msgstr "布局"
301305

302-
#: webpanel/webpanel.h:240
306+
#: webpanel/webpanel.h:243
303307
msgid "Writing mode"
304308
msgstr "书写模式"
305309

306-
#: webpanel/webpanel.h:243
310+
#: webpanel/webpanel.h:246
307311
msgid "Typography awareness for IM"
308312
msgstr "输入法感知版式"
309313

310-
#: webpanel/webpanel.h:247
314+
#: webpanel/webpanel.h:250
311315
msgid "Paging buttons style"
312316
msgstr "翻页按钮样式"
313317

314-
#: webpanel/webpanel.h:252
318+
#: webpanel/webpanel.h:255
315319
msgid "Image"
316320
msgstr "图片"
317321

318-
#: webpanel/webpanel.h:253
322+
#: webpanel/webpanel.h:256
319323
msgid "Blur"
320324
msgstr "模糊"
321325

322-
#: webpanel/webpanel.h:254
326+
#: webpanel/webpanel.h:257
323327
msgid "Shadow"
324328
msgstr "阴影"
325329

326-
#: webpanel/webpanel.h:262
330+
#: webpanel/webpanel.h:265
327331
msgid "Text font family"
328332
msgstr "文本字体族"
329333

330-
#: webpanel/webpanel.h:264
334+
#: webpanel/webpanel.h:267
331335
msgid "Text font size"
332336
msgstr "文本字号"
333337

334-
#: webpanel/webpanel.h:266
338+
#: webpanel/webpanel.h:269
335339
msgid "Label font family"
336340
msgstr "标签字体族"
337341

338-
#: webpanel/webpanel.h:268
342+
#: webpanel/webpanel.h:271
339343
msgid "Label font size"
340344
msgstr "标签字号"
341345

342-
#: webpanel/webpanel.h:270
346+
#: webpanel/webpanel.h:273
343347
msgid "Comment font family"
344348
msgstr "注释字体族"
345349

346-
#: webpanel/webpanel.h:272
350+
#: webpanel/webpanel.h:275
347351
msgid "Comment font size"
348352
msgstr "注释字号"
349353

350-
#: webpanel/webpanel.h:275
354+
#: webpanel/webpanel.h:278
351355
msgid "Preedit font family"
352356
msgstr "预编辑字体族"
353357

354-
#: webpanel/webpanel.h:277
358+
#: webpanel/webpanel.h:280
355359
msgid "Preedit font size"
356360
msgstr "预编辑字号"
357361

358-
#: webpanel/webpanel.h:279
362+
#: webpanel/webpanel.h:282
359363
msgid "User font dir"
360364
msgstr "用户字体目录"
361365

362-
#: webpanel/webpanel.h:280
366+
#: webpanel/webpanel.h:283
363367
msgid "System font dir"
364368
msgstr "系统字体目录"
365369

366-
#: webpanel/webpanel.h:285
370+
#: webpanel/webpanel.h:288
367371
msgid "Style"
368372
msgstr "样式"
369373

370-
#: webpanel/webpanel.h:291
374+
#: webpanel/webpanel.h:294
371375
msgid "Mark style"
372376
msgstr "标记样式"
373377

374-
#: webpanel/webpanel.h:292
378+
#: webpanel/webpanel.h:295
375379
msgid "Mark text"
376380
msgstr "标记文本"
377381

378-
#: webpanel/webpanel.h:294
382+
#: webpanel/webpanel.h:297
379383
msgid "Hover behavior"
380384
msgstr "悬停行为"
381385

382-
#: webpanel/webpanel.h:300
386+
#: webpanel/webpanel.h:303
383387
msgid "Border width (px)"
384388
msgstr "边框宽度(px)"
385389

386-
#: webpanel/webpanel.h:303
390+
#: webpanel/webpanel.h:306
387391
msgid "Border radius (px)"
388392
msgstr "边框半径(px)"
389393

390-
#: webpanel/webpanel.h:304
394+
#: webpanel/webpanel.h:307
391395
msgid "Margin (px)"
392396
msgstr "外边距(px)"
393397

394-
#: webpanel/webpanel.h:307
398+
#: webpanel/webpanel.h:310
395399
msgid "Highlight radius (px)"
396400
msgstr "高亮半径(px)"
397401

398-
#: webpanel/webpanel.h:310
402+
#: webpanel/webpanel.h:313
399403
msgid "Top padding (px)"
400404
msgstr "顶填充(px)"
401405

402-
#: webpanel/webpanel.h:312
406+
#: webpanel/webpanel.h:315
403407
msgid "Right padding (px)"
404408
msgstr "右填充(px)"
405409

406-
#: webpanel/webpanel.h:314
410+
#: webpanel/webpanel.h:317
407411
msgid "Bottom padding (px)"
408412
msgstr "底填充(px)"
409413

410-
#: webpanel/webpanel.h:317
414+
#: webpanel/webpanel.h:320
411415
msgid "Left padding (px)"
412416
msgstr "左填充(px)"
413417

414-
#: webpanel/webpanel.h:319
418+
#: webpanel/webpanel.h:322
415419
msgid "Gap between label, text and comment (px)"
416420
msgstr "标签、文本、注释间隔(px)"
417421

418-
#: webpanel/webpanel.h:322
422+
#: webpanel/webpanel.h:325
419423
msgid "Vertical minimum width (px)"
420424
msgstr "垂直时最小宽度(px)"
421425

422-
#: webpanel/webpanel.h:325
426+
#: webpanel/webpanel.h:328
427+
msgid "Scroll cell width (px)"
428+
msgstr "卷轴单元格宽度 (px)"
429+
430+
#: webpanel/webpanel.h:331
423431
msgid "Horizontal divider width (px)"
424432
msgstr "水平分隔线宽度(px)"
425433

426-
#: webpanel/webpanel.h:334
434+
#: webpanel/webpanel.h:340
427435
msgid "User CSS"
428436
msgstr "用户 CSS"
429437

430-
#: webpanel/webpanel.h:335
438+
#: webpanel/webpanel.h:341
431439
msgid "Copy HTML"
432440
msgstr "复制 HTML"
433441

434-
#: webpanel/webpanel.h:336
442+
#: webpanel/webpanel.h:342
435443
msgid "Plugin dir"
436444
msgstr "插件目录"
437445

438-
#: webpanel/webpanel.h:338
446+
#: webpanel/webpanel.h:344
439447
msgid "I know there may be risks for using plugins"
440448
msgstr "我知道使用插件可能有风险"
441449

442-
#: webpanel/webpanel.h:341
450+
#: webpanel/webpanel.h:347
443451
msgid "Plugins"
444452
msgstr "插件"
445453

446-
#: webpanel/webpanel.h:343
454+
#: webpanel/webpanel.h:349
447455
msgid "Dangerous API for JavaScript plugins"
448456
msgstr "用于 JavaScript 插件的危险 API"
449457

450-
#: webpanel/webpanel.h:346
458+
#: webpanel/webpanel.h:352
451459
msgid "Basic"
452460
msgstr "基础"
453461

454-
#: webpanel/webpanel.h:347
462+
#: webpanel/webpanel.h:353
455463
msgid "Light mode"
456464
msgstr "浅色模式"
457465

458-
#: webpanel/webpanel.h:348
466+
#: webpanel/webpanel.h:354
459467
msgid "Dark mode"
460468
msgstr "深色模式"
461469

462-
#: webpanel/webpanel.h:349
470+
#: webpanel/webpanel.h:355
463471
msgid "Typography"
464472
msgstr "版式"
465473

466-
#: webpanel/webpanel.h:350
474+
#: webpanel/webpanel.h:356
467475
msgid "Scroll mode"
468476
msgstr "卷轴模式"
469477

470-
#: webpanel/webpanel.h:351
478+
#: webpanel/webpanel.h:357
471479
msgid "Background"
472480
msgstr "背景"
473481

474-
#: webpanel/webpanel.h:352
482+
#: webpanel/webpanel.h:358
475483
msgid "Font"
476484
msgstr "字体"
477485

478-
#: webpanel/webpanel.h:353
486+
#: webpanel/webpanel.h:359
479487
msgid "Caret"
480488
msgstr "光标"
481489

482-
#: webpanel/webpanel.h:354
490+
#: webpanel/webpanel.h:360
483491
msgid "Highlight"
484492
msgstr "高亮"
485493

486-
#: webpanel/webpanel.h:355
494+
#: webpanel/webpanel.h:361
487495
msgid "Size"
488496
msgstr "尺寸"
489497

490-
#: webpanel/webpanel.h:356
498+
#: webpanel/webpanel.h:362
491499
msgid "Advanced"
492500
msgstr "高级"

webpanel/webpanel.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,10 @@ WebPanel::WebPanel(Instance *instance)
171171
candidate_window::scroll_key_action_t::four,
172172
candidate_window::scroll_key_action_t::five,
173173
candidate_window::scroll_key_action_t::six,
174+
candidate_window::scroll_key_action_t::seven,
175+
candidate_window::scroll_key_action_t::eight,
176+
candidate_window::scroll_key_action_t::nine,
177+
candidate_window::scroll_key_action_t::zero,
174178
};
175179
if (int i =
176180
key.keyListIndex(*config_.scrollMode->selectCandidate);
@@ -534,8 +538,8 @@ void WebPanel::scroll(int start, int count) {
534538
}
535539

536540
void WebPanel::expand() {
537-
scroll(0, 6 * (*config_.scrollMode->maxRowCount +
538-
1)); // Hard-coded like fcitx5-webview
541+
scroll(0, *config_.scrollMode->maxColumnCount *
542+
(*config_.scrollMode->maxRowCount + 1));
539543
}
540544

541545
void WebPanel::collapse() {

webpanel/webpanel.h

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,8 @@ FCITX_CONFIGURATION(
202202
Option<bool> animation{this, "Animation", _("Animation"), true};
203203
Option<int, IntConstrain> maxRowCount{
204204
this, "MaxRowCount", _("Max row count"), 6, IntConstrain(2, 10)};
205+
Option<int, IntConstrain> maxColumnCount{
206+
this, "MaxColumnCount", _("Max column count"), 6, IntConstrain(2, 10)};
205207
Option<KeyList> expand{
206208
this, "Expand", _("Expand"), {Key(FcitxKey_equal), Key(FcitxKey_Down)}};
207209
Option<KeyList> collapse{
@@ -220,12 +222,13 @@ FCITX_CONFIGURATION(
220222
Option<KeyList> pageDown{
221223
this, "PageDown", _("Page down"), {Key(FcitxKey_Page_Down)}};
222224
Option<KeyList> commit{this, "Commit", _("Commit"), {Key(FcitxKey_space)}};
223-
Option<KeyList> selectCandidate{this,
224-
"SelectCandidate",
225-
_("Select candidate"),
226-
{Key(FcitxKey_1), Key(FcitxKey_2),
227-
Key(FcitxKey_3), Key(FcitxKey_4),
228-
Key(FcitxKey_5), Key(FcitxKey_6)}};
225+
Option<KeyList> selectCandidate{
226+
this,
227+
"SelectCandidate",
228+
_("Select candidate"),
229+
{Key(FcitxKey_1), Key(FcitxKey_2), Key(FcitxKey_3), Key(FcitxKey_4),
230+
Key(FcitxKey_5), Key(FcitxKey_6), Key(FcitxKey_7), Key(FcitxKey_8),
231+
Key(FcitxKey_9), Key(FcitxKey_0)}};
229232
Option<bool> optimizeForHyperKey{this, "OptimizeForHyperKey",
230233
_("Optimize for Hyper key"), true};);
231234

@@ -321,6 +324,9 @@ FCITX_CONFIGURATION(
321324
Option<int, IntConstrain> verticalMinWidth{this, "VerticalMinWidth",
322325
_("Vertical minimum width (px)"),
323326
200, IntConstrain(0, 960)};
327+
Option<int, IntConstrain> scrollCellWidth{this, "ScrollCellWidth",
328+
_("Scroll cell width (px)"), 65,
329+
IntConstrain(40, 100)};
324330
Option<int, IntConstrain> horizontalDividerWidth{
325331
this, "HorizontalDividerWidth", _("Horizontal divider width (px)"), 1,
326332
IntConstrain(0, BORDER_WIDTH_MAX)};);

0 commit comments

Comments
 (0)