Skip to content

[0169] PDF阅读器在占据屏幕一半的时候,自动Fit Width#3526

Merged
da-liii merged 4 commits into
mainfrom
da/0169/screenshot
May 28, 2026
Merged

[0169] PDF阅读器在占据屏幕一半的时候,自动Fit Width#3526
da-liii merged 4 commits into
mainfrom
da/0169/screenshot

Conversation

@da-liii
Copy link
Copy Markdown
Contributor

@da-liii da-liii commented May 27, 2026

Summary

  • 当 PDFReaderWidget 宽度不超过屏幕可用宽度一半时,自动调用 fitWidth()
  • loadFromFile() 加载 PDF 后调用,确保初始显示自动适应宽度
  • 在 resize 防抖回调 onResizeDebounced() 中同样调用,支持窗口从宽变窄时自动适应
  • 引入 autoFitApplied_ 标志位,每个 PDF 加载周期内只自动触发一次,避免覆盖用户手动缩放
  • 新增单元测试 test_autoFitWidth_whenNarrowtest_noAutoFitWidth_whenWide

Test plan

  • xmake b qt_pdf_reader_widget_test 编译通过
  • xmake r qt_pdf_reader_widget_test 全部 41 个测试通过

🤖 Generated with Claude Code

da-liii and others added 4 commits May 27, 2026 20:16
- 新增 maybeAutoFitWidth():当 widget 宽度不超过屏幕可用宽度一半时,自动调用 fitWidth()
- 在 loadFromFile() 加载 PDF 后调用 maybeAutoFitWidth(),确保初始显示自动适应宽度
- 在 resize 防抖回调 onResizeDebounced() 中同样调用 maybeAutoFitWidth(),支持窗口从宽变窄时自动适应
- 引入 autoFitApplied_ 标志位,每个 PDF 加载周期内只自动触发一次,避免覆盖用户手动缩放
- 新增单元测试 test_autoFitWidth_whenNarrow 和 test_noAutoFitWidth_whenWide

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- maybeAutoFitWidth() 现在检测窗口是否真正贴靠到屏幕左/右边缘
- 排除最大化/全屏状态,避免手动缩小窗口误触发
- onResizeDebounced() 增加重置逻辑,离开半屏后可再次触发

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@MoonL79 MoonL79 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@da-liii da-liii merged commit 2d59d6b into main May 28, 2026
3 of 4 checks passed
@da-liii da-liii deleted the da/0169/screenshot branch May 28, 2026 02:39
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