Skip to content

[6245] 默认大纲侧边栏宽度与模式工具栏分隔线对齐 - #4790

Merged
PinkMagicFly merged 2 commits into
mainfrom
pigmagicfly/6245/align-outline-toolbar-separator
Nov 16, 2026
Merged

PinkMagicFly merged 2 commits into
mainfrom
pigmagicfly/6245/align-outline-toolbar-separator

Conversation

@PinkMagicFly

Copy link
Copy Markdown
Contributor

What

打开文档显示左侧大纲侧边栏(pdfOutlineDock)时,在默认状态下(未手动自定义宽度,或仅保留旧版自动写入的默认值 300)使其右边缘与上方模式工具栏(modeToolBar)第一个垂直分隔线对齐。

Why

  1. 此前大纲默认宽度固定为 300 逻辑像素,而 modeToolBar 第一个垂直分隔线在不同平台/DPI 下的实际位置约为 290~296 逻辑像素,导致打开文档后大纲右边缘与上方分隔线错位。
  2. 旧版 OutlineWidget::resizeEvent 会在首次显示时自动将默认宽度 300 写入用户偏好 "outline sidebar width",导致后续打开文档直接沿用旧默认值。

How

  • src/Plugins/Qt/qt_pdf_outline_widget.hpp / .cpp:
    • 将兜底默认宽度 kOutlineDefaultWidth 调整为 290,新增 OutlineWidget::defaultWidth() 与 OutlineWidget::separatorAlignWidth(QMainWindow*, QToolBar*)。
    • 新增 OutlineWidget::applyDockWidth(QMainWindow*, int),在程序化调整 dock 宽度时抑制 resizeEvent 的偏好落盘,避免将默认对齐宽度误写为用户自定义偏好。
  • src/Plugins/Qt/qt_tm_widget.cpp:
    • 新增 has_custom_outline_width() 区分用户真实自定义宽度与旧版自动写入的 300。
    • 在 restore_outline_dock_width 中优先对齐 modeToolBar 第一个可见分隔符中心横坐标,并在 QTimer::singleShot(0, ...) 与 SLOT_MODE_ICONS 刷新后补齐对齐。
  • tests/Plugins/Qt/qt_outline_widget_test.cpp:
    • 新增 test_separatorAlignWidth_and_defaultWidth 单元测试。

验证结果

  • gf fmt --changed-since=main:通过
  • xmake b qt_outline_widget_test && xmake r qt_outline_widget_test:25 passed, 0 failed
  • xmake build --yes stem && xmake install --yes stem:构建并安装成功
  • 手动 GUI 验收:待用户在端到端界面中确认对齐效果

@PinkMagicFly
PinkMagicFly merged commit 2a4f405 into main Nov 16, 2026
5 of 6 checks passed
@PinkMagicFly
PinkMagicFly deleted the pigmagicfly/6245/align-outline-toolbar-separator branch November 16, 2026 07:03
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.

1 participant