Skip to content

Commit 53ecd39

Browse files
committed
continuous param update
1 parent 5764559 commit 53ecd39

File tree

2 files changed

+37
-8
lines changed

2 files changed

+37
-8
lines changed

xbot2_gui/Monitoring/Parameter/RealDelegate.qml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@ RowLayout {
1212

1313
readonly property real value: slider.value
1414

15+
signal valueChangedByUser(real value)
16+
1517
function setValue(value) {
16-
console.log(`setValue ${value}`)
18+
console.log(`setValue ${value} min ${min} max ${max}`)
1719
slider.value = value
1820
spin.value = value
1921
}
@@ -26,13 +28,21 @@ RowLayout {
2628
Layout.fillWidth: true
2729
from: control.min
2830
to: control.max
29-
onMoved: spin.value = value
31+
onMoved: {
32+
control.valueChangedByUser(value)
33+
spin.value = value
34+
}
3035
}
3136

3237
DoubleSpinBox1 {
3338
id: spin
3439
from: control.min
3540
to: control.max
36-
onValueModified: slider.value = value
41+
onValueModified: function(value) {
42+
control.valueChangedByUser(value)
43+
slider.value = value
44+
45+
}
46+
adaptivePrecision: true
3747
}
3848
}

xbot2_gui/Monitoring/Parameters.qml

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ Item {
3333
property alias loader: loader
3434
property bool busy: false
3535

36+
function set() {
37+
control.busy = !autoSwitch.checked
38+
Logic.setParams(control.name, loader.item.value)
39+
.then((res) => control.busy = false)
40+
}
41+
3642
id: control
3743
leftPadding: 10
3844
rightPadding: 10
@@ -61,11 +67,14 @@ Item {
6167
Button {
6268
text: 'Set'
6369
enabled: !control.busy
64-
onClicked: {
65-
control.busy = true
66-
Logic.setParams(control.name, loader.item.value)
67-
.then((res) => control.busy = false)
68-
}
70+
onClicked: control.set()
71+
}
72+
73+
Switch {
74+
text: 'Auto'
75+
enabled: !control.busy
76+
checked: false
77+
id: autoSwitch
6978
}
7079
}
7180

@@ -82,6 +91,16 @@ Item {
8291
opacity: control.busy ? 0.1 : 1
8392
}
8493

94+
Connections {
95+
target: loader.item
96+
ignoreUnknownSignals: false
97+
function onValueChangedByUser(value) {
98+
if(autoSwitch.checked) {
99+
control.set()
100+
}
101+
}
102+
}
103+
85104
BusyIndicator {
86105
running: control.busy
87106
anchors.centerIn: loader

0 commit comments

Comments
 (0)