blob: 88eed43261109134ea4b182eb814336c68f7afce (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
|
// Copyright (C) 2025 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
// Qt-Security score:significant reason:default
import QtQuick
import QtQuick.Controls.impl
import QtQuick.Templates as T
import Qt.labs.StyleKit
import Qt.labs.StyleKit.impl
T.SpinBox {
id: control
implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset,
implicitContentWidth + leftPadding + rightPadding)
implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset,
implicitContentHeight + topPadding + bottomPadding)
leftPadding: spinBoxLayout.padding.left
topPadding: spinBoxLayout.padding.top
rightPadding: spinBoxLayout.padding.right
bottomPadding: spinBoxLayout.padding.bottom
spacing: styleReader.spacing
StyleKitControl.controlType: styleReader.type
StyleKitReader {
id: styleReader
type: StyleKitReader.SpinBox
enabled: control.enabled
focused: control.activeFocus
hovered: control.hovered || control.down.hovered || control.up.hovered
pressed: control.down.pressed || control.up.pressed
palette: control.palette
}
StyleKitReader {
id: upProperties
type: StyleKitReader.SpinBox
enabled: control.enabled
focused: control.activeFocus
hovered: control.up.hovered
pressed: control.up.pressed
palette: control.palette
}
StyleKitReader {
id: downProperties
type: StyleKitReader.SpinBox
enabled: control.enabled
focused: control.activeFocus
hovered: control.down.hovered
pressed: control.down.pressed
palette: control.palette
}
StyleKitLayout {
id: spinBoxLayout
container: control
contentMargins {
// Copy the other styles, and add indicator width to padding
left: styleReader.leftPadding
right: styleReader.rightPadding
top: styleReader.topPadding
bottom: styleReader.bottomPadding
}
layoutItems: [
// We don't lay out the contentItem here because it occupies the remaining space
// as calculated by control internal logic.
StyleKitLayoutItem {
id: upIndicatorItem
item: control.up.indicator
alignment: styleReader.indicator.up.alignment
margins.left: styleReader.indicator.up.leftMargin
margins.right: styleReader.indicator.up.rightMargin
margins.top: styleReader.indicator.up.topMargin
margins.bottom: styleReader.indicator.up.bottomMargin
fillWidth: styleReader.indicator.up.implicitWidth === Style.Stretch
fillHeight: styleReader.indicator.up.implicitHeight === Style.Stretch
},
StyleKitLayoutItem {
id: downIndicatorItem
item: control.down.indicator
alignment: styleReader.indicator.down.alignment
margins.left: styleReader.indicator.down.leftMargin
margins.right: styleReader.indicator.down.rightMargin
margins.top: styleReader.indicator.down.topMargin
margins.bottom: styleReader.indicator.down.bottomMargin
fillWidth: styleReader.indicator.down.implicitWidth === Style.Stretch
fillHeight: styleReader.indicator.down.implicitHeight === Style.Stretch
}
]
spacing: styleReader.spacing
mirrored: control.mirrored
}
validator: IntValidator {
locale: control.locale.name
bottom: Math.min(control.from, control.to)
top: Math.max(control.from, control.to)
}
contentItem: TextInput {
z: 2
text: control.displayText
font: styleReader.font
selectionColor: control.palette.highlight
selectedTextColor: control.palette.highlightedText
color: styleReader.text.color
horizontalAlignment: styleReader.text.alignment & Qt.AlignHorizontal_Mask
verticalAlignment: styleReader.text.alignment & Qt.AlignVertical_Mask
readOnly: !control.editable
validator: control.validator
inputMethodHints: control.inputMethodHints
clip: width < implicitWidth
}
up.indicator: IndicatorDelegate {
parentControl: control
indicatorProperties: upProperties.indicator.up
x: upIndicatorItem.x
y: upIndicatorItem.y
width: upIndicatorItem.width
height: upIndicatorItem.height
}
down.indicator: IndicatorDelegate {
parentControl: control
indicatorProperties: downProperties.indicator.down
x: downIndicatorItem.x
y: downIndicatorItem.y
width: downIndicatorItem.width
height: downIndicatorItem.height
}
background: BackgroundDelegate {
parentControl: control
backgroundProperties: styleReader.background
}
}
|