11import org.kde.ksysguard.formatter as Formatter
12import org.kde.ksysguard.sensors as Sensors
27 property alias from: spinBox.from
31 property alias to: spinBox.to
43 property real multiplier
47 property alias sensors: unitModel.sensors
51 signal valueModified()
53 implicitWidth: leftPadding + spinBox.implicitWidth + comboBox.implicitWidth + rightPadding
54 implicitHeight: topPadding + Math.max(spinBox.implicitHeight, comboBox.implicitHeight) + bottomPadding
61 contentItem: RowLayout {
67 Layout.fillWidth: true
68 Layout.preferredWidth: 0
71 from: Math.pow(-2, 31) + 1
72 to: Math.pow(2, 31) - 1
75 value: control.value * 100
80 value: spinBox.value / 100
83 validator: DoubleValidator {
84 locale: spinBox.locale.name
85 bottom: Math.min(spinBox.from, spinBox.to)
86 top: Math.max(spinBox.from, spinBox.to)
89 textFromValue: function(value, locale) {
96 let realValue = value / 100
97 let fract = realValue - Math.trunc(realValue)
103 if ((fract * 10) - Math.trunc(fract * 10) != 0) {
107 return Number(value / 100).toLocaleString(locale,
'f', digits)
110 valueFromText: function(text, locale) {
111 return Number.fromLocaleString(locale, text) * 100
114 onValueModified: control.valueModified()
120 Layout.fillWidth:
true
121 Layout.preferredWidth: 0
123 visible: unitModel.sensors.length > 0
131 control.unit = currentValue
132 control.multiplier = model.data(model.index(currentIndex, 0), Sensors.SensorUnitModel.MultiplierRole)
133 control.valueModified()
136 Component.onCompleted: updateCurrentIndex()
138 model: Sensors.SensorUnitModel {
140 onReadyChanged: comboBox.updateCurrentIndex()
143 function updateCurrentIndex() {
144 if (unitModel.ready && control.unit >= 0) {
145 currentIndex = indexOfValue(control.unit)