Skip to content

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

Closed
zqq-dora wants to merge 1 commit into
linuxdeepin:masterfrom
zqq-dora:fix-scrollbar-style
Closed

zqq-dora wants to merge 1 commit into
linuxdeepin:masterfrom
zqq-dora:fix-scrollbar-style

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 引用

@deepin-ci-robot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

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

@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

Data structures

Define the scrollbar sizing, radius, opacity, and border style tokens that the control consumes.

  • qt6/src/qml/FlowStyle.qml L855-860, L865-872, L885-888

UI

Apply the orientation-specific widths and per-state radii in the ScrollBar control, including its default content width.

  • qt6/src/qml/ScrollBar.qml L58-64, L71-75, L83-87 (+4 small edits)

Make the exhibition scrollbar examples visible in both themes by using theme-aware frame and content colors.

  • 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 3 issues

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

## Individual Comments

### Comment 1
<location path="qt6/src/qml/ScrollBar.qml" line_range="58" />
<code_context>
             PropertyChanges {
                 target: control.contentItem
-                implicitWidth: DS.Style.scrollBar.width
+                implicitWidth: control.orientation == Qt.Horizontal ? DS.Style.scrollBar.horizontalWidth : DS.Style.scrollBar.width
                 opacity: DS.Style.scrollBar.hideOpacity
             }
</code_context>
<issue_to_address>
**Older style overrides lose scrollbar sizing**

When an application supplies a style override based on the previous scroll-bar token set, a custom `DS.Style` based on the previous token set has no `horizontalWidth`, `hoverWidth`, or `normalRadius`; these bindings then read missing properties, leaving scrollbar dimensions or radii invalid and breaking rendering for applications using that override.

Provide backward-compatible fallbacks for the new tokens or preserve the old style shape when resolving scrollbar values.

Also at `qt6/src/qml/ScrollBar.qml:83`, `qt6/src/qml/ScrollBar.qml:125`.
</issue_to_address>

### Comment 2
<location path="qt6/src/qml/FlowStyle.qml" line_range="858" />
<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 on press**

When a vertical scrollbar transitions from hover to pressed, the hover state uses `hoverWidth` 14 while the pressed state uses `activeWidth` 12; `OutsideBoxBorder` adds 1px on each side, so the bar goes from 16px to 14px and visibly narrows on press.

Set the vertical pressed width to match the hover width.

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

### Comment 3
<location path="examples/exhibition/ScrollBar.qml" line_range="11" />
<code_context>
 Column {
     id: panel
+
+    property bool darkMode: ApplicationHelper.n === ApplicationHelper.DarkType
+    property color bgColor: darkMode ? "#1b1b1b" : "#ffffff"
+    property color borderColor: darkMode ? "#3d3d3d" : "#cacaca"
</code_context>
<issue_to_address>
**Demo keeps light-mode colors**

When the exhibition is shown in dark mode, `ApplicationHelper.n` does not expose the current theme, so `darkMode` remains false and `bgColor`, `borderColor`, and `contentBgColor` keep their light-mode values; the demo's surfaces and scrollbar borders lose contrast.

Bind `darkMode` to the exposed theme property instead of `ApplicationHelper.n`.
</issue_to_address>

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

Comment thread qt6/src/qml/ScrollBar.qml
PropertyChanges {
target: control.contentItem
implicitWidth: DS.Style.scrollBar.width
implicitWidth: control.orientation == Qt.Horizontal ? DS.Style.scrollBar.horizontalWidth : DS.Style.scrollBar.width

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 · Older style overrides lose scrollbar sizing

When an application supplies a style override based on the previous scroll-bar token set, a custom DS.Style based on the previous token set has no horizontalWidth, hoverWidth, or normalRadius; these bindings then read missing properties, leaving scrollbar dimensions or radii invalid and breaking rendering for applications using that override.

Provide backward-compatible fallbacks for the new tokens or preserve the old style shape when resolving scrollbar values.

Also at qt6/src/qml/ScrollBar.qml:83, qt6/src/qml/ScrollBar.qml:125.

Prompt for AI agents
In `qt6/src/qml/ScrollBar.qml` at line 58:

**Older style overrides lose scrollbar sizing**

When an application supplies a style override based on the previous scroll-bar token set, a custom `DS.Style` based on the previous token set has no `horizontalWidth`, `hoverWidth`, or `normalRadius`; these bindings then read missing properties, leaving scrollbar dimensions or radii invalid and breaking rendering for applications using that override.

Provide backward-compatible fallbacks for the new tokens or preserve the old style shape when resolving scrollbar values.

Also at `qt6/src/qml/ScrollBar.qml:83`, `qt6/src/qml/ScrollBar.qml:125`.

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 on press

When a vertical scrollbar transitions from hover to pressed, the hover state uses hoverWidth 14 while the pressed state uses activeWidth 12; OutsideBoxBorder adds 1px on each side, so the bar goes from 16px to 14px and visibly narrows on press.

Set the vertical pressed width to match the hover width.

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

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

**Scrollbar narrows on press**

When a vertical scrollbar transitions from hover to pressed, the hover state uses `hoverWidth` 14 while the pressed state uses `activeWidth` 12; `OutsideBoxBorder` adds 1px on each side, so the bar goes from 16px to 14px and visibly narrows on press.

Set the vertical pressed width to match the hover width.

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

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 keeps light-mode colors

When the exhibition is shown in dark mode, ApplicationHelper.n does not expose the current theme, so darkMode remains false and bgColor, borderColor, and contentBgColor keep their light-mode values; the demo's surfaces and scrollbar borders lose contrast.

Bind darkMode to the exposed theme property instead of ApplicationHelper.n.

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

**Demo keeps light-mode colors**

When the exhibition is shown in dark mode, `ApplicationHelper.n` does not expose the current theme, so `darkMode` remains false and `bgColor`, `borderColor`, and `contentBgColor` keep their light-mode values; the demo's surfaces and scrollbar borders lose contrast.

Bind `darkMode` to the exposed theme property instead of `ApplicationHelper.n`.

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 引用
@zqq-dora
zqq-dora force-pushed the fix-scrollbar-style branch from daccd89 to 260603c Compare November 19, 2026 07:34
@zqq-dora zqq-dora changed the title fix(scrollbar): refine width, radius, opacity and border for per-state styling fix(scrollbar): refine width, radius, opacity for per-state styling Nov 19, 2026
@18202781743

Copy link
Copy Markdown
Contributor

这个pr是要合入master么?

@zqq-dora

Copy link
Copy Markdown
Author

目标分支搞错了,应该合入 v25-flowstyle,已重新提 PR。

@zqq-dora zqq-dora closed this Nov 19, 2026
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