Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remote ID: Fix validation #12247

Merged
merged 4 commits into from
Dec 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions src/QmlControls/QGCTextField.qml
Original file line number Diff line number Diff line change
Expand Up @@ -53,25 +53,31 @@ TextField {
if (validationError) {
validationToolTip.visible = true
}
} else {
validationToolTip.visible = false
}
}

function showValidationError(errorString, originalValidValue = undefined) {
function showValidationError(errorString, originalValidValue = undefined, preventViewSiwtch = true) {
validationToolTip.text = errorString
validationToolTip.originalValidValue = originalValidValue
validationToolTip.visible = true
if (!validationError) {
validationError = true
globals.validationErrorCount++
if (preventViewSiwtch) {
globals.validationErrorCount++
}
}
}

function clearValidationError() {
function clearValidationError(preventViewSiwtch = true) {
validationToolTip.visible = false
validationToolTip.originalValidValue = undefined
if (validationError) {
validationError = false
globals.validationErrorCount--
if (preventViewSiwtch) {
globals.validationErrorCount--
}
}
}

Expand Down
14 changes: 12 additions & 2 deletions src/UI/preferences/RemoteIDSettings.qml
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,6 @@ SettingsPage {
SettingsGroupLayout {
heading: qsTr("Operator ID")
Layout.fillWidth: true
outerBorderColor: (_regionOperation === RemoteIDSettings.RegionOperation.EU || remoteIDSettings.sendOperatorID.value) ?
(_activeRID && !_remoteIDManager.operatorIDGood ? qgcPal.colorRed : defaultBorderColor) : defaultBorderColor

FactCheckBoxSlider {
text: qsTr("Broadcast%1").arg(isEURegion ? " (EU Required)" : "")
Expand Down Expand Up @@ -375,12 +373,24 @@ SettingsPage {
}

QGCTextField {
id: operatorIDTextField
Layout.preferredWidth: textFieldWidth
Layout.fillWidth: true
text: operatorIDFact.valueString
visible: operatorIDFact.visible
maximumLength: 20 // Maximum defined by Mavlink definition of OPEN_DRONE_ID_OPERATOR_ID message

property bool operatorIDInvalid: ((_regionOperation === RemoteIDSettings.RegionOperation.EU || remoteIDSettings.sendOperatorID.value) &&
_activeRID && !_remoteIDManager.operatorIDGood)

onOperatorIDInvalidChanged: {
if (operatorIDInvalid) {
operatorIDTextField.showValidationError(qsTr("Invalid Operator ID"), operatorIDFact.valueString, false /* preventViewSwitch */)
} else {
operatorIDTextField.clearValidationError(false /* preventViewSwitch */)
}
}

onTextChanged: {
operatorIDFact.value = text
if (_activeVehicle) {
Expand Down
Loading