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