Generated Settings Pages
This page explains how the new Application Settings pages are generated and how to extend them.
Architecture Overview
The runtime stack is:
- Fact metadata in
src/Settings/*.SettingsGroup.json - Settings Fact accessors in
src/Settings/*Settings.h/.cc - Settings UI page definitions in
src/UI/AppSettings/pages/*.SettingsUI.json - Page list in
src/UI/AppSettings/pages/SettingsPages.json - Python generator in
tools/generators/settings_qml - Generated QML loaded by
src/QmlControls/AppSettings.qml
At build time, CMake runs the generator and places generated QML in the build tree. Those files are then compiled into the QGroundControl.AppSettings QML module.
Where Generation Is Wired
Generation is configured in src/UI/AppSettings/CMakeLists.txt:
- Custom command runs:
python -m tools.generators.settings_qml.generate_pages --output-dir <build>/generated
- Inputs:
src/UI/AppSettings/pages/*.jsonsrc/Settings/*.SettingsGroup.json
- Outputs:
- Generated page QML files (for example
AppSettings.qml,FlyViewSettings.qml, ...) SettingsPagesModel.qml
- Generated page QML files (for example
The generator entry point is tools/generators/settings_qml/generate_pages.py, with most logic in tools/generators/settings_qml/page_generator.py.
JSON Files and Their Roles
SettingsPages.jsoncontrols sidebar/page registration:
- Page name
- Icon
- Generated QML file name (
qml) - Source page definition JSON (
pageDefinition) - Optional visibility expression (
visible) - Optional divider entries
<Page>.SettingsUI.jsoncontrols page content:
bindings: reusable QML expressionsgroups: section blocks- Group options:
headingsectionName(sidebar label override)showWhen,enableWhencomponent(embed a custom QML component)keywords(for search on component-only groups)
- Control options:
setting(required), format:<settingsManager accessor>.<factName>- Optional
controloverride (checkbox,combobox,textfield,slider,browse,scaler) - Optional
label,showWhen,enableWhen,placeholder - Slider-specific
enableCheckboxandbutton
*.SettingsGroup.jsonprovides Fact metadata used by both runtime and generation:
- Type
- Label/descriptions
- Enum values
- Visibility/user visibility
- Search
keywords
How Controls Are Chosen
When control is omitted, the generator auto-selects from Fact metadata:
bool-> checkbox control- Enum-backed facts -> combobox
- Other types -> text field
Explicit control in *.SettingsUI.json overrides auto-selection.
Sidebar, Sections, and Search
Generated SettingsPagesModel.qml is built from SettingsPages.json and each page definition.
It includes:
sections: section names for expandable sidebar rowssearchTerms: page/section/fact keyword tokens used by the search field in src/QmlControls/AppSettings.qml
Search terms are derived from:
- Page name
- Section heading/section name
- Fact metadata
keywords - Group-level
keywordswhen usingcomponentgroups without explicit controls
Add a New Setting to an Existing Generated Page
- Add Fact metadata entry to the appropriate
src/Settings/<Group>.SettingsGroup.jsonfile. - Expose that Fact through the corresponding settings class:
- Add
DEFINE_SETTINGFACT(<factName>)in the matching*Settings.h. - Ensure
DECLARE_SETTINGSFACTexists in*Settings.ccif required by that file pattern.
- Add a control entry in the page JSON:
- File:
src/UI/AppSettings/pages/<Page>.SettingsUI.json - Add control:
{ "setting": "<accessor>.<factName>" }
- Build QGC. CMake regenerates the QML page automatically.
Add a New Generated Settings Page
- Create a new page definition JSON in
src/UI/AppSettings/pages, for exampleMyFeature.SettingsUI.json. - Add a new entry to
src/UI/AppSettings/pages/SettingsPages.json:
nameiconqml(output file name, for exampleMyFeatureSettings.qml)pageDefinition(your new JSON file)- Optional
visibleexpression
- Update generated outputs list in src/UI/AppSettings/CMakeLists.txt:
- Add your new QML file name to
_generated_qml_names.
- Build QGC to generate and include the new page.
Important Notes and Gotchas
- If a page exists in
SettingsPages.jsonbut has nopageDefinition, it is not generated; it is treated as hand-written QML/URL content. - The CMake
_generated_qml_nameslist is explicit. If you forget to add a new page output file name there, generation/build integration will be incomplete. - The
settingpath in*.SettingsUI.jsonmust match a validQGroundControl.settingsManager.<group>.<fact>accessor. - Fact labels should be present in metadata. Missing labels are logged at runtime by
SettingsGroup.
Runtime Override Support
SettingsManager can load external settings override files (from settingsSavePath() with the configured settings file extension), then apply metadata/value/visibility overrides in SettingsManager::adjustSettingMetaData(...).
This is separate from page generation, but it affects visibility/defaults in generated UI.