diff --git a/TeXmacs/progs/generic/insert-menu.scm b/TeXmacs/progs/generic/insert-menu.scm index 02085af8a4fdf07a5951eb81bd4516b0d994135e..4a0ebf0e7dc4f2b00d2c0ec89d61ab19c3990677 100644 --- a/TeXmacs/progs/generic/insert-menu.scm +++ b/TeXmacs/progs/generic/insert-menu.scm @@ -29,7 +29,7 @@ --- (when (not (selection-active?)) (if (detailed-menus?) - ("Include" (choose-file make-include "Include file" "")))) + ("Include" (choose-file make-include "Include file" "action_include")))) (when (not (selection-active-non-small?)) ("Link to URL" (make 'slink)) ("Hyperlink" (make 'hlink)) diff --git a/devel/202_82.md b/devel/202_82.md new file mode 100644 index 0000000000000000000000000000000000000000..e6b1bec253a903c4c5f4d4b40a9cd40cbbc228cb --- /dev/null +++ b/devel/202_82.md @@ -0,0 +1,36 @@ +# 202_82 限制"插入->链接->包含文件"的文件格式 + +## 如何测试 + +1. 点击 `插入 -> 链接 -> 包含文件` +2. 确认过滤器显示:*.tmu *.tm +3. 确认只能看到和选择 tmu、tm格式的文件 +4. 选择一个 tmu 或 tm 文件,确认成功插入 include 标记 + +## 2025/12/11 修复了插入->链接->包含文件选择链接文件时易卡死的问题 + +### What + +1. 添加新的文件类型标识符 `action_include` +2. 在 qt_chooser_widget.cpp 中添加对应的文件过滤器逻辑 +3. 修改 insert-menu.scm 中的类型参数从空字符串改为 "action_include" +4. 在 set_type 函数中添加 `nameFilters.clear()` + +### Why + +防止用户选择大文件或不支持格式,避免界面卡死。 + +### How + +1. **qt_chooser_widget.cpp **: + + - 第 165 行:添加 `nameFilters.clear()`(清空累积的旧过滤器) + - 第 183 行:添加 `action_include` 的 `mainNameFilter` + - 第 253 行:添加 `*.tmu *.tm `过滤器 + +2. **insert-menu.scm 中**: + + - 第 32 行:将 choose-file 调用的 type 参数从空字符串 "" 改为 "action_include" + + + diff --git a/src/Plugins/Qt/qt_chooser_widget.cpp b/src/Plugins/Qt/qt_chooser_widget.cpp index 436a11bd9c5c8f53ff5a94dc8e24bd549fb7aed0..847d424995a88e5b4415f1c5e7f3313a15dc9240 100644 --- a/src/Plugins/Qt/qt_chooser_widget.cpp +++ b/src/Plugins/Qt/qt_chooser_widget.cpp @@ -162,6 +162,7 @@ qt_chooser_widget_rep::plain_window_widget (string s, command q, int b) { bool qt_chooser_widget_rep::set_type (const string& _type) { QString mainNameFilter; + nameFilters.clear (); // Clear previous filters if (_type == "directory") { type= _type; return true; @@ -180,6 +181,9 @@ qt_chooser_widget_rep::set_type (const string& _type) { else if (_type == "action_save_as") { mainNameFilter= to_qstring (translate ("STEM files")); } + else if (_type == "action_include") { + mainNameFilter= to_qstring (translate ("STEM files for include")); + } else if (_type == "text") { mainNameFilter= to_qstring (translate ("Plain text files")); } @@ -247,6 +251,12 @@ qt_chooser_widget_rep::set_type (const string& _type) { nameFilters << mainNameFilter; nameFilters << to_qstring (translate ("TM files") * " (*.tm)"); } + else if (_type == "action_include") { + mainNameFilter+= " (*.tmu *.tm)"; + nameFilters << mainNameFilter; + nameFilters << to_qstring (translate ("TMU files") * " (*.tmu)"); + nameFilters << to_qstring (translate ("TM files") * " (*.tm)"); + } else { mainNameFilter+= " ("; object ret = call ("format-get-suffixes*", _type);