Files
qt-creator/share/qtcreator/qmldesigner/effectComposerQmlSources/ValueFloat.qml
Miikka Heikkinen df20f8924a EffectComposer: Fix slider value precision
Effects with slider controlled real values now properly cut the values
to two decimals.

Fixes: QDS-11773
Change-Id: I056a295e5a126536d3003490c938361e4ce382b3
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
2024-05-03 12:59:49 +00:00

51 lines
1.4 KiB
QML

// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
import QtQuick
import HelperWidgets as HelperWidgets
import StudioControls as StudioControls
import StudioTheme as StudioTheme
import EffectComposerBackend
Row {
width: parent.width
spacing: 5
HelperWidgets.DoubleSpinBox {
id: spinBox
// value: uniformValue binding can get overwritten by normal operation of the control
property double resetValue: uniformValue
onResetValueChanged: value = resetValue
width: 60
spinBoxIndicatorVisible: false
inputHAlignment: Qt.AlignHCenter
minimumValue: uniformMinValue
maximumValue: uniformMaxValue
value: uniformValue
stepSize: .01
decimals: 2
onValueModified: uniformValue = value
}
StudioControls.Slider {
id: slider
width: parent.width - 100
visible: width > 20
labels: false
decimals: 2
actionIndicatorVisible: false
handleLabelVisible: false
from: uniformMinValue
to: uniformMaxValue
value: uniformValue
onMoved: {
let fixedValue = Number.parseFloat(value).toFixed(slider.decimals)
uniformValue = fixedValue
spinBox.value = fixedValue // binding isn't working for this property so update it
}
}
}