mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 08:49:05 +02:00
Merge pull request #1161 from ctrlaltdavid/fix/spinbox
Fix settings (QML) spin box stepping
This commit is contained in:
commit
3629427cff
5 changed files with 17 additions and 15 deletions
|
@ -73,9 +73,9 @@ SpinBox {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
stepSize: realStepSize * factor
|
stepSize: Math.round(realStepSize * factor)
|
||||||
to : realTo*factor
|
to : Math.round(realTo*factor)
|
||||||
from : realFrom*factor
|
from : Math.round(realFrom*factor)
|
||||||
|
|
||||||
font.family: "Fira Sans SemiBold"
|
font.family: "Fira Sans SemiBold"
|
||||||
font.pixelSize: hifi.fontSizes.textFieldInput
|
font.pixelSize: hifi.fontSizes.textFieldInput
|
||||||
|
@ -97,11 +97,11 @@ SpinBox {
|
||||||
}
|
}
|
||||||
|
|
||||||
textFromValue: function(value, locale) {
|
textFromValue: function(value, locale) {
|
||||||
return parseFloat(value / factor).toFixed(decimals);
|
return (value / factor).toFixed(decimals);
|
||||||
}
|
}
|
||||||
|
|
||||||
valueFromText: function(text, locale) {
|
valueFromText: function(text, locale) {
|
||||||
return Number.fromLocaleString(locale, text) * factor;
|
return Math.round(Number.fromLocaleString(locale, text) * factor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -51,6 +51,7 @@ Preference {
|
||||||
decimals: preference.decimals
|
decimals: preference.decimals
|
||||||
minimumValue: preference.min
|
minimumValue: preference.min
|
||||||
maximumValue: preference.max
|
maximumValue: preference.max
|
||||||
|
realStepSize: preference.step
|
||||||
width: 100
|
width: 100
|
||||||
anchors {
|
anchors {
|
||||||
verticalCenter: parent.verticalCenter
|
verticalCenter: parent.verticalCenter
|
||||||
|
|
|
@ -76,6 +76,7 @@ Preference {
|
||||||
realValue: preference.value
|
realValue: preference.value
|
||||||
minimumValue: preference.min
|
minimumValue: preference.min
|
||||||
maximumValue: preference.max
|
maximumValue: preference.max
|
||||||
|
realStepSize: preference.step
|
||||||
width: 100
|
width: 100
|
||||||
onValueChanged: {
|
onValueChanged: {
|
||||||
slider.value = realValue;
|
slider.value = realValue;
|
||||||
|
|
|
@ -362,10 +362,10 @@ void setupPreferences() {
|
||||||
auto getter = [myAvatar]()->float { return qApp->getCamera().getSensitivity(); };
|
auto getter = [myAvatar]()->float { return qApp->getCamera().getSensitivity(); };
|
||||||
auto setter = [myAvatar](float value) { qApp->getCamera().setSensitivity(value); };
|
auto setter = [myAvatar](float value) { qApp->getCamera().setSensitivity(value); };
|
||||||
auto preference = new SpinnerSliderPreference(VR_MOVEMENT, "Camera Sensitivity", getter, setter);
|
auto preference = new SpinnerSliderPreference(VR_MOVEMENT, "Camera Sensitivity", getter, setter);
|
||||||
preference->setMin(0.01f);
|
preference->setMin(0.1f);
|
||||||
preference->setMax(5.0f);
|
preference->setMax(5.0f);
|
||||||
preference->setStep(0.1f);
|
preference->setStep(0.1f);
|
||||||
preference->setDecimals(2);
|
preference->setDecimals(1);
|
||||||
preferences->addPreference(preference);
|
preferences->addPreference(preference);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
|
@ -385,7 +385,7 @@ void setupPreferences() {
|
||||||
preference->setMin(6.0f);
|
preference->setMin(6.0f);
|
||||||
preference->setMax(30.0f);
|
preference->setMax(30.0f);
|
||||||
preference->setStep(1);
|
preference->setStep(1);
|
||||||
preference->setDecimals(2);
|
preference->setDecimals(0);
|
||||||
preferences->addPreference(preference);
|
preferences->addPreference(preference);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
|
@ -465,8 +465,8 @@ void setupPreferences() {
|
||||||
auto preference = new SpinnerPreference(VR_MOVEMENT, "User real-world height (meters)", getter, setter);
|
auto preference = new SpinnerPreference(VR_MOVEMENT, "User real-world height (meters)", getter, setter);
|
||||||
preference->setMin(1.0f);
|
preference->setMin(1.0f);
|
||||||
preference->setMax(2.2f);
|
preference->setMax(2.2f);
|
||||||
preference->setDecimals(3);
|
preference->setDecimals(2);
|
||||||
preference->setStep(0.001f);
|
preference->setStep(0.01f);
|
||||||
preferences->addPreference(preference);
|
preferences->addPreference(preference);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -478,7 +478,7 @@ void setupPreferences() {
|
||||||
preference->setMin(1.0f);
|
preference->setMin(1.0f);
|
||||||
preference->setMax(360.0f);
|
preference->setMax(360.0f);
|
||||||
preference->setStep(1);
|
preference->setStep(1);
|
||||||
preference->setDecimals(1);
|
preference->setDecimals(0);
|
||||||
preferences->addPreference(preference);
|
preferences->addPreference(preference);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
|
@ -488,7 +488,7 @@ void setupPreferences() {
|
||||||
preference->setMin(1.0f);
|
preference->setMin(1.0f);
|
||||||
preference->setMax(360.0f);
|
preference->setMax(360.0f);
|
||||||
preference->setStep(1);
|
preference->setStep(1);
|
||||||
preference->setDecimals(1);
|
preference->setDecimals(0);
|
||||||
preferences->addPreference(preference);
|
preferences->addPreference(preference);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -153,7 +153,7 @@ class FloatPreference : public Preference {
|
||||||
Q_PROPERTY(float min READ getMin CONSTANT)
|
Q_PROPERTY(float min READ getMin CONSTANT)
|
||||||
Q_PROPERTY(float max READ getMax CONSTANT)
|
Q_PROPERTY(float max READ getMax CONSTANT)
|
||||||
Q_PROPERTY(float step READ getStep CONSTANT)
|
Q_PROPERTY(float step READ getStep CONSTANT)
|
||||||
Q_PROPERTY(float decimals READ getDecimals CONSTANT)
|
Q_PROPERTY(uint decimals READ getDecimals CONSTANT)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
using Getter = std::function<float()>;
|
using Getter = std::function<float()>;
|
||||||
|
@ -194,10 +194,10 @@ protected:
|
||||||
const Getter _getter;
|
const Getter _getter;
|
||||||
const Setter _setter;
|
const Setter _setter;
|
||||||
|
|
||||||
float _decimals { 0 };
|
uint _decimals { 0 };
|
||||||
float _min { 0 };
|
float _min { 0 };
|
||||||
float _max { 1 };
|
float _max { 1 };
|
||||||
float _step { 0.1f };
|
float _step { 1 };
|
||||||
};
|
};
|
||||||
|
|
||||||
class IntPreference : public Preference {
|
class IntPreference : public Preference {
|
||||||
|
|
Loading…
Reference in a new issue