Skip to content

Conversation

@18202781743
Copy link
Contributor

@18202781743 18202781743 commented Sep 2, 2025

Changed ArrowListView button behavior from click-based to hover-based
scrolling

  1. Replaced Button with ActionButton component for better hover handling
  2. Added timer-based auto-scrolling with initial 300ms delay and 100ms
    repeat interval
  3. Implemented state machine to manage hover detection and scroll
    execution
  4. Modified layout properties to use Layout.fillWidth for better button
    sizing
  5. Removed onClicked handler and replaced with unified performScroll
    function

feat: 将滚动触发方式从点击改为悬停

将 ArrowListView 按钮行为从基于点击改为基于悬停的滚动

  1. 将 Button 替换为 ActionButton 组件以更好地处理悬停
  2. 添加基于计时器的自动滚动,具有 300 毫秒初始延迟和 100 毫秒重复间隔
  3. 实现状态机来管理悬停检测和滚动执行
  4. 修改布局属性使用 Layout.fillWidth 以获得更好的按钮尺寸
  5. 移除 onClicked 处理程序并替换为统一的 performScroll 函数

PMS: BUG-314007 BUG-278225

Summary by Sourcery

Enable hover-based auto-scrolling for arrow buttons in ArrowListView and adjust their layout and logic accordingly.

New Features:

  • Add hover-triggered auto-scrolling for ArrowListView buttons with a 300ms initial delay and 100ms repeat interval.

Enhancements:

  • Replace QML Button with ActionButton to improve hover handling and consolidate scroll actions into a single performScroll function.
  • Implement a state-machine approach with properties and timers to manage hover detection and scrolling state.
  • Update ArrowListView button layout to use fillWidth for consistent sizing.

Changed ArrowListView button behavior from click-based to hover-based
scrolling
1. Replaced Button with ActionButton component for better hover handling
2. Added timer-based auto-scrolling with initial 300ms delay and 100ms
repeat interval
3. Implemented state machine to manage hover detection and scroll
execution
4. Modified layout properties to use Layout.fillWidth for better button
sizing
5. Removed onClicked handler and replaced with unified performScroll
function

feat: 将滚动触发方式从点击改为悬停

将 ArrowListView 按钮行为从基于点击改为基于悬停的滚动
1. 将 Button 替换为 ActionButton 组件以更好地处理悬停
2. 添加基于计时器的自动滚动,具有 300 毫秒初始延迟和 100 毫秒重复间隔
3. 实现状态机来管理悬停检测和滚动执行
4. 修改布局属性使用 Layout.fillWidth 以获得更好的按钮尺寸
5. 移除 onClicked 处理程序并替换为统一的 performScroll 函数

PMS: BUG-314007 BUG-278225
@18202781743 18202781743 requested review from BLumia and mhduiy September 2, 2025 12:06
deepin-ci-robot added a commit to linuxdeepin/dtk6declarative that referenced this pull request Sep 2, 2025
Synchronize source files from linuxdeepin/dtkdeclarative.

Source-pull-request: linuxdeepin/dtkdeclarative#524
@deepin-ci-robot
Copy link
Contributor

deepin pr auto review

代码审查报告

1. ArrowListView.qml 的修改

语法逻辑

  • Layout.preferredWidth: width 改为 Layout.fillWidth: true 是一个合理的改动,这会使按钮宽度填充可用空间,而不是固定为当前宽度。
  • 保持了其他属性不变,确保了布局的一致性。

代码质量

  • 修改是简洁且符合Qt布局系统最佳实践的。fillWidth 属性比 preferredWidth 更适合需要自适应宽度的场景。
  • 两个箭头按钮的修改保持了一致性,确保了UI的对称性。

代码性能

  • 此改动不会引入额外的性能开销,实际上可能略微提高性能,因为不再需要计算和保持固定的宽度值。

代码安全

  • 此改动不会引入新的安全问题,相反,使用 fillWidth 可以避免在某些情况下可能出现的布局溢出问题。

2. ArrowListViewButton.qml 的修改

语法逻辑

  • Button 替换为 ActionButton 是一个合理的选择,假设 ActionButton 是项目中自定义的按钮组件,提供了更多功能。
  • 添加了 palette.windowText: undefined 确保按钮文本颜色不受默认调色板影响。
  • 增加了自动滚动功能,通过两个计时器实现了悬停时的自动滚动,这是一个很好的用户体验改进。

代码质量

  • 代码结构清晰,使用了状态机的方法来管理自动滚动逻辑。
  • 添加了详细的注释,解释了自动滚动功能的实现原理。
  • 将原来的点击事件处理逻辑提取为 performScroll 函数,提高了代码的可重用性。

代码性能

  • 新增的自动滚动功能可能会引入轻微的性能开销,但影响很小,因为:
    • 只在按钮启用且悬停时才激活
    • 使用了合理的间隔时间(300ms初始延迟,100ms连续滚动)
    • 使用了高效的状态管理机制

代码安全

  • 新增的功能没有明显的安全问题:
    • 正确处理了按钮的启用/禁用状态
    • 在不需要自动滚动时正确重置状态
    • 使用了适当的间隔时间,避免过度频繁的操作

改进建议

  1. 性能优化建议

    • 考虑将 performScroll 函数移到组件外部或使用更高效的方式绑定,以减少每次调用时的函数查找开销。
    • 可以添加一个属性来配置自动滚动的速度,使其更具灵活性。
  2. 功能增强建议

    • 考虑添加滚动加速度,使得长时间悬停时滚动速度逐渐增加,提供更自然的滚动体验。
    • 可以添加一个属性来配置是否启用自动滚动功能,允许用户禁用此行为。
  3. 代码组织建议

    • 考虑将自动滚动相关的逻辑封装为一个单独的可重用组件,以便在其他需要类似功能的场景中复用。

总体而言,这些修改提高了组件的功能性和用户体验,同时保持了代码的清晰和可维护性。

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

  • Consider making the 300ms initial delay and 100ms repeat interval configurable properties or style constants instead of hardcoding them.
  • To avoid potential race conditions, explicitly stop both the initialDelayTimer and hoverScrollTimer in onShouldAutoScrollChanged when shouldAutoScroll becomes false.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider making the 300ms initial delay and 100ms repeat interval configurable properties or style constants instead of hardcoding them.
- To avoid potential race conditions, explicitly stop both the initialDelayTimer and hoverScrollTimer in onShouldAutoScrollChanged when shouldAutoScroll becomes false.

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.

@sourcery-ai
Copy link

sourcery-ai bot commented Sep 2, 2025

Reviewer's Guide

This PR transitions ArrowListView scrolling from click-triggered to hover-driven behavior by swapping to ActionButton, refactoring click logic into a unified performScroll function, introducing a timer–based auto-scroll state machine, and updating layout sizing to use fillWidth.

File-Level Changes

Change Details Files
Replaced Button with ActionButton for improved hover handling
  • Swapped sourceComponent to ActionButton
  • Adjusted palette.windowText for default styling
qt6/src/qml/private/ArrowListViewButton.qml
Unified click event into performScroll function
  • Removed onClicked handler
  • Added performScroll() to handle increment/decrement logic
qt6/src/qml/private/ArrowListViewButton.qml
Added timer-based auto-scroll state machine
  • Introduced shouldAutoScroll and delayCompleted properties
  • Configured initialDelayTimer (300 ms) and hoverScrollTimer (100 ms repeat)
  • Reset delayCompleted on hover exit
qt6/src/qml/private/ArrowListViewButton.qml
Updated layout sizing to use fillWidth
  • Replaced Layout.preferredWidth with Layout.fillWidth for both up/down buttons
qt6/src/qml/ArrowListView.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
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: 18202781743, BLumia, mhduiy

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

@18202781743 18202781743 merged commit c56e04e into linuxdeepin:master Sep 4, 2025
19 of 20 checks passed
18202781743 pushed a commit to linuxdeepin/dtk6declarative that referenced this pull request Sep 4, 2025
Synchronize source files from linuxdeepin/dtkdeclarative.

Source-pull-request: linuxdeepin/dtkdeclarative#524
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