[0120] 在 Mogan STEM 中实现 PDF 阅读功能#3351
Merged
Merged
Conversation
- 新增 is_pdf_tab_file() 工具函数,通过后缀检测 PDF 文件 - qt_tm_widget_rep 集成 QTPdfPreviewWidget,支持编辑器/启动页/PDF 三种模式切换 - Scheme 层新增 load-pdf-buffer,在 load-buffer-main/load-browse-buffer/load-document 入口拦截 PDF - File -> Open 对话框默认支持 *.pdf 文件 - PDF 渲染区域外背景使用 QPalette::Mid,与编辑器外围颜色一致 - 添加 C++ 单元测试:qt_pdf_tab_utils_test、qt_pdf_preview_widget_test - 打开过的 PDF 自动加入最近文档列表 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- 新增 PDFReaderWidget:基于 QScrollArea 的连续滚动 PDF 阅读器 - 支持方向键和鼠标滚轮上下滑动浏览 - 页面垂直排列,自适应窗口宽度重新渲染 - qt_tm_widget 改用 PDFReaderWidget,QTPdfPreviewWidget 保持原样 - 代码格式化 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
QTPdfPreviewWidget 保持原样,PDF 阅读功能由新新增的 PDFReaderWidget 提供。 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- 重写 keyPressEvent,空格键向下滚动 90% 视口高度 - loadFromFile 末尾调用 adjustSize 确保布局即时更新 - 新增 qt_pdf_reader_widget_test 覆盖创建、加载和空格键滚动 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
将 preview-file 从 open-url 改为 load-pdf-buffer, 使预览 PDF 时在 Mogan 内部新标签页打开,而不是调用外部程序。 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- 重写 keyPressEvent 处理回车复制和 Escape 取消选择 - 解决焦点在 PDFReaderWidget 上时键盘事件未被捕获的问题 - 添加单元测试验证回车复制和 Escape 取消行为 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- 将 tm-files.scm 中的 load-pdf-buffer 由 define 改为 tm-define, 使其可被 tm-print.scm 中的 preview-file 正常调用 - 格式化 Qt PDF 阅读器相关代码 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
矩形选框功能存在已知问题,计划在后续版本中重新实现。 本次提交先行移除相关代码以便合并主干。 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
GatsbyUSTC
approved these changes
May 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
在 Mogan STEM 中实现基础 PDF 阅读功能,使打开 PDF 文件时直接在应用内以标签页形式展示。
Changes
C++ 基础设施
is_pdf_tab_file()工具函数(通过后缀检测 PDF)PDFReaderWidget:基于QScrollArea的连续滚动 PDF 阅读器qt_tm_widget_rep集成PDFReaderWidget,支持编辑器/启动页/PDF 三种模式切换QTPdfPreviewWidget保持原样,继续用于模板预览Scheme 层
load-pdf-buffer函数,用原始 PDF 路径直接创建 bufferload-buffer-main、load-browse-buffer、load-document入口拦截 PDFUI
File -> Open对话框默认支持*.pdfQPalette::Mid,与编辑器外围颜色一致测试
qt_pdf_tab_utils_test:验证is_pdf_tab_file()后缀检测Test Plan
File -> Open打开 PDF,验证在标签页内打开🤖 Generated with Claude Code