From df34d8dcc0b26ba7955571c17fb2c926ece16b70 Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Fri, 30 Nov 2018 14:51:44 -0800 Subject: [PATCH] fix spinbox and adjusting OpenVrConfiguration spin boxes --- .../resources/qml/controlsUit/SpinBox.qml | 41 ++++++++++++++----- .../qml/hifi/tablet/OpenVrConfiguration.qml | 18 +++----- 2 files changed, 37 insertions(+), 22 deletions(-) diff --git a/interface/resources/qml/controlsUit/SpinBox.qml b/interface/resources/qml/controlsUit/SpinBox.qml index 34794d80c7..564157efb0 100644 --- a/interface/resources/qml/controlsUit/SpinBox.qml +++ b/interface/resources/qml/controlsUit/SpinBox.qml @@ -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 diff --git a/interface/resources/qml/hifi/tablet/OpenVrConfiguration.qml b/interface/resources/qml/hifi/tablet/OpenVrConfiguration.qml index a2104826c3..a9d67fec35 100644 --- a/interface/resources/qml/hifi/tablet/OpenVrConfiguration.qml +++ b/interface/resources/qml/hifi/tablet/OpenVrConfiguration.qml @@ -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"];