Repository navigation
fix: use DevicePixel for print page rect under Qt6 - #671
deepin-bot[bot] merged 1 commit into
Conversation
1. Qt6 print engines use the printer's native resolution, not 72 DPI. 2. pageRect(Point) broke unit consistency: margins and fonts are in device pixels, so layout got wrong scale and negative title box. 3. Restore Qt5 pageRect() semantics by using DevicePixel in all 3 print paths (doPrint, doPrintWithLargeDoc, asynPrint). Log: Fixed broken Qt6 print layout: oversized text, wrong page count and missing page numbers. Influence: 1. Open a text file, press Ctrl+P, check 2cm margins and normal font size in print preview. 2. Export to PDF (A4) from the print dialog and verify total page count and bottom-right page numbers. 3. Open a large file (>1MB) to hit the large-doc print path and flip preview pages to check layout stability. fix: 修复Qt6下打印页面矩形单位错误导致的排版异常 1. Qt6 打印引擎使用打印机原生分辨率,不再默认 72 DPI。 2. pageRect(Point) 与边距、字号的设备像素单位不一致,导致缩放 错误且页码框宽度为负。 3. 三处打印路径(doPrint/doPrintWithLargeDoc/asynPrint)恢复 Qt5 pageRect() 的设备像素语义。 Log: 修复 Qt6 下打印及打印预览排版错乱(文字过大、页数异常、 页码缺失)的问题。 Influence: 1. 打开文本文件,Ctrl+P 打印预览,检查 2 厘米页边距与字号是否 正常。 2. 在打印对话框导出 PDF(A4),检查总页数与右下角页码是否 正确。 3. 打开大文件(大于 1MB)走大文档打印路径,翻页预览检查排版 稳定。 PMS: BUG-380145
Reviewer's guide (collapsed on small PRs)Reviewer's GuideUpdates all Qt6 printing paths to use device-pixel page rectangles, matching the units used for margins, font sizing, page sizing, and painter coordinates; this fixes layout scaling and pagination issues while retaining Qt5 behavior. Flow diagram for Qt6 print layout coordinate alignmentflowchart LR
P[QPrinter] --> R[pageRect DevicePixel]
R --> L[Page layout and margins]
L --> Q[QPainter coordinates]
Q --> O[Correct print and preview pagination]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
deepin pr auto review🤖 AI 代码审查报告📊 总体评价
🔍 详细分析1. 语法逻辑 ✅评价: 语法正确,逻辑清晰 ✅ 通过 潜在问题: 建议: [] 2. 代码质量 ✅评价: 代码结构清晰,注释完整 ✅ 通过 潜在问题: 建议: [] 3. 代码性能 ✅评价: 性能良好,资源使用合理 ✅ 通过 潜在问题: 建议: [] 4. 代码安全 🔒评价: 存在0个安全漏洞 ✅ 通过
安全漏洞详情: 建议: [] 💡 改进建议代码示例本报告由 AI 代码审查工具自动生成 |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: lzwind, pengfeixx 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 |
Summary
Qt6 打印引擎使用打印机原生分辨率(
setResolution()已废弃无效),而pageRect(QPrinter::Point)返回磅(1/72 英寸)单位,与代码中按设备像素计算的页边距、字号、setPageSize不一致,导致打印及打印预览排版错乱:文字过大、每行字符极少、总页数异常、页码框宽度为负不显示。Changes
src/widgets/window.cpp三处打印路径(doPrint/doPrintWithLargeDoc/asynPrint)将pageRect(QPrinter::Point)改为pageRect(QPrinter::DevicePixel),恢复 Qt5 无参pageRect()的设备像素语义,与 painter 坐标系及边距/字号计算单位保持一致。Testing
PMS: BUG-380145
Summary by Sourcery
Bug Fixes: