diff options
author | Nicolas Werner <nicolas.werner@hotmail.de> | 2022-01-13 05:51:57 +0100 |
---|---|---|
committer | Nicolas Werner <nicolas.werner@hotmail.de> | 2022-01-13 05:52:31 +0100 |
commit | c59bb67569bfe997f33410a6dafd2ef31749cd73 (patch) | |
tree | 35a27349705c74aab7c5a89a523ec4e42c769fe5 /resources | |
parent | Small size and selection improvements for the settings page (diff) | |
download | nheko-c59bb67569bfe997f33410a6dafd2ef31749cd73.tar.xz |
Fix setting double values in setting spinboxes
Diffstat (limited to 'resources')
-rw-r--r-- | resources/qml/pages/UserSettingsPage.qml | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/resources/qml/pages/UserSettingsPage.qml b/resources/qml/pages/UserSettingsPage.qml index 3701784d..71a90a27 100644 --- a/resources/qml/pages/UserSettingsPage.qml +++ b/resources/qml/pages/UserSettingsPage.qml @@ -118,7 +118,7 @@ Rectangle { } } DelegateChoice { - roleValue: UserSettingsModel.Number + roleValue: UserSettingsModel.Integer SpinBox { anchors.right: parent.right @@ -129,6 +129,42 @@ Rectangle { stepSize: model.valueStep value: model.value onValueChanged: model.value = value + editable: true + } + } + DelegateChoice { + roleValue: UserSettingsModel.Double + + SpinBox { + id: spinbox + + readonly property double div: 100 + readonly property int decimals: 2 + + anchors.right: parent.right + width: Math.min(parent.width, implicitWidth) + enabled: !deadTimer.running && model.enabled + from: model.valueLowerBound * div + to: model.valueUpperBound * div + stepSize: model.valueStep * div + value: model.value * div + onValueChanged: model.value = value/div + editable: true + + property real realValue: value / div + + validator: DoubleValidator { + bottom: Math.min(spinbox.from/spinbox.div, spinbox.to/spinbox.div) + top: Math.max(spinbox.from/spinbox.div, spinbox.to/spinbox.div) + } + + textFromValue: function(value, locale) { + return Number(value / spinbox.div).toLocaleString(locale, 'f', spinbox.decimals) + } + + valueFromText: function(text, locale) { + return Number.fromLocaleString(locale, text) * spinbox.div + } } } DelegateChoice { |