Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions devel/0405.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# [0405] 修复主页 New 卡片使用无效样式导致模式工具栏图标缺失

## 相关文档
- [dddd.md](dddd.md) - 任务文档模板
- [1002.md](1002.md) - 将打开文件功能从侧边栏迁移到主页

## 任务相关的代码文件
- `src/Plugins/Qt/qt_home_page.cpp`

## 如何测试

### 确定性测试(单元测试)

### 非确定性测试(文档验证)
1. 启动应用,点击主页 "New" 卡片新建空白文档
2. 确认底部模式工具栏图标完整显示(如 Share to zhihu、新起一节等)
3. 确认文档正常渲染,无样式缺失异常

## 如何提交

提交前执行以下最少步骤:

```bash
# 确认修改仅涉及指定文件
git diff --stat
```

## What

修复 commit 41acb4906 引入的回归问题:主页 "New" 卡片新建文档时使用了无效的样式 ID `"new"`,导致模式工具栏部分图标缺失。

1. 在 `qt_home_page.cpp` 的 `createDocumentWithStyle` 中,点击 `"new"` 卡片时传递的样式名由 `"new"` 恢复为 `"generic"`

## Why

commit 41acb4906 将启动页中 "New" 卡片的内部样式 ID 从 `"generic"` 改成了 `"new"`,使语义更清晰。但对应的 Scheme 调用 `(new-document-with-style "new")` 会将 `"new"` 直接传给 `(init-style)`,而 TeXmacs 的默认样式文件是 `generic.ts`,并不存在 `new.ts`。文档加载了无效的 `"new"` 样式后,所有依赖样式判断的菜单和工具栏(如 Share to zhihu、新起一节等)都无法正常渲染,导致图标缺失。

## How

在 `createDocumentWithStyle` 中保留 `"new"` 作为 UI 卡片的内部标识(用于区分 New/Open/Template 等卡片),但在调用 Scheme 函数时显式传递正确的默认样式名 `"generic"`:

```cpp
if (styleId == "new") {
eval_scheme ("(new-document-with-style \"generic\")");
return;
}
```

这样 `"new"` 仅作为 C++ 层的卡片标识,不影响文档样式的初始化。
2 changes: 1 addition & 1 deletion src/Plugins/Qt/qt_home_page.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,7 @@ QtHomePage::onRecentDocContextMenu (const QPoint& pos) {
void
QtHomePage::createDocumentWithStyle (const QString& styleId) {
if (styleId == "new") {
eval_scheme ("(new-document-with-style " * qt_scheme_quote (styleId) * ")");
eval_scheme ("(new-document-with-style \"generic\")");
return;
}

Expand Down
Loading