Skip to content

Conversation

@wjyrich
Copy link

@wjyrich wjyrich commented Sep 3, 2025

Fixed scrollbar visibility condition to properly handle AlwaysOn policy with hover/pressed states. The previous logic would show scrollbar in AlwaysOn mode even when hovered or pressed, which caused visual inconsistency. Now it only shows when not hovered and not pressed in AlwaysOn mode, while maintaining the original behavior for the moving condition.

修复滚动条可见性逻辑

修复滚动条可见性条件以正确处理 AlwaysOn 策略与悬停/按下状态。之前的逻辑
会在 AlwaysOn 模式下即使悬停或按下时也显示滚动条,这导致视觉不一致。现在
在 AlwaysOn 模式下仅在未悬停且未按下时显示,同时保持移动条件的原始行为。

Pms: BUG-332031

Summary by Sourcery

Adjust scrollbar visibility logic to properly handle the AlwaysOn policy by only showing the scrollbar when not hovered or pressed, while preserving the original moving behavior.

Bug Fixes:

  • Fix scrollbar AlwaysOn policy to hide the scrollbar when hovered or pressed
  • Preserve existing moving-based visibility for scrollbars under the size threshold

Fixed scrollbar visibility condition to properly handle AlwaysOn policy
with hover/pressed states. The previous logic would show scrollbar
in AlwaysOn mode even when hovered or pressed, which caused visual
inconsistency. Now it only shows when not hovered and not pressed in
AlwaysOn mode, while maintaining the original behavior for the moving
condition.

修复滚动条可见性逻辑

修复滚动条可见性条件以正确处理 AlwaysOn 策略与悬停/按下状态。之前的逻辑
会在 AlwaysOn 模式下即使悬停或按下时也显示滚动条,这导致视觉不一致。现在
在 AlwaysOn 模式下仅在未悬停且未按下时显示,同时保持移动条件的原始行为。

Pms: BUG-332031
@deepin-ci-robot
Copy link
Contributor

[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

@deepin-ci-robot
Copy link
Contributor

deepin pr auto review

我对这段代码的修改进行审查,主要关注语法逻辑、代码质量、性能和安全性:

  1. 语法逻辑:

    • 修改后的逻辑更加完整和严格,增加了对hovered和pressed状态的检查
    • 原代码中当policy为AlwaysOn时会无条件显示滚动条,修改后增加了对hovered和pressed状态的排除
    • moving状态的判断保持不变,仍然依赖于active、pressed和hovered状态
  2. 代码质量:

    • 修改后的逻辑更加清晰,明确排除了hovered和pressed状态
    • 使用括号明确优先级,提高了代码可读性
    • 保持了原有的命名风格和代码结构
  3. 性能影响:

    • 此修改对性能影响微乎其微,只是增加了一些简单的布尔判断
    • 这些属性(hovered、pressed)本来就是Qt框架内置的,访问成本低
  4. 安全性:

    • 此修改提高了组件的行为安全性,避免了在用户交互时意外显示滚动条
    • 通过排除hovered和pressed状态,确保了用户体验的一致性

改进建议:

  1. 考虑将这个复杂的条件提取为一个单独的函数或属性,以提高代码可读性:

    readonly property bool shouldShowScrollBar: 
        (control.policy === T.ScrollBar.AlwaysOn && !control.hovered && !control.pressed) || 
        (moving && control.size < 1.0)

    然后在when条件中使用shouldShowScrollBar

  2. 考虑添加注释解释这个条件的目的,特别是对于为什么要在AlwaysOn时排除hovered和pressed状态

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

@sourcery-ai
Copy link

sourcery-ai bot commented Sep 3, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Refined the AlwaysOn scrollbar visibility logic to hide the scrollbar when hovered or pressed while preserving the original moving and size-based display conditions.

Class diagram for updated ScrollBar state logic

classDiagram
class ScrollBar {
  +policy: Policy
  +active: bool
  +pressed: bool
  +hovered: bool
  +size: float
}
class State {
  +name: string
  +moving: bool
  +when: bool
}
ScrollBar "1" -- "*" State : has
State : when = (policy == AlwaysOn && !hovered && !pressed) || (moving && size < 1.0)
State : moving = active && !pressed && !hovered
Loading

State diagram for ScrollBar visibility logic

stateDiagram-v2
    [*] --> AlwaysOn
    AlwaysOn --> Visible : !hovered && !pressed
    AlwaysOn --> Hidden : hovered || pressed
    [*] --> Moving
    Moving --> Visible : active && !pressed && !hovered && size < 1.0
    Visible --> [*]
    Hidden --> [*]
Loading

File-Level Changes

Change Details Files
Refined scrollbar visibility condition
  • Added checks to hide scrollbar when hovered or pressed in AlwaysOn mode
  • Reformatted the when expression to group AlwaysOn and moving conditions
  • Ensured existing moving && size < 1.0 logic remains intact
qt6/src/qml/ScrollBar.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

@wjyrich wjyrich closed this Sep 3, 2025
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