Skip to content

fix: unify save failure messages with tr() - #419

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

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

Conversation

@JWWTSL

@JWWTSL JWWTSL commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

fix: unify save failure messages with tr()

  1. Root cause: saveComposite() passed raw Qt/OS errorString() to
    saveFailed signal, bypassing app translation and showing English
    on some paths while other paths used tr() showing Chinese
  2. Fix: replace all three errorString() calls with tr() of a unified
    user-facing message, add missing translation entries in .ts files
  3. Impact: save failure dialogs now show consistent localized text;
    signal signature unchanged, no caller impact

Log: save failure prompts now display consistent language

Influence:

  1. Test saving to a read-only system directory, verify Chinese prompt
  2. Test saving to a folder under system disk, verify Chinese prompt
  3. Verify normal save operation is unaffected

fix: 统一保存失败提示的应用级翻译

  1. 根因:saveComposite() 直接透传 Qt/OS 的 errorString() 到
    saveFailed 信号,绕过应用翻译体系,部分错误路径显示英文,
    而其他路径使用 tr() 显示中文,导致提示语不一致
  2. 方案:将三处 errorString() 替换为统一的 tr() 用户提示,
    并在 .ts 翻译文件中补充缺失的翻译条目
  3. 影响:保存失败弹窗在所有路径下统一显示本地化文本,
    信号签名不变,不影响调用方

Log: 保存失败提示语现已统一显示中文

Influence:

  1. 测试保存到只读系统目录,验证提示为中文
  2. 测试保存到系统盘下文件夹,验证提示为中文
  3. 验证正常保存操作不受影响

PMS: BUG-376893

Summary by Sourcery

Ensure image save failures display consistent localized guidance across all save error paths.

Bug Fixes:

  • Unify image save failure notifications under a translatable application message instead of exposing raw system error text.
  • Add the missing Chinese and German translation entries for image editing save errors.

1. Root cause: saveComposite() passed raw Qt/OS errorString() to
   saveFailed signal, bypassing app translation and showing English
   on some paths while other paths used tr() showing Chinese
2. Fix: replace all three errorString() calls with tr() of a unified
   user-facing message, add missing translation entries in .ts files
3. Impact: save failure dialogs now show consistent localized text;
   signal signature unchanged, no caller impact

Log: save failure prompts now display consistent language

Influence:
1. Test saving to a read-only system directory, verify Chinese prompt
2. Test saving to a folder under system disk, verify Chinese prompt
3. Verify normal save operation is unaffected

fix: 统一保存失败提示的应用级翻译

1. 根因:saveComposite() 直接透传 Qt/OS 的 errorString() 到
   saveFailed 信号,绕过应用翻译体系,部分错误路径显示英文,
   而其他路径使用 tr() 显示中文,导致提示语不一致
2. 方案:将三处 errorString() 替换为统一的 tr() 用户提示,
   并在 .ts 翻译文件中补充缺失的翻译条目
3. 影响:保存失败弹窗在所有路径下统一显示本地化文本,
   信号签名不变,不影响调用方

Log: 保存失败提示语现已统一显示中文

Influence:
1. 测试保存到只读系统目录,验证提示为中文
2. 测试保存到系统盘下文件夹,验证提示为中文
3. 验证正常保存操作不受影响

PMS: BUG-376893
@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

The PR makes all saveComposite() failure paths emit one tr()-localized user-facing message, replacing raw platform error text, and updates the English and Simplified Chinese catalogs so save-failure dialogs are consistent without changing signal consumers or normal save behavior.

Sequence diagram for localized composite image save failures

sequenceDiagram
    participant Controller as ImageEditController
    participant File as QSaveFile
    participant Writer as QImageWriter
    participant Dialog as Save failure dialog

    Controller->>File: open(QIODevice::WriteOnly)
    alt open fails
        Controller->>Dialog: saveFailed(tr("Failed to save the image. Please check the file path and permissions."))
    else open succeeds
        Controller->>Writer: write(result)
        alt write fails
            Controller->>Dialog: saveFailed(tr("Failed to save the image. Please check the file path and permissions."))
        else write succeeds
            Controller->>File: commit()
            alt commit fails
                Controller->>Dialog: saveFailed(tr("Failed to save the image. Please check the file path and permissions."))
            end
        end
    end
Loading

File-Level Changes

Change Details Files
Standardize all composite-image save failures on one application-translatable message instead of exposing raw Qt/OS errors.
  • Replace file-open, image-write, and file-commit errorString() emissions with the same tr() message.
  • Keep the saveFailed signal interface and save control flow unchanged.
src/src/imageeditcontroller.cpp
Add translation catalog entries for the save failure message and related image-edit strings.
  • Add the English source entry for the unified save failure prompt.
  • Provide the Simplified Chinese translation for the save failure prompt.
  • Add or retain corresponding image-edit translation metadata for invalid paths and format validation.
src/translations/deepin-image-viewer.ts
src/translations/deepin-image-viewer_zh_CN.ts

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


📊 总体评价

项目 结果
审查结论 代码审查通过
评分详情 本次提交将 ImageEditController::saveComposite() 中三处保存失败的原始系统错误字符串统一替换为可翻译的 tr() 消息, 并同步更新了 Qt 翻译源文件(.ts)和中文翻译文件(_zh_CN.ts)。四维度分析均未发现问题, 语法正确、逻辑清晰,代码质量良好,无性能影响,无安全漏洞。OCR 审查同样未发现任何问题。

🔍 详细分析

1. 语法逻辑 ✅

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

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

建议: ['无需修改,语法逻辑完全正确。']


2. 代码质量 ✅

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

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

建议: ['建议将重复的 tr() 字符串提取为函数级局部常量,例如: const QString errorMsg = tr("Failed to save the image. Please check the file path and permissions."); 以减少重复并便于未来统一修改。']


3. 代码性能 ✅

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

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

建议: ['无性能优化建议,当前实现性能良好。']


4. 代码安全 🔒

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

🔐 发现 0 个安全漏洞

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

建议: ['无需安全加固,当前实现安全合规。']


💡 改进建议代码示例

// 可选优化:提取重复字符串为局部常量 bool ImageEditController::saveComposite(const QUrl &destination, const QVariantList &sources) {
    // ...
    const QString saveFailMsg = tr("Failed to save the image. Please check the file path and permissions.");

    QSaveFile file(targetPath);
    if (!file.open(QIODevice::WriteOnly)) {
        Q_EMIT saveFailed(saveFailMsg);
        return false;
    }
    QImageWriter writer(&file, normalizedSource);
    if (!writer.write(result)) {
        Q_EMIT saveFailed(saveFailMsg);
        file.cancelWriting();
        return false;
    }
    if (!file.commit()) {
        Q_EMIT saveFailed(saveFailMsg);
        return false;
    }
    return true;
}

本报告由 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