Skip to content

fix: prevent text clipping in image annotation save - #427

Open
JWWTSL wants to merge 1 commit into
linuxdeepin:masterfrom
JWWTSL:agent/pms-bug-bot/df27275eace4
Open

JWWTSL wants to merge 1 commit into
linuxdeepin:masterfrom
JWWTSL:agent/pms-bug-bot/df27275eace4

Conversation

@JWWTSL

@JWWTSL JWWTSL commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

fix: prevent text clipping in image annotation save

  1. Root cause: QPainter::drawText with a rect argument clips text
    exceeding the rectangle by default, while the QML preview uses
    CanvasContext.fillText which never clips — the mismatch causes
    text annotations to be truncated in saved images
  2. Fix: add Qt::TextSingleLine | Qt::TextDontClip flags to the text
    annotation drawText call, and Qt::TextDontClip to the number
    annotation drawText call, matching the non-clipping QML preview
  3. Impact: text and number annotations in saved images render
    identically to the edit preview, no effect on other annotation types

Log: Fix text annotation truncation when saving edited images

Influence:

  1. Test adding long text annotations and saving, verify text is complete
  2. Test adding number annotations and saving, verify number is complete
  3. Verify saved image matches the edit preview for text annotations

fix: 修复看图编辑文本标注保存后截断问题

  1. 根因:保存时 QPainter::drawText 传入矩形参数默认裁剪超出边界的
    文本,而 QML 预览使用 CanvasContext.fillText 不裁剪,两者不一致
    导致保存的图片中文本标注被截断
  2. 方案:在文本标注 drawText 调用中添加 Qt::TextSingleLine |
    Qt::TextDontClip 标志,在序号标注 drawText 调用中添加
    Qt::TextDontClip 标志,使保存渲染与 QML 预览一致
  3. 影响:保存图片中的文本和序号标注渲染与编辑预览一致,不影响其他
    标注类型

Log: 修复看图编辑文本标注保存后截断的问题

Influence:

  1. 测试添加长文本标注后保存,验证文本完整不被截断
  2. 测试添加序号标注后保存,验证序号完整不被截断
  3. 验证保存图片中文本标注与编辑预览一致

PMS: BUG-379123

Summary by Sourcery

Bug Fixes:

  • Prevent text and number annotations from being clipped when saving edited images, keeping saved output consistent with the edit preview.

1. Root cause: QPainter::drawText with a rect argument clips text
   exceeding the rectangle by default, while the QML preview uses
   CanvasContext.fillText which never clips — the mismatch causes
   text annotations to be truncated in saved images
2. Fix: add Qt::TextSingleLine | Qt::TextDontClip flags to the text
   annotation drawText call, and Qt::TextDontClip to the number
   annotation drawText call, matching the non-clipping QML preview
3. Impact: text and number annotations in saved images render
   identically to the edit preview, no effect on other annotation types

Log: Fix text annotation truncation when saving edited images

Influence:
1. Test adding long text annotations and saving, verify text is complete
2. Test adding number annotations and saving, verify number is complete
3. Verify saved image matches the edit preview for text annotations

fix: 修复看图编辑文本标注保存后截断问题

1. 根因:保存时 QPainter::drawText 传入矩形参数默认裁剪超出边界的
   文本,而 QML 预览使用 CanvasContext.fillText 不裁剪,两者不一致
   导致保存的图片中文本标注被截断
2. 方案:在文本标注 drawText 调用中添加 Qt::TextSingleLine |
   Qt::TextDontClip 标志,在序号标注 drawText 调用中添加
   Qt::TextDontClip 标志,使保存渲染与 QML 预览一致
3. 影响:保存图片中的文本和序号标注渲染与编辑预览一致,不影响其他
   标注类型

Log: 修复看图编辑文本标注保存后截断的问题

Influence:
1. 测试添加长文本标注后保存,验证文本完整不被截断
2. 测试添加序号标注后保存,验证序号完整不被截断
3. 验证保存图片中文本标注与编辑预览一致

PMS: BUG-379123
@deepin-ci-robot

Copy link
Copy Markdown

[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.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@sourcery-ai

sourcery-ai Bot commented Oct 27, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Updates image composition saving so text and number annotations are not clipped by QPainter, matching the edit preview while leaving other annotation types unchanged.

Flow diagram for unclipped annotation image saving

flowchart LR
    A[Annotation data] --> B[ImageEditController.saveComposite]
    B --> C{Annotation type}
    C -->|Text| D[QPainter.drawText with TextSingleLine and TextDontClip]
    C -->|Number| E[QPainter.drawText with TextDontClip]
    D --> F[Saved image matches edit preview]
    E --> F
    C -->|Other| G[Existing rendering unchanged]
Loading

File-Level Changes

Change Details Files
Align saved annotation text rendering with the non-clipping QML preview.
  • Add TextDontClip to centered number annotations.
  • Add TextSingleLine and TextDontClip to left-aligned text annotations.
src/src/imageeditcontroller.cpp

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

🤖 AI 代码审查报告

总体评分: 100 分 (通过阈值: 70分)

Pass


📊 总体评价

项目 结果
审查结论 代码审查通过
评分详情 本次提交修复了图片标注保存时文字被裁剪的问题,通过在 QPainter::drawText 调用中添加 Qt::TextDontClip 和 Qt::TextSingleLine 标志来防止文本裁剪。变更范围小、目标明确、实现正确,四维度均无问题。

🔍 详细分析

1. 语法逻辑 ✅

评价: 语法正确,逻辑清晰 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: []


2. 代码质量 ✅

评价: 代码结构清晰,注释完整 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: []


3. 代码性能 ✅

评价: 性能良好,资源使用合理 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: []


4. 代码安全 🔒

评价: 存在0个安全漏洞 ✅ 通过

🔐 发现 0 个安全漏洞

安全漏洞详情:
✅ 未发现安全漏洞

建议: []


💡 改进建议代码示例


本报告由 AI 代码审查工具自动生成

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants