Repository navigation
fix: resolve content area spacing and alignment issues - #437
Draft
GongHeng2017 wants to merge 1 commit into
Draft
GongHeng2017 wants to merge 1 commit into
GongHeng2017 wants to merge 1 commit into
Conversation
1. Root cause: layout chain sets zero margins (setContentsMargins(0,0,0,0)) at CentralDocPage, leaving no gap between titlebar and content area; SheetBrowser lacks explicit alignment, causing horizontal asymmetry 2. Fix: set top margin to 10px in CentralDocPage layout and add setAlignment(Qt::AlignHCenter | Qt::AlignTop) in SheetBrowser 3. Impact: only UI layout parameters changed, no function signatures or core rendering logic affected Log: fix content area zero vertical gap with titlebar and horizontal misalignment Influence: 1. Test PDF opening with different page sizes for correct spacing and centering 2. Test window resize to verify alignment persists 3. Test multi-page navigation to ensure layout consistency fix: 修复内容区间距缺失和水平未居中问题 1. 根因:布局链中 CentralDocPage 设置零边距(setContentsMargins(0,0,0,0)), 标题栏与内容区之间无垂直间距;SheetBrowser 未设置对齐方式,内容区 在视口中水平未居中 2. 方案:CentralDocPage 布局上边距设为 10px,SheetBrowser 构造函数中 添加 setAlignment(Qt::AlignHCenter | Qt::AlignTop) 确保水平居中 3. 影响:仅修改 UI 布局参数,不涉及函数签名或核心渲染逻辑 Log: 修复内容区与标题栏零间距及水平未居中问题 Influence: 1. 测试不同页面尺寸的 PDF 打开后的间距和居中效果 2. 测试窗口缩放后对齐是否保持 3. 测试多页翻页后布局一致性 PMS: BUG-193233
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: GongHeng2017 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 |
GongHeng2017
marked this pull request as draft
October 29, 2026 20:41
Reviewer's guide (collapsed on small PRs)Reviewer's GuideFixes document viewer layout positioning with a 10px gap below the titlebar and explicit horizontal centering of page content, without changing rendering or document-processing behavior. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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.
Root Cause Analysis
The document viewer (deepin-reader) has two UI layout issues: (1) the content area has zero vertical gap with the titlebar because
CentralDocPagesetssetContentsMargins(0, 0, 0, 0)in its layout, and the entire layout chain (MainWindow → Central → CentralDocPage) propagates zero margins; (2) the content area is not horizontally centered becauseSheetBrowser(aQGraphicsView) does not set an explicit alignment, and the scene's centering is based onmaxWidth(widest page) rather than viewport width. Pixel analysis of the bug screenshot confirms: y=122 is white (255,255,255), y=123 is content color (230,238,237) — zero gap; left margin 40px ≠ right margin 90px.Fix Approach
CentralDocPage.cpp:110: ChangesetContentsMargins(0, 0, 0, 0)tosetContentsMargins(0, 10, 0, 0)to add a 10px top margin between the titlebar and content area.SheetBrowser.cpp:65: AddsetAlignment(Qt::AlignHCenter | Qt::AlignTop)in the constructor to ensure the scene content is horizontally centered in the viewport.Change Safety Assessment
Code Safety
5d71add4), not from any historical bug fix. No historical fix is reverted.referenceslist is empty.Business Impact Scope
Affected module: document viewer layout display. The changes affect how PDF/document pages are positioned in the application window — vertical spacing between titlebar and content, and horizontal centering of content within the viewport. No core functionality (parsing, rendering, search, annotation) is affected.
Verification Suggestion
Test opening PDFs of various page sizes to verify correct spacing and centering. Test window resize and multi-page navigation to ensure layout consistency.
根因分析
文档查看器(deepin-reader)存在两个 UI 布局问题:(1)内容区与标题栏之间无垂直间距,因为
CentralDocPage在布局中设置了setContentsMargins(0, 0, 0, 0),整条布局链(MainWindow → Central → CentralDocPage)均传播零边距;(2)内容区水平未居中,因为SheetBrowser(QGraphicsView)未设置显式对齐方式,且场景居中基于maxWidth(最宽页面)而非视口宽度。Bug 截图像素分析确认:y=122 为白色 (255,255,255),y=123 为内容色 (230,238,237)——零间距;左边距 40px ≠ 右边距 90px。修复方案
CentralDocPage.cpp:110:将setContentsMargins(0, 0, 0, 0)改为setContentsMargins(0, 10, 0, 0),在标题栏与内容区之间添加 10px 上边距。SheetBrowser.cpp:65:在构造函数中添加setAlignment(Qt::AlignHCenter | Qt::AlignTop),确保场景内容在视口中水平居中。改动安全评估
代码安全评估
5d71add4),非历史 bug 修复产物,不撤销任何已有修复。业务影响范围
受影响模块:文档查看器布局显示。改动影响 PDF/文档页面在应用窗口中的定位——标题栏与内容区的垂直间距、内容区在视口中的水平居中。不涉及核心功能(解析、渲染、搜索、注释)。
验证建议
测试打开不同页面尺寸的 PDF,验证间距和居中效果。测试窗口缩放和多页翻页,确保布局一致性。
Summary by Sourcery
Bug Fixes: