Skip to content

[6241] 修复隐藏状态启动时无法通过底部页码按钮展开大纲侧边栏 - #4779

Merged
da-liii merged 2 commits into
mainfrom
6241-outline-sidebar-toggle
Nov 13, 2026
Merged

da-liii merged 2 commits into
mainfrom
6241-outline-sidebar-toggle

Conversation

@da-liii

@da-liii da-liii commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

问题

当 "outline sidebar" 偏好为 "off"(上次退出时收起了大纲侧边栏)时,通过 xmake r stem ~/git/xiyouji/xiyouji.stem 启动后,点击左下角状态栏「页面: x/y」按钮无法展开 Outline 侧边栏。

根因:PR #4227 引入的 outline_sidebar_enabled() 检查错误地把「视图显隐偏好」与「大纲数据模型加载」绑定在一起——偏好为 off 时 loadDocumentOutline/setOutline 直接 bridge_->clear() 清空数据,导致 hasContent() 恒为 false;用户点击按钮虽将偏好切为 on,但 update_visibility 里 new_pdfOutlineVisibility = hasContent() 仍为 false,侧边栏无法显示(数据死锁)。

修复

  • 数据解耦(qt_pdf_outline_widget.cpp):setOutline/loadDocumentOutline 始终填充大纲数据模型,仅按偏好设置 setVisible,保证 hasContent() 如实反映文档大纲
  • 按需刷新(qt_tm_widget.cpp):toggle_outline_sidebar 在编辑器模式下展开时主动 loadDocumentOutline(),确保展开时数据就绪
  • 状态同步(qt_tm_widget.cpp SLOT_FILE):编辑器模式下显式同步 setVisible(hasContent())
  • 单元测试:新增 test_setOutline_preference_off,验证偏好 off 时数据保留(hasContent() 为 true)且控件隐藏(isVisible() 为 false)

测试

  • xmake b qt_outline_widget_test && xmake r qt_outline_widget_test(23 passed)
  • gf fmt --changed-since=main(无格式问题)
  • 手动验证:off 状态启动 → 点击「页面: 1 / 1」按钮 → 侧边栏正常展开

任务文档:dev-agent 仓库 devel/6241.stem

da-liii and others added 2 commits November 13, 2026 00:07
- setOutline/loadDocumentOutline 不再在偏好 off 时清空大纲数据,仅隐藏 dock
- toggle_outline_sidebar 展开时按需重载文档大纲
- SLOT_FILE 编辑器模式显式同步 outline dock 可见性
- 新增单元测试 test_setOutline_preference_off
@da-liii
da-liii merged commit 5d2166f into main Nov 13, 2026
12 checks passed
@da-liii
da-liii deleted the 6241-outline-sidebar-toggle branch November 13, 2026 02:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants