go back to using a slider instead of the spinner

This commit is contained in:
Michael Zanetti 2019-01-24 23:33:24 +01:00
parent cea41bdbcc
commit 6b95be2e40
2 changed files with 22 additions and 2 deletions

View File

@ -10,6 +10,9 @@ Item {
property alias from: slider.from
property alias to: slider.to
property alias stepSize: slider.stepSize
readonly property real rawValue: slider.value
signal moved(real value);
Slider {

View File

@ -113,11 +113,13 @@ DevicePageBase {
Label {
Layout.fillWidth: true
Layout.minimumWidth: parent.width / 2
text: stateDelegate.stateType.displayName
elide: Text.ElideRight
}
Loader {
id: stateDelegateLoader
Layout.fillWidth: true
sourceComponent: {
switch (stateType.type.toLowerCase()) {
case "string":
@ -144,7 +146,8 @@ DevicePageBase {
}
if (stateDelegate.writable) {
return spinBoxComponent;
return sliderComponent;
// return spinBoxComponent;
}
return numberLabelComponent;
case "color":
@ -157,6 +160,11 @@ DevicePageBase {
}
}
Label {
visible: stateDelegateLoader.sourceComponent === sliderComponent
text: stateDelegate.deviceState.value
}
Label {
visible: stateDelegate.stateType.unit !== Types.UnitUnixTime && stateDelegate.stateType.unitString.length > 0
text: stateDelegate.stateType.unitString
@ -412,7 +420,7 @@ DevicePageBase {
SpinBox {
width: 150
signal changed(var value)
stepSize: (to - from) / 10
stepSize: (to - from) / 20
editable: true
onValueModified: {
changed(value)
@ -420,6 +428,15 @@ DevicePageBase {
}
}
Component {
id: sliderComponent
ThrottledSlider {
signal changed(var value)
stepSize: 1
onMoved: changed(value)
}
}
Component {
id: comboBoxComponent
ComboBox {