[0153] PDF 阅读器支持链接悬停光标和点击跳转#3444
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- 使用 MuPDF fz_load_links 提取每页链接信息 - 鼠标悬停链接时显示 PointingHandCursor - 点击内部链接跳转到对应页面,外部链接通过 QDesktopServices 打开 - 拖动时不触发链接点击,避免和 QScroller 拖动冲突 - 参考 Okular 的链接处理实现 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
MuPDF 的 fz_rect 使用左下角为原点的 PDF 坐标系, 而 Qt 使用左上角为原点的 widget 坐标系。 提取链接时需将 Y 坐标翻转,否则链接检测完全失效。 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
在 extractPageLinks 和 linkAtPos 中添加 LIII_DEBUG 日志, 用于排查链接检测和坐标匹配问题。 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Qt 的 MouseMove 事件(无按钮按下时)只会发送给鼠标正下方的 widget。 如果 page label 的 mouseTracking 为 false,事件根本不会生成, viewport 的 eventFilter 永远收不到 hover 事件,导致链接悬浮和点击完全失效。 修复: 1. 每个 page label 创建时加上 label->setMouseTracking(true) 2. onRectSelectToggled 中不再关闭 viewport 的 mouseTracking Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- 移除 QScroller 的自动 eventFilter,由 eventFilter 手动驱动 handleInput, 避免 QScroller 拦截 MouseMove 事件 - 设置 contentWidget 和 QLabel 的 WA_TransparentForMouseEvents, 使鼠标事件直达 viewport - 使用 QLabel::contentsRect()(排除 CSS border)计算归一化坐标, 修复因 1px border 导致的链接坐标偏移 - 使用 fz_resolve_link 解析 #nameddest 等内部链接为目标页码, 支持跳转到 named destination - 统一 eventFilter 入口的坐标转换逻辑,消除重复代码 - 新增 test_linkHoverViaPostedEvent 和 test_linkClickAfterQScrollerPress 测试 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
链接坐标和 fz_bound_page 在同一坐标空间中,不需要 Y 翻转, 直接用链接坐标减去页面框原点做归一化即可。 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- 移除 extractPageLinks、linkAtPos、updateLinkCursor、eventFilter 中的 LIII_DEBUG 调试日志 - 移除在 headless 环境下不可靠的 test_dragScrollsDown 测试 - 经 bin/format 格式化 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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
Test plan
🤖 Generated with Claude Code