overte-JulianGro/interface/resources/qml/dialogs/preferences/SpinBoxPreference.qml
Phil Palmer 3b5eb2d24b Partial fix for spinner boxes not using the _step property of SpinnerPreference.
(https://github.com/vircadia/vircadia/issues/117)
- In SpinBoxPreference.qml, SpinBox was missing "realStepSize: preference.step".
- Had to change FloatPreference::step from float to double, because there is some truncation happening somewhere.  For example, a step of 0.01f was acting like 0.00 because (0.01f < 0.01).
- Changed FloatPreference::decimals (number of decimal places) from float to uint, because it seemed to make more sense.
- Changed the 'User real-world height' spinbox to use a resolution of 1cm (for display and step) rather than 1mm.
- Remaining bug: the up & down buttons of the spinbox fail to change the value, at some values, though the mouse wheel always works.  Repro:
Settings > Controls > User real-world height
Hover the mouse over the box and and scroll the mouse wheel down until the value is at 1.15.
Click the up button a few times and observe that the number can't be increased.
Scroll the mouse wheel forward and observe that the number increases correctly.
- Todo: Change all calls to FloatPreference::setStep to pass doubles, if this change to its parameter type is kept.
2020-12-23 22:53:43 -05:00

62 lines
1.5 KiB
QML

//
// SpinBoxPreference.qml
//
// Created by Bradley Austin Davis on 18 Jan 2016
// Copyright 2016 High Fidelity, Inc.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
import QtQuick 2.5
import controlsUit 1.0
Preference {
id: root
property alias spinner: spinner
height: control.height + hifi.dimensions.controlInterlineHeight
Component.onCompleted: {
spinner.realValue = preference.value;
}
function save() {
preference.value = spinner.realValue;
preference.save();
}
Row {
id: control
anchors {
bottom: parent.bottom
}
height: Math.max(spinnerLabel.height, spinner.controlHeight)
Label {
id: spinnerLabel
text: root.label + ":"
colorScheme: hifi.colorSchemes.dark
anchors {
verticalCenter: parent.verticalCenter
}
horizontalAlignment: Text.AlignRight
wrapMode: Text.Wrap
}
spacing: hifi.dimensions.labelPadding
SpinBox {
id: spinner
decimals: preference.decimals
minimumValue: preference.min
maximumValue: preference.max
realStepSize: preference.step
width: 100
anchors {
verticalCenter: parent.verticalCenter
}
colorScheme: hifi.colorSchemes.dark
}
}
}