Skip to content

Conversation

@electricface
Copy link
Member

@electricface electricface commented Feb 6, 2026

  • Also fixed the same issue with sort mode menu, category jump menu,
    and search box text size

fix: 应用右键菜单字体没有随着字体大小调整而立即改变

  • 同时也修复了排序模式菜单、分类跳转菜单,搜索框文字大小的相同问题

Log: 修复启动器应用右键菜单字体没有谁字体大小调整而立即改变问题
Influence: 启动器菜单文字大小
PMS: BUG-335169

Summary by Sourcery

Ensure launcher menus and search box text respond immediately to global font size changes across the windowed interface.

Bug Fixes:

  • Fix application context menu text not updating when the global font size is adjusted.
  • Fix sort mode menu and category jump menu text not reflecting font size changes until now.
  • Fix search box text size not following the configured font size in the windowed view.

font size adjustment

- Also fixed the same issue with sort mode menu, category jump menu,
and search box text size

---

fix: 应用右键菜单字体没有随着字体大小调整而立即改变

- 同时也修复了排序模式菜单、分类跳转菜单,搜索框文字大小的相同问题

Log: 修复启动器应用右键菜单字体没有谁字体大小调整而立即改变问题
Influence: 启动器菜单文字大小
PMS: BUG-335169
@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: electricface

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
Copy link

sourcery-ai bot commented Feb 6, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Binds various launcher menus and the search box to the shared DTK font manager so their text size updates immediately when the global font size changes.

Sequence diagram for launcher font size change propagation

sequenceDiagram
    actor User
    participant SettingsApp
    participant DTK_fontManager
    participant AppItemMenus
    participant CategoryMenus
    participant SearchBox

    User->>SettingsApp: changeFontSize(newSize)
    SettingsApp->>DTK_fontManager: setFontSize(newSize)
    DTK_fontManager-->>DTK_fontManager: update_t6_font
    DTK_fontManager-->>AppItemMenus: notify_font_changed(t6)
    DTK_fontManager-->>CategoryMenus: notify_font_changed(t6)
    DTK_fontManager-->>SearchBox: notify_font_changed(t6)

    AppItemMenus-->>AppItemMenus: font bound to DTK_fontManager.t6
    CategoryMenus-->>CategoryMenus: font bound to DTK_fontManager.t6
    SearchBox-->>SearchBox: font bound to DTK_fontManager.t6

    AppItemMenus-->>User: menu text size updated
    CategoryMenus-->>User: sort and category menu text size updated
    SearchBox-->>User: search text size updated immediately
Loading

Flow diagram for DTK font manager bindings in launcher components

flowchart LR
    DTK_fontManager_t6[DTK_fontManager.t6]

    DTK_fontManager_t6 --> AppItemMenu_font
    DTK_fontManager_t6 --> DummyAppItemMenu_font
    DTK_fontManager_t6 --> CategoryMenu_font
    DTK_fontManager_t6 --> CategoryMenu_label_font
    DTK_fontManager_t6 --> SearchBox_font

    AppItemMenu_font[AppItemMenu D.Menu font]
    DummyAppItemMenu_font[DummyAppItemMenu D.Menu font]
    CategoryMenu_font[SideBar categorizedMenu font]
    CategoryMenu_label_font[AppListView category label font]
    SearchBox_font[BottomBar searchEdit font]
Loading

File-Level Changes

Change Details Files
Bind category jump menu and its label text to the shared DTK font so they follow global font size changes.
  • Assign DTK.fontManager.t6 to the category menu popup font property.
  • Bind the internal Text element’s font to the menu’s font to keep label styling consistent.
qml/windowed/AppListView.qml
Bind all app context menus (including dummy menu) to the shared DTK font manager.
  • Set the font of the dummy app item context menu’s D.Menu to DTK.fontManager.t6 so its items resize with the global font.
  • Set the font of the main app item context menu’s D.Menu to DTK.fontManager.t6 to ensure consistent font size updates.
qml/DummyAppItemMenu.qml
qml/AppItemMenu.qml
Bind the search box text font to the shared DTK font manager so it scales with the global font size.
  • Set the search edit field font to DTK.fontManager.t6 so its text reacts immediately to font size changes.
qml/windowed/BottomBar.qml
Bind sidebar sort mode menu to the shared DTK font manager.
  • Set the sidebar categorizedMenu font to D.DTK.fontManager.t6 so its menu items follow global font size.
qml/windowed/SideBar.qml

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

@deepin-ci-robot
Copy link

deepin pr auto review

这段代码的 diff 显示了对 QML 文件中多个组件(菜单、搜索框等)添加了统一的字体设置 DTK.fontManager.t6。以下是对这段代码的详细审查意见:

1. 语法逻辑

  • 现状:代码逻辑正确,符合 QML 语法规范。在 MenuTextField 等控件上直接设置 font 属性是合法的。
  • 潜在问题:在 AppListView.qml 中,代码不仅给 ddeCategoryMenu 设置了 font: DTK.fontManager.t6,还在内部的 Text 组件中显式绑定了 font: ddeCategoryMenu.font
    • 分析:这种做法是多余的。通常 Menu 控件会自动将其 font 属性传播给内部的 MenuItemText 内容。显式绑定虽然不会报错,但增加了代码的冗余度。如果 Menu 控件本身支持字体继承,建议移除 Text 中的显式绑定,依赖控件的默认继承行为。

2. 代码质量

  • 现状:代码风格基本统一,缩进和格式符合规范。
  • 改进建议
    • 硬编码字体:直接在多个文件中散落地使用 DTK.fontManager.t6 属于"硬编码"(Hard Coding)。如果将来需要全局调整字体大小或样式,或者需要根据不同屏幕密度(DPI)动态调整字体,需要修改多处代码。
    • 建议:建议在项目的公共样式文件或全局配置中定义一个通用的菜单/控件字体属性,例如 AppStyle.menuFontAppStyle.defaultFont。各个组件引用这个统一定义,便于后续维护和统一修改。

3. 代码性能

  • 现状:设置 font 属性本身对性能影响极小,通常只在组件初始化时计算一次。
  • 改进建议
    • 绑定开销:在 AppListView.qml 中,font: ddeCategoryMenu.font 创建了一个属性绑定。虽然开销不大,但在列表视图(ListView/Repeater)中,如果菜单频繁打开或创建,过多的绑定会略微增加内存和 CPU 开销。如前所述,如果控件支持继承,应移除此绑定。

4. 代码安全

  • 现状:代码本身没有明显的安全漏洞。
  • 注意点
    • 依赖检查:代码强依赖 DTK (Deepin Tool Kit) 的 fontManager。如果 DTK 版本更新导致 fontManager 接口变动(例如 t6 被重命名或移除),这些界面将无法正确显示字体或报错。
    • 建议:确保项目对 DTK 的版本有明确的依赖限制,或者在引用前增加必要的类型检查或容错处理(尽管在 QML 中处理这种库级别的依赖比较困难,通常通过构建系统控制版本)。

总结与修改建议

这段代码的主要目的是统一 UI 字体风格,功能上没有问题。为了提高代码的可维护性和健壮性,建议进行以下优化:

  1. 消除冗余绑定
    qml/windowed/AppListView.qml 中,尝试移除 Text 组件中的 font: ddeCategoryMenu.font,观察菜单项字体是否依然正确继承。如果正确继承,则删除该行。

  2. 统一定义字体
    创建或利用现有的全局样式单例(假设为 AppStyle):

    // AppStyle.qml (伪代码)
    pragma Singleton
    QtObject {
        property font menuFont: DTK.fontManager.t6
        // ...
    }

    然后在各个文件中引用:

    // 替换 font: DTK.fontManager.t6
    font: AppStyle.menuFont
  3. 代码格式微调
    qml/windowed/BottomBar.qml 中,font: DTK.fontManager.t6 后面多了一个空行(+ 行之后),建议保持与其他文件一致的风格,除非是为了分隔逻辑块。

修改后的部分代码示例(针对 AppListView.qml):

--- a/qml/windowed/AppListView.qml
+++ b/qml/windowed/AppListView.qml
@@ -263,8 +263,7 @@ FocusScope {
         modal: true
         closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutsideParent
 
-        font: DTK.fontManager.t6
-
+        font: AppStyle.menuFont // 建议使用统一样式
         property var existingSections: []
         Repeater {
             model: ddeCategoryMenu.existingSections
@@ -279,7 +278,6 @@ FocusScope {
                     alignment: Qt.AlignCenter
                     text: menuItem.text
                     color: parent.palette.windowText
-                    font: ddeCategoryMenu.font
                 }
                 background: BoxPanel {
                     anchors.left: parent.left

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • There’s an inconsistency in how the font manager is referenced (DTK.fontManager.t6 vs D.DTK.fontManager.t6 in SideBar.qml); consider aligning on a single import/alias pattern to avoid confusion and future mistakes.
  • You’re now repeating font: DTK.fontManager.t6 across several components; consider introducing a shared style or wrapper component for menus/search inputs to centralize this binding and make future font changes easier.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- There’s an inconsistency in how the font manager is referenced (`DTK.fontManager.t6` vs `D.DTK.fontManager.t6` in `SideBar.qml`); consider aligning on a single import/alias pattern to avoid confusion and future mistakes.
- You’re now repeating `font: DTK.fontManager.t6` across several components; consider introducing a shared style or wrapper component for menus/search inputs to centralize this binding and make future font changes easier.

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.

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • In SideBar.qml you’re using D.DTK.fontManager.t6 while the other files use DTK.fontManager.t6; consider aligning the namespace usage to avoid subtle runtime binding issues.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In SideBar.qml you’re using `D.DTK.fontManager.t6` while the other files use `DTK.fontManager.t6`; consider aligning the namespace usage to avoid subtle runtime binding issues.

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.

Copy link
Member

@BLumia BLumia left a comment

Choose a reason for hiding this comment

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

这个是不是应该 dtkdeclarative 改更合理,按理说所有的 Menu/MenuItem 都应该有相同的行为?

cc @18202781743

@BLumia BLumia requested a review from 18202781743 February 6, 2026 05:49
id: categorizedCom
D.Menu {
id: categorizedMenu
font: D.DTK.fontManager.t6
Copy link
Contributor

Choose a reason for hiding this comment

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

感觉是启动器这个场景出了问题,像启动器的搜索框弹出的右键菜单也是错误的,但在控制中心就是对的,
启动器的窗口是个PopupWindow,像是没有继承Window的font变化,

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.

4 participants