fix: optimize app properties and trash monitoring - #1690
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: wjyrich 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 GuideRefactors application manager integration to perform targeted AMAppItem property updates, enrich AppItem metadata, introduce a GIO-based TrashMonitor for dynamic trash icon state, extend AppsApplet with app management APIs, fix AMAppItemModel initialization/ready signaling (including trash icon updates and deduplication), and propagate app model data changes into the dock's global element model. Sequence diagram for AMAppItem targeted property updatessequenceDiagram
participant AM_Application as ApplicationManager_Application
participant DBus as DBus
participant AMAppItem as AMAppItem
participant AppItem as AppItem
participant AppItemModel as AppItemModel
AM_Application->>DBus: PropertiesChanged
DBus->>AMAppItem: onPropertyChanged(QDBusMessage)
AMAppItem->>AMAppItem: qdbus_cast QVariantMap changedProperties
alt [Name/GenericName/X_Deepin_Vendor changed]
AMAppItem->>AppItem: setGenericName()
AMAppItem->>AppItem: setVendor()
AMAppItem->>AppItem: setAppName()
end
alt [Icons changed]
AMAppItem->>AppItem: setAppIconName()
end
alt [Categories changed]
AMAppItem->>AppItem: setDDECategories()
AMAppItem->>AppItem: setCategories()
end
alt [Actions or ActionName changed]
AMAppItem->>AMAppItem: updateActions()
AMAppItem->>AppItem: setActions()
end
AppItem-->>AppItemModel: dataChanged(...) emits
Sequence diagram for TrashMonitor-driven trash icon updatessequenceDiagram
participant FS as GIO_trash
participant GIO as GFileMonitor
participant TrashMonitor as TrashMonitor
participant AMAppItemModel as AMAppItemModel
participant TrashItem as AMAppItem_dde_trash
FS-->>GIO: file event
GIO->>TrashMonitor: onTrashChanged(...)
TrashMonitor->>TrashMonitor: updateState()
TrashMonitor-->>AMAppItemModel: emptyChanged(bool)
AMAppItemModel->>AMAppItemModel: updateTrashIcon()
AMAppItemModel->>TrashItem: setAppIconName(user-trash | user-trash-full)
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
/test github-pr-review-ci |
1. Refactor AMAppItem property change handling to process only changed properties instead of re-fetching all data 2. Add vendor and genericName properties to AppItem model for better app information display 3. Add TrashMonitor class using GIO to dynamically update trash icon state 4. Add comprehensive app management methods to AppsApplet (launch, autostart, scale, desktop operations) 5. Fix AMAppItemModel initialization to prevent duplicate app entries and properly emit ready state 6. Improve dock global element model to forward data changes from source apps model Log: Enhanced application properties handling with targeted updates, dynamic trash icon updates, and new applet management APIs Influence: 1. Test app icon updates when application metadata changes via D-Bus 2. Verify trash icon changes when files are added/removed from trash 3. Test launchApp with and without activation token 4. Verify sendToDesktop and removeFromDesktop operations work correctly 5. Test disableScale behavior with various environment configurations 6. Verify autoStart property updates correctly persist 7. Test dock app icon updates when app properties change 8. Verify no duplicate app entries appear under various load scenarios fix: 优化应用程序属性和回收站监控 1. 重构 AMAppItem 属性变更处理,仅处理变更的属性而不是重新获取全部数据 2. 为 AppItem 模型添加厂商和通用名称属性,优化应用信息显示 3. 添加使用 GIO 的 TrashMonitor 类,动态更新回收站图标状态 4. 为 AppsApplet 添加全面的应用管理方法(启动、自启动、缩放、桌面操作) 5. 修复 AMAppItemModel 初始化逻辑,防止重复应用条目并正确发出就绪状态 6. 改进 dock 全局元素模型,正确转发源应用模型的数据变更 Log: 增强应用属性处理机制,支持定向更新,增加回收站图标动态更新和应用管 理 API Influence: 1. 测试通过 D-Bus 修改应用元数据时图标是否及时更新 2. 验证向回收站添加/删除文件时图标是否自动切换 3. 测试带激活令牌和不带激活令牌时的应用启动功能 4. 验证发送到桌面和从桌面移除操作是否正常 5. 测试各种环境配置下禁用缩放功能的行为 6. 验证自启动属性修改后是否正确持久化 7. 测试应用属性变更时 dock 图标是否同步更新 8. 验证各种加载场景下不会出现重复应用条目 PMS: TASK-393709
deepin pr auto review★ 总体评分:89分■ 【总体评价】
■ 【详细分析】
■ 【改进建议代码示例】 // applets/dde-apps/amappitem.h 增加成员变量缓存
// ...
private:
QString m_cachedName;
QString m_cachedGenericName;
QString m_cachedVendor;
// ...
// applets/dde-apps/amappitem.cpp 构造函数中初始化缓存
AMAppItem::AMAppItem(const QDBusObjectPath &path, const ObjectInterfaceMap &source, QObject *parent)
: Application(AM_DBUS_SERVICE, path.path(), QDBusConnection::sessionBus(), parent)
, AppItem(DUtil::unescapeFromObjectPath(path.path().split('/').last()), AppItemModel::AppItemType)
{
// ... 原有初始化代码 ...
m_cachedName = name;
m_cachedGenericName = genericName;
m_cachedVendor = xDeepinVendor;
// ...
}
// applets/dde-apps/amappitem.cpp onPropertyChanged中消除同步调用
void AMAppItem::onPropertyChanged(const QDBusMessage &msg)
{
const QList<QVariant> arguments = msg.arguments();
if (arguments.count() != 3)
return;
if (arguments.at(0).toString() != AM_APPLICATION_INTERFACE)
return;
QVariantMap changedProperties = qdbus_cast<QVariantMap>(arguments.at(1));
const auto value = [&changedProperties](QLatin1StringView name) {
return changedProperties.value(name);
};
const auto contains = [&changedProperties](QLatin1StringView name) {
return changedProperties.contains(name);
};
if (contains(QLatin1String("Name")) || contains(QLatin1String("GenericName"))
|| contains(QLatin1String("X_Deepin_Vendor"))) {
if (contains(QLatin1String("Name")))
m_cachedName = getLocaleOrDefaultValue(qdbus_cast<QStringMap>(value(QLatin1String("Name"))), locale, DEFAULT_KEY);
if (contains(QLatin1String("GenericName")))
m_cachedGenericName = getLocaleOrDefaultValue(qdbus_cast<QStringMap>(value(QLatin1String("GenericName"))), locale, DEFAULT_KEY);
if (contains(QLatin1String("X_Deepin_Vendor")))
m_cachedVendor = value(QLatin1String("X_Deepin_Vendor")).toString();
AppItem::setGenericName(m_cachedGenericName);
AppItem::setVendor(m_cachedVendor);
AppItem::setAppName(m_cachedVendor == QLatin1String("deepin") && !m_cachedGenericName.isEmpty() ? m_cachedGenericName : m_cachedName);
}
// ... 其他属性按需更新,同样避免使用基类的同步获取方法 ...
} |
|
|
||
| auto reply = item->SendToDesktop(); | ||
| auto *watcher = new QDBusPendingCallWatcher(reply, this); | ||
| connect(watcher, &QDBusPendingCallWatcher::finished, this, [this, watcher, desktopId]() { |
| return item; | ||
| } | ||
|
|
||
| bool AppsApplet::launchApp(const QString &desktopId, const QString &activationToken) |
There was a problem hiding this comment.
这种启动应用,跟其它的am封装的接口不太一样吧,它也放在appsApplet进行提供么,
| bool appModelReady() const; | ||
| QVariantMap ddeCategories() const; | ||
|
|
||
| Q_INVOKABLE bool launchApp(const QString &desktopId, const QString &activationToken = {}); |
There was a problem hiding this comment.
这些Q_INVOKABLE的接口看能不能删掉,这里只保留一些只读的属性,尽量不提供操作接口,担心后续维护问题,
|
|
||
| namespace apps | ||
| { | ||
| TrashMonitor::TrashMonitor(QObject *parent) |
There was a problem hiding this comment.
这次先不加这个吧,分个提交,这种实现感觉有点儿怪,看之后怎么处理吧,
Log: Enhanced application properties handling with targeted updates, dynamic trash icon updates, and new applet management APIs
Influence:
fix: 优化应用程序属性和回收站监控
Log: 增强应用属性处理机制,支持定向更新,增加回收站图标动态更新和应用管
理 API
Influence:
PMS: TASK-393709
Summary by Sourcery
Refine application metadata handling and expose new applet APIs while integrating trash state monitoring and improving dock synchronization.
New Features:
Bug Fixes:
Enhancements: