Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions examples/exhibition/ScrollBar.qml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2022-2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: LGPL-3.0-or-later

Expand All @@ -7,6 +7,11 @@ import org.deepin.dtk 1.0

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

property color borderColor: darkMode ? "#3d3d3d" : "#cacaca"
property color contentBgColor: darkMode ? "#2a2a2a" : "#f5f5f5"

Label {
width: parent.width
wrapMode: Text.WordWrap
Expand All @@ -21,7 +26,8 @@ Column {
width: parent.width

Rectangle {
border.color: "#cacaca"
border.color: panel.borderColor
color: panel.contentBgColor
width: 300
height: 213
Flickable {
Expand All @@ -44,14 +50,15 @@ Column {
}
}

Item { width: parent.width; height: 1}
Item { width: parent.width; height: 1 }

Rectangle {
id: frame
clip: true
width: 1000
height: 278
border.color: "black"
border.color: panel.borderColor
color: panel.contentBgColor
Rectangle {
id: content
width: 450
Expand Down
18 changes: 13 additions & 5 deletions qt6/src/qml/FlowStyle.qml
Original file line number Diff line number Diff line change
Expand Up @@ -852,19 +852,24 @@ QtObject {
// Bar
property QtObject scrollBar: QtObject {
property int padding: 2
property int width: 4
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`.

property int horizontalHoverWidth: 12
property int normalRadius: 4
property real hideOpacity: 0.0
property int hidePauseDuration: 450
property int hideDuration: 1500
property int hideWidthDuration: 100
property int radius: 6

property D.Palette background: D.Palette {
normal: Qt.rgba(0, 0, 0, 0.3)
normal: Qt.rgba(0, 0, 0, 0.5)
normalDark: Qt.rgba(1, 1, 1, 0.3)

hovered: Qt.rgba(0, 0, 0, 0.4)
hoveredDark: Qt.rgba(1, 1, 1, 0.6)
hovered: Qt.rgba(0, 0, 0, 0.7)
hoveredDark: Qt.rgba(1, 1, 1, 0.7)

pressed: Qt.rgba(0, 0, 0, 0.4)
pressedDark: Qt.rgba(1, 1, 1, 0.3)
Expand All @@ -877,7 +882,10 @@ QtObject {

property D.Palette insideBorder: D.Palette {
normal: Qt.rgba(0, 0, 0, 0.05)
normalDark: Qt.rgba(1, 1, 1, 0.1)
normalDark: Qt.rgba(1, 1, 1, 0.05)

hoveredDark: Qt.rgba(1, 1, 1, 0.1)
pressedDark: Qt.rgba(1, 1, 1, 0.05)
}
}

Expand Down
28 changes: 22 additions & 6 deletions qt6/src/qml/ScrollBar.qml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2022-2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: LGPL-3.0-or-later

Expand Down Expand Up @@ -55,24 +55,36 @@ T.ScrollBar {
when: __currentState === 0
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`.

opacity: DS.Style.scrollBar.hideOpacity
}
PropertyChanges {
target: backgroundRect
radius: DS.Style.scrollBar.normalRadius
}
},
State {
name: "normal"
when: __currentState === 1
PropertyChanges {
target: control.contentItem
implicitWidth: DS.Style.scrollBar.width
implicitWidth: control.orientation == Qt.Horizontal ? DS.Style.scrollBar.horizontalWidth : DS.Style.scrollBar.width
}
PropertyChanges {
target: backgroundRect
radius: DS.Style.scrollBar.normalRadius
}
},
State {
name: "hover"
when: __currentState === 2
PropertyChanges {
target: control.contentItem
implicitWidth: DS.Style.scrollBar.activeWidth
implicitWidth: control.orientation == Qt.Horizontal ? DS.Style.scrollBar.horizontalHoverWidth : DS.Style.scrollBar.hoverWidth
}
PropertyChanges {
target: backgroundRect
radius: DS.Style.scrollBar.radius
}
},
State {
Expand All @@ -82,6 +94,10 @@ T.ScrollBar {
target: control.contentItem
implicitWidth: DS.Style.scrollBar.activeWidth
}
PropertyChanges {
target: backgroundRect
radius: DS.Style.scrollBar.radius
}
}
]

Expand All @@ -100,13 +116,13 @@ T.ScrollBar {
property D.Palette insideBorderColor: DS.Style.scrollBar.insideBorder
property D.Palette outsideBorderColor: DS.Style.scrollBar.outsideBorder

implicitWidth: DS.Style.scrollBar.width
implicitWidth: control.orientation == Qt.Horizontal ? DS.Style.scrollBar.horizontalWidth : DS.Style.scrollBar.width
implicitHeight: implicitWidth

Rectangle {
id: backgroundRect
anchors.fill: parent
radius: control.orientation == Qt.Horizontal ? control.height / 2 : control.width / 2
radius: DS.Style.scrollBar.normalRadius
color: content.D.ColorSelector.backgroundColor
}

Expand Down
Loading