diff --git a/src/FactSystem/FactControls/FactPanel.qml b/src/FactSystem/FactControls/FactPanel.qml index a6cacd55d1229b4ef5690ac5f9eed46f33c70c94..5343bc3e6b0f4030185c54f85bc8f13abb738142 100644 --- a/src/FactSystem/FactControls/FactPanel.qml +++ b/src/FactSystem/FactControls/FactPanel.qml @@ -31,18 +31,18 @@ import QGroundControl.FactSystem 1.0 import QGroundControl.Controls 1.0 import QGroundControl.Palette 1.0 -Rectangle { - color: qgcPal.window +FocusScope { + property alias color: rectangle.color - QGCPalette { id: qgcPal; colorGroupEnabled: enabled } + property string __missingParams: "" + property string __errorMsg: "" - property string __missingParams: "" - property string __errorMsg: "" + QGCPalette { id: qgcPal; colorGroupEnabled: enabled } function showMissingParameterOverlay(missingParamName) { - if (__missingParams.length != 0) { - __missingParams = __missingParams.concat(", ") - } + if (__missingParams.length != 0) { + __missingParams = __missingParams.concat(", ") + } __missingParams = __missingParams.concat(missingParamName) __missingParamsOverlay.visible = true } @@ -53,17 +53,22 @@ Rectangle { } Rectangle { - id: __missingParamsOverlay - anchors.fill: parent - z: 9999 - visible: false - color: qgcPal.window - opacity: 0.85 - - QGCLabel { + id: rectangle + color: qgcPal.window + + Rectangle { + id: __missingParamsOverlay anchors.fill: parent - wrapMode: Text.WordWrap - text: __errorMsg.length ? __errorMsg : "Parameters(s) missing: " + __missingParams + z: 9999 + visible: false + color: qgcPal.window + opacity: 0.85 + + QGCLabel { + anchors.fill: parent + wrapMode: Text.WordWrap + text: __errorMsg.length ? __errorMsg : "Parameters(s) missing: " + __missingParams + } } } } diff --git a/src/QmlControls/ParameterEditorDialog.qml b/src/QmlControls/ParameterEditorDialog.qml index 02146711daabe76b8c02d070fbf7358589d43a46..1efe2197923cd610c9a8d3c711df08f8d4f46270 100644 --- a/src/QmlControls/ParameterEditorDialog.qml +++ b/src/QmlControls/ParameterEditorDialog.qml @@ -58,8 +58,7 @@ QGCViewDialog { validationError.text = fact.validate(validateValue, false /* convertOnly */) forceSave.visible = true } - // This was causing problems where it would never give up focus even when hidden! - //valueField.forceActiveFocus() + valueField.forceActiveFocus() } Column { @@ -87,14 +86,6 @@ QGCViewDialog { // At this point all Facts are numeric inputMethodHints: Qt.ImhFormattedNumbersOnly - - onAccepted: accept() - - Keys.onReleased: { - if (event.key == Qt.Key_Escape) { - reject() - } - } } QGCLabel { text: fact.name } diff --git a/src/QmlControls/QGCTextField.qml b/src/QmlControls/QGCTextField.qml index 3d38a8e8100319f44fd3de02d543f4456500fb84..0c7b0f40baf9b7080f7d68c9b20da1c45182290b 100644 --- a/src/QmlControls/QGCTextField.qml +++ b/src/QmlControls/QGCTextField.qml @@ -6,9 +6,17 @@ import QGroundControl.Palette 1.0 import QGroundControl.ScreenTools 1.0 TextField { + id: root + property bool showUnits: false property string unitsLabel: "" + Component.onCompleted: { + if (typeof qgcTextFieldforwardKeysTo !== 'undefined') { + root.Keys.forwardTo = [qgcTextFieldforwardKeysTo] + } + } + property var __qgcPal: QGCPalette { colorGroupEnabled: enabled } textColor: __qgcPal.textFieldText diff --git a/src/QmlControls/QGCView.qml b/src/QmlControls/QGCView.qml index 359d4fc5615cab47c59ae75c6ea53c7c6a4efc0c..797d8033a51d0350040d5dca42642479f7b8eae9 100644 --- a/src/QmlControls/QGCView.qml +++ b/src/QmlControls/QGCView.qml @@ -146,6 +146,8 @@ FactPanel { viewPanel.enabled = false __dialogOverlay.visible = true + __dialogComponentLoader.item.forceActiveFocus() + __animateShowDialog.start() } @@ -166,10 +168,13 @@ FactPanel { viewPanel.enabled = false __dialogOverlay.visible = true + __dialogComponentLoader.item.forceActiveFocus() + __animateShowDialog.start() } function hideDialog() { + __dialogComponentLoader.item.focus = false viewPanel.enabled = true __animateHideDialog.start() } @@ -336,6 +341,9 @@ FactPanel { anchors.top: __spacer.bottom anchors.bottom: parent.bottom sourceComponent: __dialogComponent + + property bool acceptAllowed: __acceptButton.visible + property bool rejectAllowed: __rejectButton.visible } } // Rectangle - Dialog panel } // Item - Dialog overlay diff --git a/src/QmlControls/QGCViewDialog.qml b/src/QmlControls/QGCViewDialog.qml index 81cabcba2cad8032d7e9fd2120444d1bf3bad932..e827f599677e049300154d6d15264666887088da 100644 --- a/src/QmlControls/QGCViewDialog.qml +++ b/src/QmlControls/QGCViewDialog.qml @@ -34,18 +34,34 @@ import QGroundControl.FactSystem 1.0 import QGroundControl.FactControls 1.0 FactPanel { + property var qgcTextFieldforwardKeysTo: this ///< Causes all QGCTextFields to forward keys here if they have focus + QGCPalette { id: __qgcPal; colorGroupEnabled: enabled } signal hideDialog + Keys.onReleased: { + if (event.key == Qt.Key_Escape) { + reject() + event.accepted = true + } else if (event.key == Qt.Key_Return) { + accept() + event.accepted = true + } + } + function accept() { - Qt.inputMethod.hide() - hideDialog() + if (acceptAllowed) { + Qt.inputMethod.hide() + hideDialog() + } } function reject() { - Qt.inputMethod.hide() - hideDialog() + if (rejectAllowed) { + Qt.inputMethod.hide() + hideDialog() + } } color: __qgcPal.windowShadeDark