Repository navigation
Conversation
1. Root cause: saveComposite() emitted raw Qt/OS errorString()
via saveFailed signal, bypassing app-level tr() translation
and producing English messages outside .ts control
2. Fix: replace all three errorString() calls with unified
tr("Failed to save the image. Please check the file path
and permissions.") so messages go through app translation
3. Impact: all save-failure paths now display consistent
localized text, no behavior change for valid save paths
Log: Unify save failure error messages to use app-level translation
Influence:
1. Test saving to a read-only system directory shows localized message
2. Test saving to a folder without write permission shows localized message
3. Verify normal save to a writable path still works correctly
fix: 统一保存失败提示语的翻译
1. 根因:saveComposite() 通过 saveFailed 信号直接透传 Qt/OS 的
errorString(),绕过应用级 tr() 翻译,产生不受 .ts 控制的英文提示
2. 方案:将三处 errorString() 调用统一替换为 tr("Failed to save
the image. Please check the file path and permissions."),
使消息经过应用翻译体系
3. 影响:所有保存失败路径均显示一致的本地化文本,对正常保存路径无行为变化
Log: 统一保存失败时的错误提示语翻译
Influence:
1. 测试保存到只读系统目录时显示本地化提示
2. 测试保存到无写入权限的文件夹时显示本地化提示
3. 验证正常保存到可写路径仍可正常工作
PMS: BUG-376893
|
[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 GuideThe PR standardizes all saveComposite() failure notifications by routing them through a single tr()-translated message instead of raw Qt/OS error strings, while updating translation catalogs; save control flow and successful saves remain unchanged. Sequence diagram for localized image save failuressequenceDiagram
participant Controller as ImageEditController
participant File as QSaveFile
participant Writer as QImageWriter
participant UI as Save failure UI
Controller->>File: open(QIODevice::WriteOnly)
alt open fails
Controller->>UI: 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->>UI: saveFailed(tr("Failed to save the image. Please check the file path and permissions."))
else write succeeds
Controller->>File: commit()
alt commit fails
Controller->>UI: saveFailed(tr("Failed to save the image. Please check the file path and permissions."))
end
end
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
deepin pr auto review🤖 AI 代码审查报告📊 总体评价
🔍 详细分析1. 语法逻辑 ✅评价: 语法正确,逻辑清晰 ✅ 通过 潜在问题: 建议: [] 2. 代码质量 ✅评价: 代码结构清晰,注释完整 ✅ 通过 潜在问题: 建议: ['建议将重复的提示字符串提取为局部常量,如 const QString errorMsg = tr("Failed to save the image. Please check the file path and permissions."); 然后在三处 Q_EMIT saveFailed(errorMsg) 中复用,提高可维护性'] 3. 代码性能 ✅评价: 性能良好,资源使用合理 ✅ 通过 潜在问题: 建议: [] 4. 代码安全 🔒评价: 存在0个安全漏洞 ✅ 通过
安全漏洞详情: 建议: [] 💡 改进建议代码示例// 建议优化:提取重复字符串为局部常量
bool ImageEditController::saveComposite(const QUrl &destination, const QVariantList &extra)
{
// ... 前置逻辑 ...
QSaveFile file(targetPath);
if (!file.open(QIODevice::WriteOnly)) {
const QString errorMsg = tr("Failed to save the image. Please check the file path and permissions.");
Q_EMIT saveFailed(errorMsg);
return false;
}
QImageWriter writer(&file, normalizedSource);
if (!writer.write(result)) {
const QString errorMsg = tr("Failed to save the image. Please check the file path and permissions.");
Q_EMIT saveFailed(errorMsg);
file.cancelWriting();
return false;
}
if (!file.commit()) {
const QString errorMsg = tr("Failed to save the image. Please check the file path and permissions.");
Q_EMIT saveFailed(errorMsg);
return false;
}
return true;
}本报告由 AI 代码审查工具自动生成 |
fix: unify save error messages with tr()
via saveFailed signal, bypassing app-level tr() translation
and producing English messages outside .ts control
tr("Failed to save the image. Please check the file path
and permissions.") so messages go through app translation
localized text, no behavior change for valid save paths
Log: Unify save failure error messages to use app-level translation
Influence:
fix: 统一保存失败提示语的翻译
errorString(),绕过应用级 tr() 翻译,产生不受 .ts 控制的英文提示
the image. Please check the file path and permissions."),
使消息经过应用翻译体系
Log: 统一保存失败时的错误提示语翻译
Influence:
PMS: BUG-376893
Summary by Sourcery
Use localized, consistent error messaging for failed image saves while preserving normal save behavior.
Bug Fixes:
Chores: