Skip to content

fix(slider): adjust path calculation for handle alignment#617

Merged
deepin-bot[bot] merged 1 commit intolinuxdeepin:masterfrom
52cyb:master
May 8, 2026
Merged

fix(slider): adjust path calculation for handle alignment#617
deepin-bot[bot] merged 1 commit intolinuxdeepin:masterfrom
52cyb:master

Conversation

@52cyb
Copy link
Copy Markdown
Contributor

@52cyb 52cyb commented May 8, 2026

When handleType is NoHandleType, the x-coordinate calculation now calculates based on sliderGroove to correct the visual alignment of the slider path.

Log: adjust path calculation for handle alignment
PMS: BUG-358623
Influence: 检查输入设备的反馈音量显示是否正确,同时关注静音场景(PMS:350837)

Summary by Sourcery

Adjust slider path and pass region calculations to keep the filled track visually aligned when using a handle-less slider variant.

Bug Fixes:

  • Fix misaligned slider path rendering when the handle type is set to a handle-less (NoArrowType) configuration.

Enhancements:

  • Introduce a NoArrowType handle type to support sliders rendered without a visible handle while retaining correct positioning logic.

@deepin-ci-robot
Copy link
Copy Markdown
Contributor

Hi @52cyb. Thanks for your PR.

I'm waiting for a linuxdeepin member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented May 8, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Adjusts slider path and filled track calculations so that when the handle type is NoArrowType (no visible handle), the path endpoints and passItem width are aligned based on the groove dimensions and visualPosition instead of the (non‑existent) handle geometry.

Updated class diagram for Slider handleType and geometry calculation

classDiagram
    class Slider {
        bool horizontal
        HandleType handleType
        real visualPosition
        Handle handle
        Groove sliderGroove
        PassItem passItem
    }

    class HandleType {
        <<enumeration>>
        ArrowUp
        ArrowLeft
        ArrowBottom
        ArrowRight
        NoArrowType
    }

    class Handle {
        real x
        real y
        real width
        real height
    }

    class Groove {
        real width
        real height
    }

    class PassItem {
        real x
        real y
        real width
        real height
    }

    Slider --> HandleType : uses
    Slider *-- Handle : contains
    Slider *-- Groove : contains
    Slider *-- PassItem : contains
Loading

Flow diagram for slider path and passItem width calculation with NoArrowType

flowchart TD
    A[Start layout of slider path and passItem] --> B{horizontal?}

    B -->|yes| C{handleType is NoArrowType?}
    C -->|yes| D[PathLine.x = visualPosition * sliderGroove.width]
    C -->|no| E[PathLine.x = handle.x]

    D --> F[passItem.width = visualPosition * sliderGroove.width]
    E --> F[passItem.width = handle.x]

    B -->|no| G{handleType is NoArrowType?}
    G -->|yes| H[PathLine.y = visualPosition * sliderGroove.height]
    G -->|no| I[PathLine.y = handle.y + handle.height / 2]

    F --> J[PathLine.y = sliderGroove.height / 2 for horizontal]
    H --> K[passItem.width = DS_Style_slider_groove_height]
    I --> K

    J --> L[End layout]
    K --> L
Loading

File-Level Changes

Change Details Files
Introduce a NoArrowType handle type and special-case the slider path endpoint calculation to align to the groove when no handle is shown.
  • Extend the Slider.HandleType enum with a NoArrowType value used to indicate absence of a visible handle.
  • Update the PathLine x/y endpoint calculations to derive coordinates from visualPosition and sliderGroove size when handleType is NoArrowType, falling back to handle.x / handle.y for other handle types.
  • Adjust the passItem width calculation for horizontal sliders to use visualPosition * sliderGroove.width when handleType is NoArrowType, keeping the previous behavior for other handle types.
qt6/src/qml/Slider.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

Copy link
Copy Markdown

@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 found 2 issues, and left some high level feedback:

  • The new NoArrowType enum value is added to the ArrowType enumeration but used as Slider.HandleType.NoArrowType; please double‑check the enum/namespace consistency so that the type name and usage match and avoid confusion or runtime issues.
  • The repeated inline ternary checks on control.handleType === Slider.HandleType.NoArrowType for x, y, and passItem.width make the path geometry harder to read; consider extracting a small helper or intermediate properties (e.g., effectiveHandleX/Y) to centralize this logic and improve maintainability.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The new `NoArrowType` enum value is added to the `ArrowType` enumeration but used as `Slider.HandleType.NoArrowType`; please double‑check the enum/namespace consistency so that the type name and usage match and avoid confusion or runtime issues.
- The repeated inline ternary checks on `control.handleType === Slider.HandleType.NoArrowType` for `x`, `y`, and `passItem.width` make the path geometry harder to read; consider extracting a small helper or intermediate properties (e.g., `effectiveHandleX/Y`) to centralize this logic and improve maintainability.

## Individual Comments

### Comment 1
<location path="qt6/src/qml/Slider.qml" line_range="21" />
<code_context>
         ArrowBottom = 4,
-        ArrowRight = 5
+        ArrowRight = 5,
+        NoArrowType = 6
     }

</code_context>
<issue_to_address>
**issue (bug_risk):** Consider how the new `NoArrowType` integrates with any existing assumptions about handle types.

This new enum value breaks the prior invariant that all handle types are arrow-shaped, so any logic that assumes `handleType` always implies an arrow might now behave incorrectly. Please review callers that switch/branch on `handleType` to ensure `NoArrowType` is handled explicitly rather than falling into an unintended default/fallback path.
</issue_to_address>

### Comment 2
<location path="qt6/src/qml/Slider.qml" line_range="118-120" />
<code_context>
                         y: control.horizontal ? -DS.Style.slider.groove.height / 2 : control.handle.y + control.handle.height / 2
                         height: control.horizontal ? DS.Style.slider.groove.height : sliderGroove.height - control.handle.y - control.handle.height / 2
-                        width: control.horizontal ? control.handle.x : DS.Style.slider.groove.height
+                        width: control.horizontal ? (control.handleType === Slider.HandleType.NoArrowType 
+                                                    ? control.visualPosition * sliderGroove.width 
+                                                    : control.handle.x) : DS.Style.slider.groove.height
                     }

</code_context>
<issue_to_address>
**issue (bug_risk):** Vertical `passItem` still uses `handle.y` while the path now uses `visualPosition` for `NoArrowType`, which can desync the visual elements.

In the vertical case, `PathLine.y` now uses `visualPosition * sliderGroove.height` for `NoArrowType`, but `passItem.y` / `height` still use `control.handle.y` / `height`. If `NoArrowType` changes how `handle.y` is derived or leaves it meaningless, the passed region can drift from the knob position. Consider updating the vertical `passItem` bindings for `NoArrowType` to follow the same `visualPosition`-based logic as the path endpoint so all visuals stay aligned.
</issue_to_address>

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.

Comment thread qt6/src/qml/Slider.qml
Comment thread qt6/src/qml/Slider.qml
When handleType is NoHandleType, the x-coordinate calculation now calculates based on sliderGroove to correct the visual alignment of the slider path.

Log: adjust path calculation for handle alignment
PMS: BUG-358623
Influence: 检查输入设备的反馈音量显示是否正确,同时关注静音场景(PMS:350837)
@deepin-ci-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: 18202781743, 52cyb

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

@52cyb
Copy link
Copy Markdown
Contributor Author

52cyb commented May 8, 2026

/merge

@deepin-bot deepin-bot Bot merged commit bdc27e7 into linuxdeepin:master May 8, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants