Skip to content

feat: improve app list focus behavior and styling#659

Merged
deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
wjyrich:fix-bug-334167
Oct 14, 2025
Merged

feat: improve app list focus behavior and styling#659
deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
wjyrich:fix-bug-334167

Conversation

@wjyrich

@wjyrich wjyrich commented Oct 14, 2025

Copy link
Copy Markdown
Contributor
  1. Move Keys.onReturnPressed and Keys.onSpacePressed outside of the button delegate to fix scope issues
  2. Replace complex BoxPanel background with FocusBoxBorder for menu items, simplifying styling and improving focus visibility
  3. Add forceActiveFocus() call when list gains active focus to ensure proper focus management
  4. Change category type change behavior from positionViewAtBeginning to setting currentIndex to 0 for better navigation
  5. Simplify ItemBackground focus condition by removing focusPolicy check

feat: 改进应用列表焦点行为和样式

  1. 将 Keys.onReturnPressed 和 Keys.onSpacePressed 移出按钮委托以修复作用 域问题
  2. 使用 FocusBoxBorder 替换复杂的 BoxPanel 背景,简化样式并改进焦点可 见性
  3. 在列表获得活动焦点时添加 forceActiveFocus() 调用以确保正确的焦点管理
  4. 将类别类型更改行为从 positionViewAtBeginning 改为设置 currentIndex 为 0,改善导航体验
  5. 通过移除 focusPolicy 检查简化 ItemBackground 焦点条件

PMS: BUG-334167

Summary by Sourcery

Improve focus behavior and styling in the app list view by fixing key event scope, streamlining background styling, and enhancing focus navigation.

Bug Fixes:

  • Fix scope issues by moving onReturnPressed and onSpacePressed handlers outside the button delegate

Enhancements:

  • Replace complex BoxPanel background with FocusBoxBorder for menu items
  • Add forceActiveFocus call when the list gains active focus to ensure correct focus management
  • Change category type change behavior to resetting currentIndex to 0 for improved navigation
  • Simplify ItemBackground focus condition by removing the focusPolicy check

@wjyrich wjyrich requested review from 18202781743 and BLumia October 14, 2025 06:29
@sourcery-ai

sourcery-ai Bot commented Oct 14, 2025

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Reorganizes key event handlers and introduces simplified focus styling and management to improve focus behavior and navigation in the application list.

Sequence diagram for improved app launch key handling

sequenceDiagram
    participant User as actor User
    participant AppListView
    participant AppItem
    User->>AppListView: Presses Return or Space key
    AppListView->>AppItem: launchApp(desktopId)
Loading

Class diagram for updated menu item background styling

classDiagram
    class MenuItem {
        +text: string
        +palette: Palette
        +down: bool
        +hovered: bool
        +visualFocus: bool
    }
    class FocusBoxBorder {
        +color: Color
        +visible: bool
        +anchors: Anchors
        +margins: int
    }
    MenuItem "1" -- "1" FocusBoxBorder : background
    class BoxPanel {
        +outsideBorderColor: Color
        +insideBorderColor: Color
        +radius: int
        +background: Palette
        +color1: Color
        +color2: Color
    }
    %% BoxPanel removed as background for MenuItem
Loading

File-Level Changes

Change Details Files
Fix keyboard event handling for list items
  • Move Return key handler out of button delegate
  • Move Space key handler out of button delegate
qml/windowed/AppListView.qml
Simplify menu item background styling with FocusBoxBorder
  • Replace complex BoxPanel background with FocusBoxBorder
  • Adjust visibility condition to include visualFocus and hovered/down state
qml/windowed/AppListView.qml
Ensure proper focus management on list activation
  • Add forceActiveFocus() call when listView gains active focus
qml/windowed/AppListView.qml
Improve category navigation behavior
  • Change category type change handler to set currentIndex to 0 instead of positionViewAtBeginning
qml/windowed/AppListView.qml
Simplify ItemBackground focus condition
  • Remove focusPolicy check from focus activation condition
qml/windowed/ItemBackground.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

@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 there - I've reviewed your changes - here's some feedback:

  • Add a null check before calling currentItem.forceActiveFocus() to avoid runtime errors when the list is empty or no item is present.
  • Double-check the FocusBoxBorder anchors.margins change from 2px to 4px against the design spec to ensure the new styling aligns with overall UI layout.
  • Consider extracting the Keys.onReturnPressed and Keys.onSpacePressed handlers into a shared component or delegate helper to avoid duplication and keep keyboard behavior consistent.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Add a null check before calling currentItem.forceActiveFocus() to avoid runtime errors when the list is empty or no item is present.
- Double-check the FocusBoxBorder anchors.margins change from 2px to 4px against the design spec to ensure the new styling aligns with overall UI layout.
- Consider extracting the Keys.onReturnPressed and Keys.onSpacePressed handlers into a shared component or delegate helper to avoid duplication and keep keyboard behavior consistent.

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.

1. Move Keys.onReturnPressed and Keys.onSpacePressed outside of the
button delegate to fix scope issues
2. Replace complex BoxPanel background with FocusBoxBorder for menu
items, simplifying styling and improving focus visibility
3. Add forceActiveFocus() call when list gains active focus to ensure
proper focus management
4. Change category type change behavior from positionViewAtBeginning to
setting currentIndex to 0 for better navigation
5. Simplify ItemBackground focus condition by removing focusPolicy check

feat: 改进应用列表焦点行为和样式

1. 将 Keys.onReturnPressed 和 Keys.onSpacePressed 移出按钮委托以修复作用
域问题
2. 使用 FocusBoxBorder 替换复杂的 BoxPanel 背景,简化样式并改进焦点可
见性
3. 在列表获得活动焦点时添加 forceActiveFocus() 调用以确保正确的焦点管理
4. 将类别类型更改行为从 positionViewAtBeginning 改为设置 currentIndex 为
0,改善导航体验
5. 通过移除 focusPolicy 检查简化 ItemBackground 焦点条件

PMS: BUG-334167
@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

我对这个代码差异进行审查,发现了一些可以改进的地方:

  1. 代码结构和逻辑改进:
  • 在AppListView.qml中,Keys.onReturnPressed和Keys.onSpacePressed的处理被移到了ListView外部,这可能会导致事件处理不一致。建议保持这两个事件处理器在ListView内部,以确保它们能正确处理列表项的键盘事件。
  • 将menuItem.down || menuItem.hovered改为menuItem.highlighted是一个好的改进,因为highlighted属性更准确地表达了组件的高亮状态。
  1. 代码性能优化:
  • 在onActiveFocusChanged处理程序中,添加了currentItem的检查和forceActiveFocus()调用,这有助于确保焦点正确设置,但要注意避免不必要的焦点重设。
  • 将listView.positionViewAtBeginning()改为listView.currentIndex = 0是一个性能优化,因为currentIndex = 0的操作比positionViewAtBeginning()更轻量级。
  1. 代码安全改进:
  • 在ItemBackground.qml中,移除了control.focusPolicy的检查,这可能是一个潜在的问题。建议保留这个检查,以确保只有在控件确实需要焦点时才显示焦点边框,这样可以避免不必要的视觉元素渲染。
  1. 代码质量改进:
  • 建议在AppListView.qml中添加注释,解释为什么使用currentIndex = 0而不是positionViewAtBeginning(),以提高代码可读性。
  • 对于Keys事件处理器的重构,建议添加注释说明为什么将它们移到ListView外部,以及这种改变可能带来的影响。
  1. 其他建议:
  • 考虑添加边界检查,特别是在使用currentItem时,以防止可能的空引用异常。
  • 在修改事件处理逻辑时,建议进行充分的测试,确保键盘交互仍然按预期工作。

总体而言,这些修改大部分是积极的,特别是性能优化方面的改进。但需要注意事件处理逻辑的改变可能带来的影响,并确保相关功能仍然正常工作。

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: 18202781743, 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

@wjyrich

wjyrich commented Oct 14, 2025

Copy link
Copy Markdown
Contributor Author

/forcemerge

@deepin-bot

deepin-bot Bot commented Oct 14, 2025

Copy link
Copy Markdown

This pr force merged! (status: blocked)

@deepin-bot deepin-bot Bot merged commit b3b8ba0 into linuxdeepin:master Oct 14, 2025
7 of 9 checks passed
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.

3 participants