QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
MissionItemEditorLoader.qml
Go to the documentation of this file.
1import QtQuick
2
3import QGroundControl
4import QGroundControl.Controls
5
6/// Loads the editor QML of a mission item. The editors rely on some sizing properties of the enclosing item for their
7/// layout, which this Loader provides so every host gets the same editor behavior.
8Loader {
9 id: root
10
11 required property var missionItem ///< null unloads the editor
12 property real availableWidth: 0
13
14 readonly property real _margin: ScreenTools.defaultFontPixelWidth / 2
15 readonly property real _innerMargin: 2
16 readonly property real _radius: ScreenTools.defaultFontPixelWidth / 2
17 readonly property real _editFieldWidth: Math.min(availableWidth - _innerMargin * 2, ScreenTools.defaultFontPixelWidth * 12)
18
19 function _load() {
20 if (missionItem) {
21 setSource(missionItem.editorQml, {
22 missionItem: root.missionItem,
23 availableWidth: Qt.binding(() => root.availableWidth)
24 })
25 } else {
26 setSource("")
27 }
28 }
29
30 onMissionItemChanged: _load()
31
32 // Deliberately not asynchronous. An editor destroyed while still loading warns "Cannot create a component in an
33 // invalid context", which synchronous loading avoids.
34 Component.onCompleted: _load()
35}