Repository navigation
fix: add scan completion notification message - #49
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideThe scan completion callback now emits success or failure toast notifications through DMessageManager, making scan-save results visible to users without changing the existing asynchronous save flow. Sequence diagram for scan completion notificationssequenceDiagram
participant ScanWidget
participant QtConcurrent
participant DMessageManager
ScanWidget->>QtConcurrent: saveScan(request)
QtConcurrent-->>ScanWidget: result
alt result.success
ScanWidget->>DMessageManager: sendMessage(window(), successIcon, savedPath)
else save failed
ScanWidget->>DMessageManager: sendMessage(window(), warningIcon, failureMessage)
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="src/ui/scanwidget.cpp" line_range="630" />
<code_context>
m_historyEdit->moveCursor(QTextCursor::Start);
m_historyEdit->insertPlainText(result.filePath + "\n");
+ DMessageManager::instance()->sendMessage(window(), QIcon::fromTheme("dialog-ok"),
+ tr("Scan completed, saved to: %1").arg(result.filePath));
} else {
qCWarning(app) << "Failed to save scan to:" << result.filePath;
</code_context>
<issue_to_address>
**Notifications stay in English**
When the app runs under a supported non-English locale, the translation catalogs lack both strings passed to `tr()`, so Qt falls back to the English source text for the success and failure notifications; users see English toasts.
Add translations for both notification strings to the locale catalogs.
Also at `src/ui/scanwidget.cpp:633-635`.
</issue_to_address>1. Root cause: onScanFinished() only logged debug output and wrote to a hidden m_historyEdit widget, no user-visible notification shown 2. Fix: use DMessageManager to display success/failure messages after scan save completes, matching existing pattern in mainwindow.cpp 3. Impact: users now see a confirmation message when scan completes successfully or fails to save Log: Added scan completion notification message Influence: 1. Test scan completion with a connected scanner device 2. Verify success message displays with saved file path 3. Verify failure message displays when save fails fix: 添加扫描完成提示消息 1. 根因:onScanFinished() 仅输出 debug 日志并写入隐藏的 m_historyEdit 控件,无任何用户可见通知 2. 方案:使用 DMessageManager 在扫描保存完成后显示成功/失败提示, 与 mainwindow.cpp 中现有模式一致 3. 影响:用户现在可以看到扫描完成成功或保存失败的提示消息 Log: 添加扫描完成提示消息 Influence: 1. 测试连接扫描仪设备后完成扫描 2. 验证成功时显示包含保存文件路径的提示 3. 验证保存失败时显示失败提示 PMS: BUG-323729
e540036 to
8ca9c12
Compare
deepin pr auto review🤖 AI 代码审查报告📊 总体评价
🔍 详细分析1. 语法逻辑 ✅评价: 优秀 ✅ 通过 潜在问题: 建议: 代码语法正确,逻辑清晰,无编译错误风险。DMessageManager::instance()->sendMessage() 调用符合 DTK API 规范,tr() 国际化函数使用正确,QIcon::fromTheme() 使用标准图标主题名称。QFutureWatcher 信号在主线程触发,UI 操作线程安全。 2. 代码质量 ✅评价: 优秀 ✅ 通过 潜在问题: 建议: 建议在新增的通知代码处添加简短注释,说明通知的目的。代码结构清晰,翻译文件同步更新完整,4种语言翻译均已覆盖新增字符串。 3. 代码性能 ✅评价: 优秀 ✅ 通过 潜在问题: 建议: 性能良好,DMessageManager 消息通知为轻量级 UI 操作,QIcon::fromTheme 使用图标缓存,无性能瓶颈。 4. 代码安全 🔒评价: 优秀 ✅ 通过
安全漏洞详情: 建议: 存在0个安全漏洞。result.filePath 来自文件保存对话框返回值,非用户直接输入,无注入风险。通知消息中展示文件路径属于正常用户体验需求,不构成敏感信息泄露。 💡 改进建议代码示例// 扫描完成通知
DMessageManager::instance()->sendMessage(window(),
QIcon::fromTheme("dialog-ok"),
tr("Scan completed, saved to: %1").arg(result.filePath));
// 扫描保存失败通知
DMessageManager::instance()->sendMessage(window(),
QIcon::fromTheme("dialog-warning"),
tr("Failed to save scan."));本报告由 AI 代码审查工具自动生成 |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: lzwind, re2zero 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 |
|
/forcemerge |
|
This pr force merged! (status: unstable) |
Root Cause Analysis
When a scan completes,
ScanWidget::onScanFinished()only writes debug logs viaqCDebug/qCWarningand inserts the file path intom_historyEdit, which is hidden (m_historyEdit->hide()at line 178). No user-visible notification is shown after scan completion. The root cause is the absence of any UI feedback mechanism in the scan completion callback. Key evidence:src/ui/scanwidget.cpp:625-636— only debug logging and hidden text edit update;src/ui/scanwidget.cpp:178—m_historyEditis hidden;src/mainwindow.cpp:80,205—DMessageManageralready used elsewhere in the project.Fix
Added
DMessageManager::sendMessage()calls in theonScanFinished()async save callback to display a success message (with saved file path) or a failure message, matching the existing pattern inmainwindow.cpp. Added#include <DMessageManager>to the includes. No existing logic was modified — this is a purely additive change.Change Safety Assessment
Code Safety
36132f3("fix: move the scanner and camera work off the UI thread") which introduced the asyncQFutureWatcher+ lambda callback pattern. This fix adds notification calls within that lambda callback without changing the async flow.Business Impact Scope
Affects the scan completion notification flow for all scanner types (document scanners, high-speed cameras). Users will now see a toast message when a scan completes successfully (with the saved file path) or fails to save. No other functional modules are affected.
Verification Suggestion
Test scan completion with various scanner devices (high-speed camera, document scanner) and file formats (PNG/JPEG/PDF/OFD). Verify the success toast displays the saved file path, and the failure toast appears when save fails. Test consecutive scans to ensure each shows a notification.
根因分析
扫描完成后,
ScanWidget::onScanFinished()仅通过qCDebug/qCWarning输出调试日志,并将文件路径写入m_historyEdit(该控件在第 178 行被hide()隐藏)。扫描完成后无任何用户可见通知。根因为扫描完成回调中缺少 UI 反馈机制。关键证据:src/ui/scanwidget.cpp:625-636— 仅有调试日志和隐藏文本控件更新;src/ui/scanwidget.cpp:178—m_historyEdit被隐藏;src/mainwindow.cpp:80,205— 项目已有DMessageManager使用先例。修复方案
在
onScanFinished()异步保存回调中添加DMessageManager::sendMessage()调用,显示成功消息(含保存文件路径)或失败消息,与mainwindow.cpp中现有模式一致。添加了#include <DMessageManager>头文件。未修改任何现有逻辑,纯属增量改动。改动安全评估
代码安全评估
36132f3("fix: move the scanner and camera work off the UI thread")修改,引入了异步QFutureWatcher+ lambda 回调模式。本次修复在该 lambda 回调中添加通知调用,不改变异步流程。业务影响范围
影响所有扫描设备类型(高拍仪、扫描仪)的扫描完成通知流程。用户将在扫描成功完成时看到提示消息(含保存文件路径),保存失败时看到失败提示。不影响其他功能模块。
验证建议
测试不同扫描设备(高拍仪、扫描仪)和文件格式(PNG/JPEG/PDF/OFD)的扫描完成流程。验证成功提示显示保存文件路径,失败时显示失败提示。测试连续多次扫描确保每次均显示通知。
Summary by Sourcery
Provide localized success and failure notifications for completed scans.
New Features:
Bug Fixes:
Chores: