fix: keep default generic name for launcher search functionality - #1717
fix: keep default generic name for launcher search functionality#1717wjyrich wants to merge 1 commit into
Conversation
The AMAppItem previously used localized generic names when setting the generic name for application items, which broke the launchpad's English search functionality. The issue was that localized generic names (e.g., Chinese) were stored as the generic name, preventing English text searches from matching applications. The fix separates the handling of generic names: the default (non- localized) generic name is now preserved for the generic name role to maintain search functionality, while localized names continue to be used for the display app name. This ensures both search and display requirements are satisfied independently. Changes: 1. Preserve the default generic name for GenericNameRole to maintain launchpad English search compatibility 2. Continue using the localized generic name for deepin vendor app display names 3. Refactor name map extraction to avoid redundant locale processing 4. Update both constructor and property change handler consistently Log: Fixed launchpad search by preserving default generic names Influence: 1. Verify launchpad can search applications by English generic name 2. Test localized display names for deepin vendor applications 3. Verify application name and generic name display in launcher 4. Test property change updates for application name fields fix: 修复启动器搜索功能保留默认通用名称 AMAppItem 之前在使用本地化通用名称设置应用项目时,破坏了启动器的英文搜索 功能。问题在于本地化通用名称(如中文)被存储为通用名称,导致英文文本搜索 无法匹配到应用。 此修复将通用名称的处理分离:保留默认(非本地化)通用名称用于通用名称角色 以维持搜索功能,同时继续使用本地化名称作为显示名称。这可确保搜索和显示需 求能够独立满足。 变更内容: 1. 保留默认通用名称用于 GenericNameRole,以维持启动器英文搜索兼容性 2. 继续使用本地化通用名称作为 deepin 厂商应用的显示名称 3. 重构名称映射提取,避免重复的本地化处理 4. 构造函数和属性变更处理程序保持一致的更新逻辑 Log: 修复启动器搜索功能,保留默认通用名称 Influence: 1. 验证启动器可以通过英文通用名称搜索应用 2. 测试 deepin 厂商应用的本地化显示名称 3. 验证应用名称和通用名称在启动器中的显示 4. 测试应用名称字段的属性变更更新 PMS: BUG-375179
|
[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 GuideUpdates AMAppItem to keep the default, non-localized generic name for launcher search while independently using localized names for display, with consistent behavior during initialization and property changes. Sequence diagram for localized app names and English searchsequenceDiagram
participant Application
participant AMAppItem
participant Launcher
Application->>AMAppItem: construct from appInfo
AMAppItem->>AMAppItem: getLocaleOrDefaultValue(Name, locale, DEFAULT_KEY)
AMAppItem->>AMAppItem: getLocaleOrDefaultValue(GenericName, locale, DEFAULT_KEY)
AMAppItem->>AMAppItem: AppItem::setGenericName(genericNameMap.value(DEFAULT_KEY))
alt deepin vendor with localized generic name
AMAppItem->>AMAppItem: AppItem::setAppName(localizedGenericName)
else other application
AMAppItem->>AMAppItem: AppItem::setAppName(localizedName)
end
Launcher->>AMAppItem: search by English generic name
AMAppItem-->>Launcher: match using default generic name
Sequence diagram for application name property updatessequenceDiagram
participant Application
participant AMAppItem
participant Launcher
Application->>AMAppItem: onPropertyChanged(Name, GenericName, X_Deepin_Vendor)
AMAppItem->>AMAppItem: getLocaleOrDefaultValue(nameMap, locale, DEFAULT_KEY)
AMAppItem->>AMAppItem: getLocaleOrDefaultValue(genericNameMap, locale, DEFAULT_KEY)
AMAppItem->>AMAppItem: AppItem::setGenericName(genericNameMap.value(DEFAULT_KEY))
AMAppItem->>AMAppItem: AppItem::setAppName(localizedGenericName or localizedName)
AMAppItem-->>Launcher: updated search and display names
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
deepin pr auto review🤖 AI 代码审查报告📊 总体评价
🔍 详细分析1. 语法逻辑 ✅评价: 优秀 ✅ 通过 潜在问题: 建议: 代码语法正确,逻辑清晰。构造函数和 onPropertyChanged 方法中均正确实现了默认通用名称与本地化名称的分离处理。边界条件处理完善:当 DEFAULT_KEY 不存在于 genericNameMap 中时,QMap::value() 返回空字符串,属于预期行为。建议保持当前实现。 2. 代码质量 ✅评价: 优秀 ✅ 通过 潜在问题:
建议: 代码结构清晰,注释完整。两处修改(构造函数和 onPropertyChanged)均添加了注释说明修改原因。变量命名规范且具有描述性(nameMap、genericNameMap、localizedName、localizedGenericName)。重构合理地提取了名称映射变量,避免了重复的 qdbus_cast 调用。建议在 genericNameMap.value(DEFAULT_KEY) 处补充说明 DEFAULT_KEY 不存在时的预期行为。 3. 代码性能 ✅评价: 优秀 ✅ 通过 潜在问题: 建议: 性能良好,资源使用合理。重构后提取 nameMap 和 genericNameMap 为局部变量并复用,避免了在构造函数中重复调用 qdbus_cast。QMap 使用隐式共享(COW),拷贝开销极小。无性能瓶颈。 4. 代码安全 🔒评价: 优秀 ✅ 通过
安全漏洞详情: 建议: 存在0个安全漏洞。代码处理来自 D-Bus 的应用管理器数据(org.desktopspec.ApplicationManager1),属于可信系统服务。无 SQL 注入、命令注入或路径遍历风险。无硬编码密钥或敏感信息泄露。Qt 字符串处理内存安全。 💡 改进建议代码示例// 建议在第49行附近补充边界情况说明:
// Keep the default generic name for launchpad's English search while NameRole remains localized.
// Note: If DEFAULT_KEY is not present in the map, an empty string is returned,
// which is acceptable - the app simply won't match by generic name in search.
AppItem::setGenericName(genericNameMap.value(DEFAULT_KEY));本报告由 AI 代码审查工具自动生成 |
The AMAppItem previously used localized generic names when setting the generic
name for application items, which broke the launchpad's English search functionality. The issue was that localized generic names (e.g., Chinese) were
stored as the generic name, preventing English text searches from matching
applications.
The fix separates the handling of generic names: the default (non- localized)
generic name is now preserved for the generic name role to maintain search
functionality, while localized names continue to be used for the display app
name. This ensures both search and display requirements are satisfied independently.
Changes:
English search compatibility
Log: Fixed launchpad search by preserving default generic names
Influence:
fix: 修复启动器搜索功能保留默认通用名称
AMAppItem 之前在使用本地化通用名称设置应用项目时,破坏了启动器的英文搜索
功能。问题在于本地化通用名称(如中文)被存储为通用名称,导致英文文本搜索
无法匹配到应用。
此修复将通用名称的处理分离:保留默认(非本地化)通用名称用于通用名称角色
以维持搜索功能,同时继续使用本地化名称作为显示名称。这可确保搜索和显示需
求能够独立满足。
变更内容:
Log: 修复启动器搜索功能,保留默认通用名称
Influence:
PMS: BUG-375179
Summary by Sourcery
Preserve default generic names for launcher search while continuing to show localized application names.
Bug Fixes:
Enhancements: