Conversation
1. Instantiate TrashMonitor in AppsModel constructor and connect its trashAttributeChanged() signal to a new onTrashAttributeChanged() slot 2. In data() IconNameRole branch, return user-trash-full or user-trash based on trashItemCount() when desktopId is dde-trash.desktop 3. Emit dataChanged for the trash row on attribute change so QML refreshes the icon immediately Log: Integrate the existing TrashMonitor into AppsModel so the trash icon dynamically switches between user-trash and user-trash-full based on item count. PMS: BUG-285725 Influence: Trash icon in launcher now reflects actual trash state.
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: mhduiy 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 GuideAppsModel now owns and observes TrashMonitor, dynamically returns the appropriate empty/full trash icon, and notifies QML to refresh the trash row when the monitored trash state changes. Sequence diagram for dynamic trash icon updatessequenceDiagram
participant TrashMonitor
participant AppsModel
participant QML
TrashMonitor-->>AppsModel: trashAttributeChanged()
AppsModel->>AppsModel: onTrashAttributeChanged()
AppsModel-->>QML: dataChanged(trashIndex, IconNameRole)
QML->>AppsModel: data(index, IconNameRole)
AppsModel->>TrashMonitor: trashItemCount()
TrashMonitor-->>AppsModel: item count
AppsModel-->>QML: user-trash or user-trash-full
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
deepin pr auto review🤖 AI 代码审查报告📊 总体评价
🔍 详细分析1. 语法逻辑 ✓(25/25 分)评价: 语法正确,逻辑清晰 ✓ 潜在问题: 分析说明:
建议: 无 2. 代码质量 ✓(24/25 分)评价: 代码结构清晰,注释完整 ✓ 潜在问题:
分析说明:
建议:
// 在 appsmodel.h 中添加
static constexpr auto kTrashDesktopId = "dde-trash.desktop";3. 代码性能 ✓(18/20 分)评价: 性能良好,资源使用合理 ✓ 潜在问题:
分析说明:
建议:
// 在 TrashMonitor 中缓存 trash item count
// int m_trashItemCount = 0;
// 在 onTrashMonitorChanged() 中更新缓存值
// 在 data() 中读取缓存值而非同步查询4. 代码安全 ✓(30/30 分)评价: 存在0个安全漏洞 ✓
安全漏洞详情: 漏洞对比统计:新增漏洞 0 个,减少漏洞 0 个,持平 0 个 分析说明:
建议: 无 📋 OCR 审查结果
💡 改进建议代码示例// 建议优化:缓存 trashItemCount 并使用常量
// appsmodel.h 中添加常量
private:
static constexpr auto kTrashDesktopId = "dde-trash.desktop";
// appsmodel.cpp 中 data() 修改
case AppsModel::IconNameRole: {
const QString desktopId = normalizedDesktopId(sourceData(sourceIndex, DesktopIdRoleName).toString());
if (desktopId == QLatin1String(kTrashDesktopId) && m_trashMonitor) {
// 使用缓存的 trashItemCount 而非每次同步查询
return m_trashMonitor->trashItemCount() > 0
? QStringLiteral("user-trash-full")
: QStringLiteral("user-trash");
}
// ...
}📝 审查结论本次 PR 修改了 代码实现与 PR 目的完全一致,逻辑清晰,无安全漏洞。仅有轻微的代码质量(魔法字符串不一致)和性能(同步 GIO 调用)改进建议,不影响代码的正确性和可用性。 总分:97 分 — 代码审查通过 本报告由 AI 代码审查工具自动生成 |
|
经讨论,文件管理器侧修复,实时更换图标来实现这个功能,我们无需修改 |
Root Cause Analysis
The
TrashMonitorclass in dde-launchpad implements trash state monitoring via GFileMonitor ontrash:///, providingtrashItemCount()and thetrashAttributeChanged()signal. However, it was never instantiated or connected inAppsModel. TheAppsModel::data()IconNameRole branch (appsmodel.cpp:177-181) directly passes through the staticIcon=user-trashfromdde-trash.desktop, with no dynamic switching logic. This causes the trash icon in the launcher's category view to always show a fixed style regardless of actual trash state.Fix
Integrated the existing
TrashMonitorintoAppsModel: instantiate it in the constructor and connect itstrashAttributeChanged()signal to a newonTrashAttributeChanged()slot. Indata()'s IconNameRole branch, returnuser-trash-full(whentrashItemCount() > 0) oruser-trashfordde-trash.desktop. The slot emitsdataChangedfor the trash row so QML refreshes the icon immediately. This matches the approach suggested by the development team (PMS history #9).Change Safety Assessment
Code Safety
b3d8fbd7), not a bug fix — this change does not revert any historical fix.dde-trash.desktopis added before the existing logic.Business Impact Scope
user-trash) and full (user-trash-full) based on actual trash item count. Other app icons are unaffected.Verification Suggestion
user-trashwhen the trash is empty anduser-trash-fullwhen files exist, and that it switches in real-time when adding/removing files while the launcher is open.根因分析
dde-launchpad 中
TrashMonitor类已实现回收站状态监听(通过 GFileMonitor 监听trash:///,提供trashItemCount()和trashAttributeChanged()信号),但在AppsModel中从未被实例化或连接。AppsModel::data()的 IconNameRole 分支(appsmodel.cpp:177-181)直接透传dde-trash.desktop中的静态Icon=user-trash,无动态切换逻辑,导致启动器分类视图中回收站图标始终显示固定样式,不随回收站实际状态变化。修复方案
在
AppsModel中集成已有的TrashMonitor:构造函数中实例化并连接trashAttributeChanged()信号到新增的onTrashAttributeChanged()槽;data()的 IconNameRole 分支中对dde-trash.desktop根据trashItemCount()返回user-trash-full(>0)或user-trash(=0);槽函数发射dataChanged通知 QML 即时刷新图标。符合开发团队在 PMS 历史记录 #9 中指明的技术方向。改动安全评估
代码安全评估
b3d8fbd7引入,非 bug 修复产物,本次改动不会撤销历史修复。dde-trash.desktop增加 early return。业务影响范围
user-trash)和有文件(user-trash-full)样式间动态切换。其他应用图标不受影响。验证建议
user-trash、有文件时显示为user-trash-full,且在启动器打开状态下放入/清空文件时图标能实时切换。Summary by Sourcery
Integrate trash monitoring into AppsModel so the launcher dynamically displays the empty or full trash icon.
Bug Fixes:
Enhancements: