Skip to content

fix: keep default generic name for launcher search functionality - #1717

Open
wjyrich wants to merge 1 commit into
linuxdeepin:masterfrom
wjyrich:fix-bug-375179
Open

fix: keep default generic name for launcher search functionality#1717
wjyrich wants to merge 1 commit into
linuxdeepin:masterfrom
wjyrich:fix-bug-375179

Conversation

@wjyrich

@wjyrich wjyrich commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

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

Summary by Sourcery

Preserve default generic names for launcher search while continuing to show localized application names.

Bug Fixes:

  • Preserve the default generic application name so launcher searches continue to match English generic names.
  • Keep localized generic names for deepin application display names while retaining localized regular names for other applications.

Enhancements:

  • Align initial application loading and property-change handling around shared localized and default name semantics.

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
@deepin-ci-robot

Copy link
Copy Markdown

[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.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@sourcery-ai

sourcery-ai Bot commented Aug 27, 2026

Copy link
Copy Markdown

Reviewer's Guide

Updates 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 search

sequenceDiagram
    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
Loading

Sequence diagram for application name property updates

sequenceDiagram
    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
Loading

File-Level Changes

Change Details Files
Preserve the unlocalized default generic name for launcher search while retaining localized names for application display.
  • Extract Name and GenericName maps once and derive localized display values from them.
  • Store the default GenericName map entry in GenericNameRole.
  • Use localized GenericName for deepin vendor app names, otherwise use localized Name.
applets/dde-apps/amappitem.cpp
Apply the same default-versus-localized name handling when application properties change.
  • Reuse existing maps when a property is unchanged and recalculate localized display values.
  • Keep GenericNameRole synchronized with the default generic name during updates.
  • Update vendor-specific display-name selection consistently with construction.
applets/dde-apps/amappitem.cpp

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

🤖 AI 代码审查报告

总体评分: 99 分 (通过阈值: 70分)

Pass


📊 总体评价

项目 结果
审查结论 代码审查通过
评分详情 总体评分 99 分,大于 70 分通过阈值,代码质量优秀。本次修改正确修复了启动器英文搜索功能的 bug,将默认(非本地化)通用名称用于 GenericNameRole 以维持搜索功能,同时保留本地化名称用于显示。代码结构清晰,注释完整,无安全漏洞。

🔍 详细分析

1. 语法逻辑 ✅

评价: 优秀 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: 代码语法正确,逻辑清晰。构造函数和 onPropertyChanged 方法中均正确实现了默认通用名称与本地化名称的分离处理。边界条件处理完善:当 DEFAULT_KEY 不存在于 genericNameMap 中时,QMap::value() 返回空字符串,属于预期行为。建议保持当前实现。


2. 代码质量 ✅

评价: 优秀 ✅ 通过

潜在问题:

  1. applets/dde-apps/amappitem.cpp:49 - genericNameMap.value(DEFAULT_KEY) 在 DEFAULT_KEY 不存在时返回空字符串,建议增加注释说明此边界情况的设计意图,便于后续维护者理解

建议: 代码结构清晰,注释完整。两处修改(构造函数和 onPropertyChanged)均添加了注释说明修改原因。变量命名规范且具有描述性(nameMap、genericNameMap、localizedName、localizedGenericName)。重构合理地提取了名称映射变量,避免了重复的 qdbus_cast 调用。建议在 genericNameMap.value(DEFAULT_KEY) 处补充说明 DEFAULT_KEY 不存在时的预期行为。


3. 代码性能 ✅

评价: 优秀 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: 性能良好,资源使用合理。重构后提取 nameMap 和 genericNameMap 为局部变量并复用,避免了在构造函数中重复调用 qdbus_cast。QMap 使用隐式共享(COW),拷贝开销极小。无性能瓶颈。


4. 代码安全 🔒

评价: 优秀 ✅ 通过

🔐 发现 0 个安全漏洞

安全漏洞详情:
✅ 未发现安全漏洞

建议: 存在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 代码审查工具自动生成

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants