fix(reader): restore arrow key scrolling by removing QAction shortcut registration - #409
Conversation
Reviewer's GuideRestores Qt's default arrow-key and Space scrolling in document reading mode by removing their central QAction registrations and page-level forwarding, while preserving slide-show navigation through SlideWidget focus and keyPressEvent handling. Sequence diagram for mode-specific keyboard handlingsequenceDiagram
actor User
participant Central
participant DocumentView
participant SlideWidget
participant Qt
User->>Central: keyPressEvent(arrow or Space)
alt document reading mode
Central->>Qt: default scrolling
Qt-->>DocumentView: scroll document
else slide show mode
Central->>SlideWidget: keyPressEvent(event)
SlideWidget->>SlideWidget: handleKeyPressEvent(key)
SlideWidget->>Qt: DWidget::keyPressEvent(event)
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
… registration Arrow keys (Left/Right/Up/Down) and Space were registered as QAction shortcuts in Central.cpp constructor, which intercepted key events and prevented Qt's default scrolling behavior in document reading mode. The page navigation logic in CentralDocPage.cpp for these keys was already commented out, so the QAction had no effect except blocking default scrolling. Fix by commenting out the QAction registrations for these keys in Central.cpp, removing the slide widget key forwarding in CentralDocPage.cpp, and adding a keyPressEvent override to SlideWidget with setFocus() in its constructor so slide show mode handles arrow keys and space independently. This restores the fix from commit a81e5e1 that was reverted by the v23 merge commit b20fcf9. Log: 方向键无法滚动文档页面 Bug: https://pms.uniontech.com/bug-view-374547.html
f417b30 to
6c5612b
Compare
deepin pr auto reviewAI 代码审查报告
总体评分
变更概述本次 PR 修复了 deepin-reader 中方向键滚动功能被屏蔽的问题。通过移除 QAction 快捷键注册,恢复方向键的默认滚动行为,同时为幻灯片模式(SlideWidget)添加独立的 keyPressEvent 处理。 修改文件:
维度1:语法逻辑(25分)✓
分析:
结论: 无编译错误,逻辑合理,边界处理完善。 维度2:代码质量(23分)✓
分析:
维度3:代码性能(20分)✓
分析:
结论: 无性能瓶颈,算法复杂度合理。 维度4:代码安全(30分)✓
分析:
漏洞对比统计:新增漏洞 0 个,减少漏洞 0 个,持平 0 个 OCR 审查结果OCR(OpenCodeReview)审查发现 1 条建议:
改进建议建议1:移除注释代码,替换为说明性注释文件: 当前代码: //使用下面5个快捷键会屏蔽主界面对应的功能,故注释
//keyList.append(QKeySequence(Qt::Key_Left));
//keyList.append(QKeySequence(Qt::Key_Right));
//keyList.append(QKeySequence(Qt::Key_Up));
//keyList.append(QKeySequence(Qt::Key_Down));
//keyList.append(QKeySequence(Qt::Key_Space));建议修改: // 方向键和空格键不注册为快捷键,以保留主界面的默认滚动行为审查结论本次 PR 修复了方向键滚动被屏蔽的问题,方案设计合理:
评分: 98/100(优秀) |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: max-lvs, Resurgamz The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
/merge |
fix(reader): restore arrow key scrolling by removing QAction shortcut registration
Arrow keys (Left/Right/Up/Down) and Space were registered as QAction
shortcuts in Central.cpp constructor, which intercepted key events and
prevented Qt's default scrolling behavior in document reading mode.
The page navigation logic in CentralDocPage.cpp for these keys was
already commented out, so the QAction had no effect except blocking
default scrolling.
Fix by commenting out the QAction registrations for these keys in
Central.cpp, removing the slide widget key forwarding in
CentralDocPage.cpp, and adding a keyPressEvent override to SlideWidget
with setFocus() in its constructor so slide show mode handles arrow
keys and space independently. This restores the fix from commit
a81e5e1 that was reverted by the v23 merge commit b20fcf9.
Log: 方向键无法滚动文档页面
Bug: https://pms.uniontech.com/bug-view-374547.html
Summary by Sourcery
Restore document scrolling while retaining keyboard navigation for slide presentations.
Bug Fixes:
Enhancements: