Skip to content

Commit 5ff7da6

Browse files
authored
[2040] 需重启字段的三按钮确认弹窗qml重写 (#4042)
1 parent d4ce1ca commit 5ff7da6

16 files changed

Lines changed: 931 additions & 28 deletions

File tree

TeXmacs/plugins/lang/dic/en_US/zh_CN.scm

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1335,6 +1335,7 @@
13351335
("keyboard equivalent" "等效快捷键")
13361336
("keyboard modifiers" "")
13371337
("keyboard shortcut" "键盘快捷键")
1338+
("keyboard shortcut style" "快捷键显示风格")
13381339
("keyboard" "键盘")
13391340
("keymaps" "")
13401341
("keyword" "关键字")
@@ -1346,6 +1347,7 @@
13461347
("landscape" "横向")
13471348
("language" "语言")
13481349
("laptop presentations" "幻灯片演示")
1350+
("later" "稍后")
13491351
("large cells" "大单元格")
13501352
("large closing bracket" "大结束括号")
13511353
("large delimiter" "")
@@ -2073,6 +2075,7 @@
20732075
("resize objects" "缩放对象")
20742076
("resize" "改变大小")
20752077
("resized" "")
2078+
("restart" "重启")
20762079
("retain" "保留")
20772080
("retina screen settings" "高分屏设置")
20782081
("retina settings" "高分屏设置")
@@ -2395,6 +2398,10 @@
23952398
("surface" "曲面")
23962399
("swedish" "瑞典语")
23972400
("swiss" "")
2401+
("switch interface theme" "切换界面主题")
2402+
("switch keyboard shortcut style" "切换快捷键显示风格")
2403+
("switch look and feel" "切换外观风格")
2404+
("switch preference" "切换首选项")
23982405
("switch to first" "跳到第前面")
23992406
("switch to formula style" "")
24002407
("switch to last" "跳到最后面")
@@ -2498,6 +2505,8 @@
24982505
("this document has been produced using" "此文档撰写于")
24992506
("this document has not been saved" "现工作的暂存区信息尚未保存")
25002507
("this line" "")
2508+
("this change requires restarting Mogan STEM to take full effect." "此更改需要重新启动 Mogan STEM 才能完全生效。")
2509+
("this change requires restarting Liii STEM to take full effect." "此更改需要重新启动 Liii STEM 才能完全生效。")
25012510
("this page footer" "当前页页脚")
25022511
("this page header" "当前页页眉")
25032512
("this page" "")

TeXmacs/progs/prog/glue-symbols.scm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -727,6 +727,7 @@
727727
"clone-window"
728728
"cpp-buffer-close"
729729
"cpp-confirm-close"
730+
"cpp-confirm-restart"
730731
"cpp-form-dialog"
731732
"cpp-font-selector-dialog"
732733
"cpp-rasterize-widget"

TeXmacs/progs/texmacs/menus/preferences-menu.scm

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,47 @@
2626
;; Preferred scripting language
2727
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2828

29+
;; 三按钮重启确认的正文(陈述句,无问句——问句由按钮表达)。title 由调用方
30+
;; 按字段给出(如「切换界面主题」),本函数只产出通用的「需重启才生效」说明。
2931
(tm-define (restart-required-message)
3032
(if (community-stem?)
3133
(translate "Requires restarting Mogan STEM to take full effect. Restart now?")
3234
(translate "Requires restarting Liii STEM to take full effect. Restart now?")
3335
) ;if
3436
) ;tm-define
3537

38+
(tm-define (restart-effect-message)
39+
(if (community-stem?)
40+
(translate "This change requires restarting Mogan STEM to take full effect.")
41+
(translate "This change requires restarting Liii STEM to take full effect.")
42+
) ;if
43+
) ;tm-define
44+
45+
;; 三按钮重启确认:弹 ConfirmRestart(重启/稍后/取消),按返回值分别
46+
;; restart -> apply-proc + 存盘 + 重启
47+
;; later -> apply-proc(保留新值,不重启)
48+
;; cancel -> rollback-proc(回滚旧值)
49+
;; apply-proc / rollback-proc 为零参过程;用户未定义 save-all-buffers 时惰性加载。
50+
(tm-define (confirm-restart-and-act title apply-proc rollback-proc)
51+
(with msg
52+
(restart-effect-message)
53+
(with choice
54+
(cpp-confirm-restart title msg)
55+
(cond ((== choice "restart")
56+
(apply-proc)
57+
(when (not (defined? 'save-all-buffers))
58+
(use-modules (plugin autosave))
59+
) ;when
60+
(save-all-buffers)
61+
(restart-TeXmacs)
62+
) ;
63+
((== choice "later") (apply-proc))
64+
(else (rollback-proc))
65+
) ;cond
66+
) ;with
67+
) ;with
68+
) ;tm-define
69+
3670
(tm-menu (scripts-preferences-menu)
3771
(let* ((dummy (lazy-plugin-force)) (l (scripts-list)))
3872
(for (name l)

TeXmacs/progs/texmacs/menus/preferences-widgets.scm

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,26 +23,26 @@
2323
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2424

2525

26+
;; 需重启字段的三按钮确认标题映射(内部值 -> 翻译标题)。
27+
28+
(define (restart-preference-title which)
29+
(cond ((== which "look and feel") (translate "Switch look and feel"))
30+
((== which "gui theme") (translate "Switch interface theme"))
31+
((== which "keyboard shortcut style")
32+
(translate "Switch keyboard shortcut style")
33+
) ;
34+
(else (translate "Switch preference"))
35+
) ;cond
36+
) ;define
37+
2638
(tm-define (set-pretty-preference* which pretty-val)
2739
(let* ((old (get-pretty-preference which)))
2840
(when (!= old pretty-val)
29-
(let ((msg (restart-required-message)))
30-
(user-confirm msg
31-
#f
32-
(lambda (answ)
33-
(set-pretty-preference which pretty-val)
34-
(when answ
35-
(begin
36-
(when (not (defined? 'save-all-buffers))
37-
(use-modules (plugin autosave))
38-
) ;when
39-
(save-all-buffers)
40-
(restart-TeXmacs)
41-
) ;begin
42-
) ;when
43-
) ;lambda
44-
) ;user-confirm
45-
) ;let
41+
;; 三按钮确认:重启 / 稍后(保留新值)/ 取消(回滚旧值,修复旧 no 不回滚的 bug)。
42+
(confirm-restart-and-act (restart-preference-title which)
43+
(lambda () (set-pretty-preference which pretty-val))
44+
(lambda () (set-pretty-preference which old))
45+
) ;confirm-restart-and-act
4646
) ;when
4747
) ;let*
4848
) ;tm-define

ai-docs/qml/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ API 速查(`utils/library/dialog-value-table`,entry-key 由调用方自定
9696
| 对话框 | 模态引擎 | 模型 |
9797
|--------|---------|------|
9898
| `ConfirmClose` | `run_qml_dialog`(exec) | 点按钮返回结果 |
99+
| `ConfirmRestart` | `run_qml_dialog`(exec) | 三按钮(立即重启/稍后/取消),返回 `"restart"/"later"/"cancel"` |
99100
| `FormDialog` | `run_qml_dialog`(exec) | 本地暂存 `values`,OK 一次性 submit |
100101
| `FontSelector` | `run_modal_qml_dialog`(setModal+show) | live 写回文档,OK 落定 / Cancel 快照撤销 / Reset 按 global? 分流(文档级系统默认、段落级回快照) |
101102
| `ParagraphFormat` | `run_modal_qml_dialog`(setModal+show) | live 写回(段落 with / 文档 initial),按 scope 撤销 |
@@ -124,6 +125,18 @@ API 速查(`utils/library/dialog-value-table`,entry-key 由调用方自定
124125
在 scm 构造数据时即用 `translate` 包裹,不要硬编码英文。值(数字、内部 key)不翻译。
125126
字典条目按最小粒度登记(如 `"character count"` / `"with spaces"`),系统自动拼接
126127
`"Character count (with spaces)"``"字符数(计空格)"`),不要为每种组合加整条字典。
128+
- **`translate` 的三条自动归一化**(实现在 `src/System/Language/dictionary.cpp`
129+
`dictionary_rep::translate``qt_translate` 同源):
130+
1. **首字母大写折叠**:查表前把首字符转小写再查,命中后把结果首字母大写回。故字典
131+
一律**小写首字母登记**`("switch interface theme" "切换界面主题")`),代码里
132+
`(translate "Switch interface theme")` / `qt_translate("Switch ...")` 均能命中。
133+
仅首字符 ASCII 折叠,非全串大小写不敏感。
134+
2. **递归切分拼接**:整串查不到时,按「非字母字符」剥离前后缀、在最后一个非字母非空格
135+
字符处二分,各段递归 `translate` 再拼接。故带标点/括号的复合短语(统计项、含 `()`
136+
的标题)拆最小词登记即可,**空格不触发切分**——纯空格短语须整条登记。
137+
3. **`::` 后缀剥离**`"File::menu"` 形式递归查 `"File"`,丢弃 `::` 及之后。
138+
- **字典条目按字母序排列**`TeXmacs/plugins/lang/dic/en_US/zh_CN.scm` 等字典文件,
139+
新增条目按首字母段插入(大小写混排时以小写为准),保持可检索。
127140
- **跨弹窗复用的布局常量收进 `Theme.qml`**:行高、间距等可能被多个弹窗共用的数字,统一加在
128141
`atoms/Theme.qml` 的结构尺寸/间距阶梯段。优先用已有常量组合(如 `Theme.btnH + Theme.padS * 2`
129142
表示按钮区高度),避免为单一用途加新常量。成品弹窗只保留本弹窗专属的布局参数(如列宽比

0 commit comments

Comments
 (0)