mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
Merge pull request #14511 from danteruiz/spinbox-fixes
case 20100: fix SpinBox.qml in ControlsUit and adjusting OpenVrConfiguration SpinBoxes
This commit is contained in:
commit
fe874ca5b1
2 changed files with 37 additions and 22 deletions
|
@ -57,16 +57,23 @@ SpinBox {
|
|||
|
||||
locale: Qt.locale("en_US")
|
||||
|
||||
onValueModified: realValue = value/factor
|
||||
onValueChanged: realValue = value/factor
|
||||
onValueModified: {
|
||||
realValue = value / factor
|
||||
}
|
||||
|
||||
onValueChanged: {
|
||||
realValue = value / factor
|
||||
spinBox.editingFinished();
|
||||
}
|
||||
|
||||
onRealValueChanged: {
|
||||
var newValue = Math.round(realValue*factor);
|
||||
var newValue = Math.round(realValue * factor);
|
||||
if(value != newValue) {
|
||||
value = newValue;
|
||||
}
|
||||
}
|
||||
|
||||
stepSize: realStepSize*factor
|
||||
stepSize: realStepSize * factor
|
||||
to : realTo*factor
|
||||
from : realFrom*factor
|
||||
|
||||
|
@ -90,11 +97,11 @@ SpinBox {
|
|||
}
|
||||
|
||||
textFromValue: function(value, locale) {
|
||||
return parseFloat(value/factor).toFixed(decimals);
|
||||
return parseFloat(value / factor).toFixed(decimals);
|
||||
}
|
||||
|
||||
valueFromText: function(text, locale) {
|
||||
return Number.fromLocaleString(locale, text)*factor;
|
||||
return Number.fromLocaleString(locale, text) * factor;
|
||||
}
|
||||
|
||||
|
||||
|
@ -102,7 +109,7 @@ SpinBox {
|
|||
id: spinboxText
|
||||
z: 2
|
||||
color: isLightColorScheme
|
||||
? (spinBox.activeFocus ? hifi.colors.black : hifi.colors.lightGray)
|
||||
? (spinBox.activeFocus ? hifi.colors.black : hifi.colors.faintGray)
|
||||
: (spinBox.activeFocus ? hifi.colors.white : hifi.colors.lightGrayText)
|
||||
selectedTextColor: hifi.colors.black
|
||||
selectionColor: hifi.colors.primaryHighlight
|
||||
|
@ -112,8 +119,6 @@ SpinBox {
|
|||
verticalAlignment: Qt.AlignVCenter
|
||||
leftPadding: spinBoxLabelInside.visible ? 30 : hifi.dimensions.textPadding
|
||||
width: spinBox.width - hifi.dimensions.spinnerSize
|
||||
onEditingFinished: spinBox.editingFinished()
|
||||
|
||||
Text {
|
||||
id: suffixText
|
||||
x: metrics.advanceWidth(spinboxText.text + '*')
|
||||
|
@ -125,7 +130,7 @@ SpinBox {
|
|||
}
|
||||
|
||||
color: isLightColorScheme
|
||||
? (spinBox.activeFocus ? hifi.colors.black : hifi.colors.lightGray)
|
||||
? (spinBox.activeFocus ? hifi.colors.black : hifi.colors.faintGray)
|
||||
: (spinBox.activeFocus ? hifi.colors.white : hifi.colors.lightGrayText)
|
||||
text: suffix
|
||||
verticalAlignment: Qt.AlignVCenter
|
||||
|
@ -170,6 +175,22 @@ SpinBox {
|
|||
}
|
||||
}
|
||||
|
||||
Keys.onPressed: {
|
||||
if (event.key === Qt.Key_Return) {
|
||||
if (!spinboxText.acceptableInput) {
|
||||
var number = spinBox.valueFromText(spinboxText.text, spinBox.locale) / spinBox.factor
|
||||
|
||||
if (number < spinBox.minimumValue) {
|
||||
number = spinBox.minimumValue;
|
||||
} else if (number > maximumValue) {
|
||||
number = spinBox.maximumValue;
|
||||
}
|
||||
|
||||
spinboxText.text = spinBox.textFromValue(Math.round(number * factor), spinBox.locale)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
HifiControls.Label {
|
||||
id: spinBoxLabel
|
||||
text: spinBox.label
|
||||
|
|
|
@ -70,7 +70,7 @@ Flickable {
|
|||
readonly property bool hmdDesktop: hmdInDesktop.checked
|
||||
|
||||
property int state: buttonState.disabled
|
||||
property var lastConfiguration: null
|
||||
property var lastConfiguration: null
|
||||
|
||||
HifiConstants { id: hifi }
|
||||
|
||||
|
@ -90,7 +90,6 @@ Flickable {
|
|||
anchors.fill: parent
|
||||
propagateComposedEvents: true
|
||||
onPressed: {
|
||||
parent.forceActiveFocus()
|
||||
mouse.accepted = false;
|
||||
}
|
||||
}
|
||||
|
@ -169,9 +168,7 @@ Flickable {
|
|||
boxRadius: 7
|
||||
visible: viveInDesktop.checked
|
||||
|
||||
anchors.top: viveInDesktop.bottom
|
||||
anchors.topMargin: 5
|
||||
anchors.left: openVrConfiguration.left
|
||||
anchors.leftMargin: leftMargin + 10
|
||||
|
||||
onClicked: {
|
||||
|
@ -214,13 +211,13 @@ Flickable {
|
|||
|
||||
onRealValueChanged: {
|
||||
sendConfigurationSettings();
|
||||
openVrConfiguration.forceActiveFocus();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
HifiControls.SpinBox {
|
||||
id: headZOffset
|
||||
z: 10
|
||||
width: 112
|
||||
label: "Z Offset"
|
||||
minimumValue: -50
|
||||
|
@ -232,7 +229,6 @@ Flickable {
|
|||
|
||||
onRealValueChanged: {
|
||||
sendConfigurationSettings();
|
||||
openVrConfiguration.forceActiveFocus();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -326,7 +322,6 @@ Flickable {
|
|||
|
||||
onRealValueChanged: {
|
||||
sendConfigurationSettings();
|
||||
openVrConfiguration.forceActiveFocus();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -344,7 +339,6 @@ Flickable {
|
|||
|
||||
onRealValueChanged: {
|
||||
sendConfigurationSettings();
|
||||
openVrConfiguration.forceActiveFocus();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -578,7 +572,6 @@ Flickable {
|
|||
|
||||
onRealValueChanged: {
|
||||
sendConfigurationSettings();
|
||||
openVrConfiguration.forceActiveFocus();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -596,7 +589,6 @@ Flickable {
|
|||
|
||||
onRealValueChanged: {
|
||||
sendConfigurationSettings();
|
||||
openVrConfiguration.forceActiveFocus();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -747,8 +739,8 @@ Flickable {
|
|||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
InputConfiguration.calibrationStatus.connect(calibrationStatusInfo);
|
||||
lastConfiguration = composeConfigurationSettings();
|
||||
InputConfiguration.calibrationStatus.connect(calibrationStatusInfo);
|
||||
}
|
||||
|
||||
Component.onDestruction: {
|
||||
|
@ -777,7 +769,6 @@ Flickable {
|
|||
calibrationTimer.interval = realValue * 1000;
|
||||
openVrConfiguration.countDown = realValue;
|
||||
numberAnimation.duration = calibrationTimer.interval;
|
||||
openVrConfiguration.forceActiveFocus();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1048,6 +1039,9 @@ Flickable {
|
|||
}
|
||||
|
||||
function updateButtonState() {
|
||||
if (lastConfiguration === null) {
|
||||
lastConfiguration = composeConfigurationSettings();
|
||||
}
|
||||
var settings = composeConfigurationSettings();
|
||||
var bodySetting = settings["bodyConfiguration"];
|
||||
var headSetting = settings["headConfiguration"];
|
||||
|
|
Loading…
Reference in a new issue