Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,23 @@
"label": "Return altitude",
"optional": true,
"enableWhen": "_planeRtlAltFact && _planeRtlAltFact.value >= 0"
},
{
"param": "RTL_RADIUS",
"label": "Loiter radius",
"optional": true
Copy link

Copilot AI Mar 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RTL_RADIUS is marked optional, but the generated LabelledFactTextField will still be enabled/visible even when getParameterFact(..., false) returns null. In that case, editing the field can trigger a QML runtime error (FactTextField calls fact.validate(...) unconditionally). Consider adding a showWhen/enableWhen gate based on parameter existence (e.g., controller.parameterExists(-1, "RTL_RADIUS")) so the field is hidden/disabled when the param is missing.

Suggested change
"optional": true
"optional": true,
"showWhen": "controller.parameterExists(-1, 'RTL_RADIUS')"

Copilot uses AI. Check for mistakes.
},
{
"control": "label",
"label": "0 = use Waypoint Loiter Radius (WP_LOITER_RAD), negative = counter-clockwise",
"indent": true,
"smallFont": true
Copy link

Copilot AI Mar 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The helper label is always shown. If RTL_RADIUS is missing (optional param), this note becomes orphaned. Consider adding a showWhen gate (e.g., controller.parameterExists(-1, "RTL_RADIUS")) so the helper text only appears when the related control can be shown.

Suggested change
"smallFont": true
"smallFont": true,
"showWhen": "controller.parameterExists(-1, 'RTL_RADIUS')"

Copilot uses AI. Check for mistakes.
},
{
"param": "RTL_AUTOLAND",
"label": "Auto land after RTL",
"optional": true,
"control": "combobox"
Copy link

Copilot AI Mar 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RTL_AUTOLAND is marked optional but the combobox is always rendered. Consider adding a showWhen/enabled condition based on controller.parameterExists(-1, "RTL_AUTOLAND") to avoid showing an empty control when the parameter isn’t present.

Suggested change
"control": "combobox"
"control": "combobox",
"showWhen": "controller.parameterExists(-1, 'RTL_AUTOLAND')"

Copilot uses AI. Check for mistakes.
}
]
},
Expand Down
3 changes: 3 additions & 0 deletions tools/generators/common/controls.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ def render_label(
*,
text: str = "",
warning: bool = False,
small_font: bool = False,
tr_context: str = "",
) -> str:
"""Render a static ``QGCLabel`` (no fact binding)."""
Expand All @@ -98,6 +99,8 @@ def render_label(
lines.append(f"{indent} wrapMode: Text.WordWrap")
lines.append(f"{indent} Layout.fillWidth: true")
lines.append(f"{indent} Layout.preferredWidth: 0")
if small_font:
lines.append(f"{indent} font.pointSize: ScreenTools.smallFontPointSize")
if warning:
Comment on lines 100 to 104
Copy link

Copilot AI Mar 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new small_font branch in render_label changes generated QML output but isn’t covered by tests. Since the repo has pytest coverage for other generators, consider adding a small unit test that asserts the font.pointSize: ScreenTools.smallFontPointSize line is present when small_font=True and absent otherwise.

Copilot uses AI. Check for mistakes.
lines.append(f"{indent} color: qgcPal.warningText")
lines.append(f"{indent}}}")
Expand Down
3 changes: 3 additions & 0 deletions tools/generators/config_qml/page_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ class ControlDef:
firstEntryIsAll: bool = False # bitmask: first entry is "all" toggle
toggleCheckbox: ToggleCheckboxDef | None = None # toggleCheckbox: custom checked/onClicked
indent: bool = False # indent control with left margin
smallFont: bool = False # label: use small font size


@dataclass
Expand Down Expand Up @@ -168,6 +169,7 @@ def load_page_def(json_path: Path) -> PageDef:
firstEntryIsAll=ctrl_data.get("firstEntryIsAll", False),
toggleCheckbox=parse_toggle_checkbox(ctrl_data.get("toggleCheckbox")),
indent=ctrl_data.get("indent", False),
smallFont=ctrl_data.get("smallFont", False),
))
repeat_data = sec_data.get("repeat")
repeat_def = None
Expand Down Expand Up @@ -339,6 +341,7 @@ def _apply_indent(qml: str) -> str:
indent,
text=ctrl.label,
warning=ctrl.warning,
small_font=ctrl.smallFont,
tr_context=tr_context,
)
if ctrl.showWhen:
Expand Down
Loading