Skip to content
Merged
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: 14 additions & 1 deletion qt6/src/qml/FlowStyle.qml
Original file line number Diff line number Diff line change
Expand Up @@ -726,9 +726,10 @@ QtObject {
property int width : 300
property int height: 36
property int spacing: 10
property int indicatorSpacing: 2

property QtObject indicator: QtObject {
property int width: 24
property int width: 20
property int height: 14
property int iconSize: 24
property int focusIconSize: 10
Expand All @@ -739,6 +740,18 @@ QtObject {
pressed: Qt.rgba(0, 0, 0, 0.8)
}
}

// Combined background for both up/down indicators
property int indicatorContainerVMargin: 2
property int indicatorContainerRadius: 4
property D.Palette indicatorBackground: D.Palette {
normal: Qt.rgba(0, 0, 0, 0.15)
normalDark: Qt.rgba(0, 0, 0, 0.2)
}
// 1px inner shadow, dark mode only
property D.Palette indicatorInnerShadow: D.Palette {
normalDark: Qt.rgba(0, 0, 0, 0.4)
}
}

property QtObject plusMinusSpinBox: QtObject {
Expand Down
120 changes: 45 additions & 75 deletions qt6/src/qml/SpinBoxIndicator.qml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import QtQuick
import org.deepin.dtk 1.0 as D
import org.deepin.dtk.style 1.0 as DS
import org.deepin.dtk.private as P

Control {
id: control
Expand All @@ -19,90 +18,61 @@ Control {
property bool singleIndicator: false
property int direction
property D.Palette inactiveBackgroundColor: DS.Style.spinBox.indicator.background
property D.Palette indicatorBackground: DS.Style.spinBox.indicatorBackground
property D.Palette indicatorInnerShadow: DS.Style.spinBox.indicatorInnerShadow

palette.windowText: control.D.ColorSelector.inactiveBackgroundColor
// Background stays full opacity; only the icon dims when disabled.
hoverEnabled: true
implicitWidth: DS.Style.spinBox.indicator.width
implicitHeight: spinBox.activeFocus ? spinBox.implicitHeight / 2 : DS.Style.spinBox.indicator.height
opacity: D.ColorSelector.controlState === D.DTK.DisabledState ? 0.4 : 1
implicitHeight: (spinBox.implicitHeight - 2 * DS.Style.spinBox.indicatorContainerVMargin) / 2

Component {
id: inactiveComponent
D.DciIcon {
id: icon
smooth: control.smooth
sourceSize.width: DS.Style.spinBox.indicator.iconSize
palette: D.DTK.makeIconPalette(control.palette)
name: direction === SpinBoxIndicator.IndicatorDirection.UpIndicator ? "entry_spinbox_up" : "entry_spinbox_down"
mode: control.D.ColorSelector.controlState
theme: control.D.ColorSelector.controlTheme
fallbackToQIcon: false
}
}

Component {
id: activeComponent
Item {
Item {
id: btnBackground
width: parent.width + DS.Style.control.radius
height: parent.height + DS.Style.control.radius
anchors {
right: parent.right
top: direction === SpinBoxIndicator.IndicatorDirection.UpIndicator ? parent.top : undefined
bottom: direction === SpinBoxIndicator.IndicatorDirection.UpIndicator ? undefined : parent.bottom
}

Button {
id: btn
anchors {
right: parent.right
top: direction === SpinBoxIndicator.IndicatorDirection.UpIndicator ? parent.top : undefined
bottom: direction === SpinBoxIndicator.IndicatorDirection.UpIndicator ? undefined : parent.bottom
}
width: DS.Style.spinBox.indicatorWidth
height: spinBox.implicitHeight / 2
icon {
name: direction === SpinBoxIndicator.IndicatorDirection.UpIndicator ? "arrow_ordinary_up" : "arrow_ordinary_down"
width: DS.Style.spinBox.indicator.focusIconSize
height: DS.Style.spinBox.indicator.focusIconSize
}
activeFocusOnTab: false
opacity: 1
background: P.ButtonPanel {
button: btn
radius: 0
}
onClicked: {
if (direction === SpinBoxIndicator.IndicatorDirection.UpIndicator) {
spinBox.increase()
} else {
spinBox.decrease()
}
}
}
}
// Each indicator draws its own half of the combined background.
// The up indicator has rounded top corners; the down indicator has
// rounded bottom corners. Together they form a seamless whole with
// no overlap and no gap.
background: Rectangle {
radius: DS.Style.spinBox.indicatorContainerRadius
color: control.D.ColorSelector.indicatorBackground
topLeftRadius: direction === SpinBoxIndicator.IndicatorDirection.UpIndicator ? DS.Style.spinBox.indicatorContainerRadius : 0
topRightRadius: direction === SpinBoxIndicator.IndicatorDirection.UpIndicator ? DS.Style.spinBox.indicatorContainerRadius : 0
bottomLeftRadius: direction === SpinBoxIndicator.IndicatorDirection.DownIndicator ? DS.Style.spinBox.indicatorContainerRadius : 0
bottomRightRadius: direction === SpinBoxIndicator.IndicatorDirection.DownIndicator ? DS.Style.spinBox.indicatorContainerRadius : 0

D.ItemViewport {
id: viewport
sourceItem: btnBackground
radius: DS.Style.control.radius
fixed: true
width: btnBackground.width
height: btnBackground.height
anchors {
right: parent.right
top: direction === SpinBoxIndicator.IndicatorDirection.UpIndicator ? parent.top : undefined
bottom: direction === SpinBoxIndicator.IndicatorDirection.UpIndicator ? undefined : parent.bottom
}
hideSource: true
Loader {
active: D.DTK.themeType === D.ApplicationHelper.DarkType && direction === SpinBoxIndicator.IndicatorDirection.DownIndicator
anchors.fill: parent
sourceComponent: BoxInsetShadow {
shadowBlur: 1
shadowOffsetY: -1
spread: 0
shadowColor: control.D.ColorSelector.indicatorInnerShadow
cornerRadius: DS.Style.spinBox.indicatorContainerRadius
}
}

}

Loader {
ToolButton {
opacity: D.ColorSelector.controlState === D.DTK.DisabledState ? 0.4 : 1
anchors.fill: parent
sourceComponent: spinBox.activeFocus ? activeComponent : inactiveComponent
Comment thread
iCancely marked this conversation as resolved.
Resolved
topPadding: 0
bottomPadding: 0
leftPadding: 0
rightPadding: 0
focusPolicy: Qt.NoFocus
background: null
icon {
name: direction === SpinBoxIndicator.IndicatorDirection.UpIndicator ? "arrow_ordinary_up" : "arrow_ordinary_down"
width: DS.Style.spinBox.indicator.focusIconSize
height: DS.Style.spinBox.indicator.focusIconSize
Comment on lines +66 to +67

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 · Idle arrows render too small

When the spin box is displayed, especially while it is not focused, Button.icon always uses focusIconSize (10 px), replacing the unfocused 24 px source size; configured indicator icon sizes also no longer affect the control, so the arrows render too small.

Use the configured icon size for unfocused indicators and reserve focusIconSize for the focused state.

Also at qt6/src/qml/SpinBoxIndicator.qml:30.

Prompt for AI agents
In `qt6/src/qml/SpinBoxIndicator.qml` at lines 42-43:

**Idle arrows render too small**

When the spin box is displayed, especially while it is not focused, `Button.icon` always uses `focusIconSize` (10 px), replacing the unfocused 24 px source size; configured indicator icon sizes also no longer affect the control, so the arrows render too small.

Use the configured icon size for unfocused indicators and reserve `focusIconSize` for the focused state.

Also at `qt6/src/qml/SpinBoxIndicator.qml:30`.

}
activeFocusOnTab: false
onClicked: {
if (direction === SpinBoxIndicator.IndicatorDirection.UpIndicator) {
spinBox.increase()
} else {
spinBox.decrease()
}
}
}
}
Loading