This repository has been archived by the owner on Feb 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
AIntParameter.qml
154 lines (142 loc) · 5.3 KB
/
AIntParameter.qml
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
142
143
144
145
146
147
148
149
150
151
152
153
154
import QtQuick 2.0
import QtQuick.Controls 2.2
import QtQuick.Layouts 1.3
import "ByteList.js" as ByteList
RowLayout {
property var eeParameterData;
RowLayout {
SpinBox {
id: spinbox
from: eeParameterData.from
to: eeParameterData.to
editable: true
contentItem: TextField {
z: -2
text: spinbox.textFromValue(spinbox.value, spinbox.locale)
color: {
if (enabled) {
if (spinbox.contentItem.activeFocus)
return globStyle.background
else
return globStyle.accent
}
else
return globStyle.accentFaded
}
font.pointSize: globStyle.fontSize
selectionColor: globStyle.accentLight
selectedTextColor: globStyle.background
horizontalAlignment: Qt.AlignHCenter
verticalAlignment: Qt.AlignVCenter
readOnly: !spinbox.editable
validator: spinbox.validator
inputMethodHints: Qt.ImhFormattedNumbersOnly
background: Item {}
Keys.onReturnPressed: {
serialTask.forceActiveFocus()
}
}
up.indicator: Rectangle {
x: spinbox.mirrored ? 0 : parent.width - width
height: parent.height
implicitWidth: globStyle.size
implicitHeight: globStyle.size
color: {
if (spinbox.up.pressed)
return globStyle.accent
else if (spinbox.up.hovered)
return globStyle.backgroundFaded
else
return globStyle.background
}
border.color: {
if (enabled) {
if (spinbox.up.pressed)
return globStyle.background
else
return globStyle.accent
}
else
return globStyle.accentFaded
}
border.width: globStyle.thickness
Text {
text: "+"
font.pixelSize: globStyle.fontSize * 2
color: parent.border.color
anchors.fill: parent
fontSizeMode: Text.Fit
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
}
down.indicator: Rectangle {
x: spinbox.mirrored ? parent.width - width : 0
height: parent.height
implicitWidth: globStyle.size
implicitHeight: globStyle.size
color: {
if (spinbox.down.pressed)
return globStyle.accent
else if (spinbox.down.hovered)
return globStyle.backgroundFaded
else
return globStyle.background
}
border.color: {
if (enabled) {
if (spinbox.down.pressed)
return globStyle.background
else
return globStyle.accent
}
else
return globStyle.accentFaded
}
border.width: globStyle.thickness
Text {
text: "-"
font.pixelSize: globStyle.fontSize * 2
color: parent.border.color
anchors.fill: parent
fontSizeMode: Text.Fit
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
}
background: Rectangle {
z: -4
implicitWidth: globStyle.size * 3.5
color: {
if (spinbox.contentItem.activeFocus)
return globStyle.accent
else if (spinbox.contentItem.hovered)
return globStyle.backgroundFaded
else
return "transparent"
}
border.color: {
if (spinbox.contentItem.enabled) {
if (spinbox.contentItem.activeFocus)
return globStyle.background
else
return globStyle.accent
}
else
return globStyle.accentFaded
}
border.width: globStyle.thickness
}
}
ALabel {
text: typeof eeParameterData.unit !== 'undefined' ? eeParameterData.unit : ""
color: enabled ? globStyle.accent : globStyle.accentFaded
}
}
function getParameterValue() {
return ByteList.fromInt(spinbox.value)
}
function setParameterValue(vals) {
spinbox.value = ByteList.toInt(vals)
}
}