adjusted brightness qml slider behaviour

This commit is contained in:
ykeara
2019-04-11 21:18:53 -05:00
parent 5d41c7757f
commit 9b49191f95
@@ -34,58 +34,53 @@ GroupBox {
MyToggleButton { MyToggleButton {
id: brightnessToggle id: brightnessToggle
text: "Toggle Brightness Adjustment" text: "Toggle On/Off"
onCheckedChanged: { onCheckedChanged: {
VideoTabController.setBrightnessEnabled(this.checked, false) } VideoTabController.setBrightnessEnabled(this.checked, false) }
} }
//Item { Item {
// Layout.fillWidth: true Layout.preferredWidth: 150
//} }
MyText { MyText {
text: "Brightness:" text: "Value :"
horizontalAlignment: Text.AlignRight horizontalAlignment: Text.AlignRight
Layout.rightMargin: 10 Layout.rightMargin: 10
} }
MySlider { MySlider {
id: brightnessSlider id: brightnessSlider
from: 0.00 from: 0.05
to: 1.0 to: 1.0
stepSize: 0.01 stepSize: 0.01
value: 1.0 value: 1.0
Layout.fillWidth: true
onPositionChanged: { onPositionChanged: {
var val = (this.position * 100)/2 var val = (this.position * 100)/2
brightnessValueText.text = Math.round(val) + "%" brightnessValueText.text = Math.round(val) + "%"
} }
onValueChanged: { onValueChanged: {
//TODO change value
VideoTabController.setBrightnessValue(value.toFixed(2), false) VideoTabController.setBrightnessValue(value.toFixed(2), false)
} }
} }
MyTextField { MyTextField {
id: brightnessValueText id: brightnessValueText
text: "100.00" text: "100%"
keyBoardUID: 301
Layout.preferredWidth: 100 Layout.preferredWidth: 100
Layout.leftMargin: 10 Layout.leftMargin: 10
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignHCenter
function onInputEvent(input) { function onInputEvent(input) {
var val = parseFloat(input) var val = parseFloat(input)
if (!isNaN(val)) { if (!isNaN(val)) {
if (val < 0.0) { if (val < 5) {
val = 0 val = 5
} else if (val > 100.0) { } else if (val > 100.0) {
val = 100.0 val = 100.0
} }
var v = (val/100).toFixed(2) var v = (val/100).toFixed(2)
if (v <= brightnessSlider.to) { brightnessSlider.value = v
brightnessSlider.value = v
} else {
VideoTabController.setBrightnessValue(v, false)
}
} }
text = Math.round(VideoTabController.boundsVisibility * 100) + "%" text = Math.round(VideoTabController.boundsVisibility * 100) + "%"
} }