Repository navigation
Conversation
1. Root cause: saveComposite used QPainter::drawText(rect, flags, text) which clips text to the rect boundary, while QML preview used CanvasContext.fillText() without clipping — mismatch caused truncation 2. Fix: add Qt::TextDontClip | Qt::TextSingleLine to text annotation drawText and Qt::TextDontClip to number annotation drawText, matching the QML preview rendering behavior 3. Impact: saved images now render text annotations identically to the on-screen preview, no longer clipping wide text content Log: Fix text truncation in saved edited images to match preview Influence: 1. Test text annotation save with long text content 2. Test number annotation save with multi-digit numbers 3. Verify mixed annotations save correctly fix: 修复保存编辑图片时文本被截断的问题 1. 根因:saveComposite 使用 QPainter::drawText(rect, flags, text) 默认 裁剪文本到矩形边界,而 QML 预览使用 CanvasContext.fillText() 不裁剪 — 两条路径渲染策略不一致导致保存时文本被截断 2. 方案:为文本标注 drawText 添加 Qt::TextDontClip | Qt::TextSingleLine 标志,为序号标注 drawText 添加 Qt::TextDontClip 标志,使保存渲染 行为与 QML 预览一致 3. 影响:保存的图片中文本标注渲染与屏幕预览一致,不再裁剪宽文本 Log: 修复保存编辑图片时文本标注被截断的问题 Influence: 1. 测试长文本标注保存后文本完整不被截断 2. 测试多位数序号标注保存后正常显示 3. 验证混合标注保存结果正确 PMS: BUG-379123
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: JWWTSL 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 |
Reviewer's guide (collapsed on small PRs)Reviewer's GuideUpdates ImageEditController::saveComposite so saved text and number annotations are not truncated by QPainter's default rectangle clipping, matching the on-screen preview. Review the flag semantics and verify long text, number, and mixed annotations after saving. Sequence diagram for annotation preview and save renderingsequenceDiagram
participant User
participant EditCanvas
participant ImageEditController
participant QPainter
User->>EditCanvas: Add text or number annotation
EditCanvas->>EditCanvas: fillText()
EditCanvas-->>User: Preview renders without clipping
User->>ImageEditController: saveComposite()
ImageEditController->>QPainter: drawText(annotation bounds, flags, text)
QPainter-->>ImageEditController: Render annotation without clipping
ImageEditController-->>User: Saved image matches preview
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 代码审查工具自动生成 |
Root Cause Analysis
The save path (
ImageEditController::saveCompositeinimageeditcontroller.cpp) usedQPainter::drawText(rect, flags, text)which clips text to the rectangle boundary by default, while the QML preview path (EditCanvas.qml) usedCanvasContext.fillText()withcontext.scale()that does not clip text. This rendering strategy mismatch caused text annotations to be truncated when saving edited images, even though they displayed correctly in the preview.Key evidence: (1) QML preview uses fixed 20px font +
context.scale()without clipping; (2) C++ save path usesdrawText(QRectF, flags, text)with default clipping enabled; (3) Qt documentation confirmsdrawText(rect, flags, text)clips text to the rectangle.Fix
Added
Qt::TextDontClip | Qt::TextSingleLineflags to the text annotationdrawTextcall andQt::TextDontClipto the number annotationdrawTextcall insaveComposite, making the save rendering behavior consistent with the QML preview (no clipping, single-line rendering).Change Safety Assessment
Code Safety
Business Impact Scope
Affected functional module: Image Editor — Text/Number Annotation Save. When users add text or number annotations in edit mode and save, the saved image rendering now matches the on-screen preview. The change only affects the
drawTextrendering flags withinsaveComposite, with no impact on other editing features (crop, effects, undo/redo, etc.).Verification Suggestion
Test adding long text annotations → save → verify text is complete and not truncated. Test number annotations → save → verify correct display. Verify mixed annotation types save correctly.
根因分析
保存路径(
imageeditcontroller.cpp中的ImageEditController::saveComposite)使用QPainter::drawText(rect, flags, text),默认将文本裁剪到矩形边界内;而 QML 预览路径(EditCanvas.qml)使用CanvasContext.fillText()配合context.scale(),不裁剪文本。两条路径渲染策略不一致导致保存编辑图片时文本标注被截断,尽管预览中显示正常。关键证据:(1) QML 预览使用固定 20px 字号 +
context.scale()不裁剪;(2) C++ 保存路径使用drawText(QRectF, flags, text)且默认启用裁剪;(3) Qt 文档确认drawText(rect, flags, text)会将文本裁剪到矩形内。修复方案
在
saveComposite中为文本标注的drawText调用添加Qt::TextDontClip | Qt::TextSingleLine标志,为序号标注的drawText调用添加Qt::TextDontClip标志,使保存渲染行为与 QML 预览一致(不裁剪、单行渲染)。改动安全评估
代码安全评估
业务影响范围
受影响功能模块:图片编辑 — 文本/序号标注保存。用户在编辑模式添加文本或序号标注并保存时,保存图片的渲染将与屏幕预览一致。改动仅影响
saveComposite内drawText的渲染标志,不影响其他编辑功能(裁剪、特效、撤销重做等)。验证建议
测试添加较长文本标注 → 保存 → 验证文本完整不截断。测试序号标注 → 保存 → 验证显示正常。验证混合标注类型保存正确。
Summary by Sourcery
Bug Fixes: