Skip to content

fix(scrollbar): refine width, radius, opacity for per-state styling - #758

Merged
18202781743 merged 1 commit into
linuxdeepin:v25-flowstylefrom
zqq-dora:fix-scrollbar-style-v25
Nov 19, 2026
Merged

18202781743 merged 1 commit into
linuxdeepin:v25-flowstylefrom
zqq-dora:fix-scrollbar-style-v25

Conversation

@zqq-dora

@zqq-dora zqq-dora commented Nov 19, 2026 •

Copy link
Copy Markdown

Refactor ScrollBar to distinguish vertical and horizontal widths, fix opacity values, and use dedicated radius tokens instead of dynamic height/2 or width/2.

Style tokens (qt6/src/qml/FlowStyle.qml):

  • Vertical width 4 -> 6; add horizontalWidth: 4 for slimmer horizontal bars
  • Add hoverWidth: 14 and horizontalHoverWidth: 12 for orientation-aware hover sizing (previously both used activeWidth: 12)
  • Add normalRadius: 4 (hide/normal) and radius: 6 (hover/pressed), replacing dynamic height/2 or width/2
  • Background opacity: normal 0.3 -> 0.5, hovered 0.4 -> 0.7; hoveredDark 0.6 -> 0.7
  • insideBorder: normalDark 0.1 -> 0.05; add hoveredDark (0.1) and pressedDark (0.05)

Control (qt6/src/qml/ScrollBar.qml):

  • hide / normal / hover states use orientation-aware width tokens
  • pressed (active) state keeps activeWidth: 12; with 1px border on each side the visual width is 14, matching hover
  • All four states now drive backgroundRect.radius: normalRadius (4) for hide/normal, radius (6) for hover/pressed, replacing the old dynamic height/2 / width/2
  • contentItem.implicitWidth default is orientation-aware

Exhibition demo (examples/exhibition/ScrollBar.qml):

  • Add theme-aware border and content background colors via ApplicationHelper.n so scrollbars are visible in both light and dark modes
  • Fix D is not defined ReferenceError by replacing D.DTK.themeType / D.ApplicationHelper with correct unqualified QML references

重构 ScrollBar 样式,区分垂直和水平方向宽度,修正透明度,并使用独立的圆角参数替代动态的 height/2 / width/2。

样式参数 (qt6/src/qml/FlowStyle.qml):

  • 垂直宽度 4 -> 6;新增 horizontalWidth: 4,水平滚动条保持纤细
  • 新增 hoverWidth: 14 和 horizontalHoverWidth: 12,区分方向的 hover 宽度(之前统一用 activeWidth: 12)
  • 新增 normalRadius: 4(隐藏/正常态)和 radius: 6(hover/pressed 态),取代动态的 height/2 / width/2
  • 背景透明度:normal 0.3 -> 0.5,hover 0.4 -> 0.7;hoveredDark 0.6 -> 0.7
  • insideBorder:normalDark 0.1 -> 0.05;新增 hoveredDark (0.1) 和 pressedDark (0.05)

控件 (qt6/src/qml/ScrollBar.qml):

  • 隐藏 / 正常 / hover 状态使用方向感知的宽度参数
  • pressed(active)状态保持 activeWidth: 12;加上两侧各 1px 外描边,视觉宽度为 14,与 hover 一致
  • 四个状态均驱动 backgroundRect.radius:隐藏/正常用 normalRadius (4),hover/pressed 用 radius (6),取代旧的动态 height/2 / width/2
  • contentItem.implicitWidth 默认值改为方向感知

Exhibition 示例 (examples/exhibition/ScrollBar.qml):

  • 通过 ApplicationHelper.n 添加主题感知的边框色和内容背景色,浅色和深色模式下都能清楚看到滚动条
  • 修复 D is not defined 的 ReferenceError,将 D.DTK.themeType / D.ApplicationHelper 替换为正确的无前缀 QML 引用

Summary by Sourcery

Refine scrollbar dimensions, opacity, borders, and radii for consistent per-state and orientation-aware styling.

Bug Fixes:

  • Fix scrollbar styling so opacity, borders, orientation-specific sizing, and corner radii render consistently across states and themes.
  • Fix the exhibition scrollbar example's theme handling and invalid QML references.

Enhancements:

  • Refine scrollbar style tokens with distinct horizontal, hover, pressed, and normal-state dimensions and radii.
  • Improve scrollbar visibility in light and dark exhibition themes.

Refactor ScrollBar to distinguish vertical and horizontal widths, fix
opacity values, and use dedicated radius tokens instead of dynamic
height/2 or width/2.

Style tokens (qt6/src/qml/FlowStyle.qml):
- Vertical width 4 -> 6; add horizontalWidth: 4 for slimmer horizontal bars
- Add hoverWidth: 14 and horizontalHoverWidth: 12 for orientation-aware
  hover sizing (previously both used activeWidth: 12)
- Add normalRadius: 4 (hide/normal) and radius: 6 (hover/pressed),
  replacing dynamic height/2 or width/2
- Background opacity: normal 0.3 -> 0.5, hovered 0.4 -> 0.7;
  hoveredDark 0.6 -> 0.7
- insideBorder: normalDark 0.1 -> 0.05; add hoveredDark (0.1)
  and pressedDark (0.05)

Control (qt6/src/qml/ScrollBar.qml):
- hide / normal / hover states use orientation-aware width tokens
- pressed (active) state keeps activeWidth: 12; with 1px border on each
  side the visual width is 14, matching hover
- All four states now drive backgroundRect.radius: normalRadius (4) for
  hide/normal, radius (6) for hover/pressed, replacing the old dynamic
  height/2 / width/2
- contentItem.implicitWidth default is orientation-aware

Exhibition demo (examples/exhibition/ScrollBar.qml):
- Add theme-aware border and content background colors via
  ApplicationHelper.n so scrollbars are visible in both light and dark
  modes
- Fix "D is not defined" ReferenceError by replacing D.DTK.themeType /
  D.ApplicationHelper with correct unqualified QML references

重构 ScrollBar 样式,区分垂直和水平方向宽度,修正透明度,并使用独立的
圆角参数替代动态的 height/2 / width/2。

样式参数 (qt6/src/qml/FlowStyle.qml):
- 垂直宽度 4 -> 6;新增 horizontalWidth: 4,水平滚动条保持纤细
- 新增 hoverWidth: 14 和 horizontalHoverWidth: 12,区分方向的 hover 宽度
  (之前统一用 activeWidth: 12)
- 新增 normalRadius: 4(隐藏/正常态)和 radius: 6(hover/pressed 态),
  取代动态的 height/2 / width/2
- 背景透明度:normal 0.3 -> 0.5,hover 0.4 -> 0.7;hoveredDark 0.6 -> 0.7
- insideBorder:normalDark 0.1 -> 0.05;新增 hoveredDark (0.1)
  和 pressedDark (0.05)

控件 (qt6/src/qml/ScrollBar.qml):
- 隐藏 / 正常 / hover 状态使用方向感知的宽度参数
- pressed(active)状态保持 activeWidth: 12;加上两侧各 1px 外描边,
  视觉宽度为 14,与 hover 一致
- 四个状态均驱动 backgroundRect.radius:隐藏/正常用 normalRadius (4),
  hover/pressed 用 radius (6),取代旧的动态 height/2 / width/2
- contentItem.implicitWidth 默认值改为方向感知

Exhibition 示例 (examples/exhibition/ScrollBar.qml):
- 通过 ApplicationHelper.n 添加主题感知的边框色和内容背景色,浅色和深色
  模式下都能清楚看到滚动条
- 修复 D is not defined 的 ReferenceError,将 D.DTK.themeType /
  D.ApplicationHelper 替换为正确的无前缀 QML 引用
@deepin-ci-robot

Copy link
Copy Markdown
Contributor

Hi @zqq-dora. 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

sourcery-ai Bot commented Nov 19, 2026

Copy link
Copy Markdown

Reviewer's Guide

UI

Define the per-orientation scrollbar widths, state radii, and palette values, then apply those tokens to the corresponding control states and default content width.

  • qt6/src/qml/FlowStyle.qml L1054-1059, L1064-1071, L1084-1087
  • qt6/src/qml/ScrollBar.qml L58-64, L71-75, L83-87 (+4 small edits)

Make the exhibition scrollbar examples visible in both themes and use the unqualified application helper for theme detection.

  • examples/exhibition/ScrollBar.qml L10-14 (+4 small edits)

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 - I've found 2 issues

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="qt6/src/qml/FlowStyle.qml" line_range="1057" />
<code_context>
+        property int width: 6
+        property int horizontalWidth: 4
         property int activeWidth: 12
+        property int hoverWidth: 14
+        property int horizontalHoverWidth: 12
+        property int normalRadius: 4
</code_context>
<issue_to_address>
**Scrollbar narrows when pressed**

When a vertical scrollbar transitions from hover to pressed, `FlowStyle.hoverWidth` is 14 while `activeWidth` is 12, and `OutsideBoxBorder` adds 1 px on each side in both states, so the visible scrollbar shrinks from 16 px to 14 px when pressed.

Set `hoverWidth` to 12 so it matches `activeWidth`.

Also at `qt6/src/qml/ScrollBar.qml:83-84`.
</issue_to_address>

### Comment 2
<location path="examples/exhibition/ScrollBar.qml" line_range="11" />
<code_context>
 Column {
     id: panel
+
+    property bool darkMode: ApplicationHelper.n === ApplicationHelper.DarkType
+    property color borderColor: darkMode ? "#3d3d3d" : "#cacaca"
+    property color contentBgColor: darkMode ? "#2a2a2a" : "#f5f5f5"
</code_context>
<issue_to_address>
**Demo stays light in dark mode**

When the exhibition is shown in dark mode, `ApplicationHelper.n` is not a theme property, so `darkMode` stays false and `borderColor` and `contentBgColor` retain their light colors.

Bind `darkMode` to the registered `ApplicationHelper` singleton’s actual current-theme property.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread qt6/src/qml/FlowStyle.qml
property int width: 6
property int horizontalWidth: 4
property int activeWidth: 12
property int hoverWidth: 14

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Medium · Scrollbar narrows when pressed

When a vertical scrollbar transitions from hover to pressed, FlowStyle.hoverWidth is 14 while activeWidth is 12, and OutsideBoxBorder adds 1 px on each side in both states, so the visible scrollbar shrinks from 16 px to 14 px when pressed.

Set hoverWidth to 12 so it matches activeWidth.

Also at qt6/src/qml/ScrollBar.qml:83-84.

Prompt for AI agents
In `qt6/src/qml/FlowStyle.qml` at line 1057:

**Scrollbar narrows when pressed**

When a vertical scrollbar transitions from hover to pressed, `FlowStyle.hoverWidth` is 14 while `activeWidth` is 12, and `OutsideBoxBorder` adds 1 px on each side in both states, so the visible scrollbar shrinks from 16 px to 14 px when pressed.

Set `hoverWidth` to 12 so it matches `activeWidth`.

Also at `qt6/src/qml/ScrollBar.qml:83-84`.

Column {
id: panel

property bool darkMode: ApplicationHelper.n === ApplicationHelper.DarkType

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Medium · Demo stays light in dark mode

When the exhibition is shown in dark mode, ApplicationHelper.n is not a theme property, so darkMode stays false and borderColor and contentBgColor retain their light colors.

Bind darkMode to the registered ApplicationHelper singleton’s actual current-theme property.

Prompt for AI agents
In `examples/exhibition/ScrollBar.qml` at line 11:

**Demo stays light in dark mode**

When the exhibition is shown in dark mode, `ApplicationHelper.n` is not a theme property, so `darkMode` stays false and `borderColor` and `contentBgColor` retain their light colors.

Bind `darkMode` to the registered `ApplicationHelper` singleton’s actual current-theme property.

@deepin-ci-robot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: 18202781743, zqq-dora

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 9738224 into linuxdeepin:v25-flowstyle Nov 19, 2026
18 of 22 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