QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
QGCPopupDialogFactory.qml
Go to the documentation of this file.
1import QtQuick
2import QtQml
3
4/// Factory for creating and opening QGCPopupDialog instances from a Component.
5/// Place the factory immediately before its associated Component. The dialog is created
6/// with the factory's parent as the initial parent, then QGCPopupDialog reparents itself
7/// to Overlay.overlay on completion.
8///
9/// Example:
10/// QGCPopupDialogFactory {
11/// id: myDialogFactory
12/// dialogComponent: myDialogComponent
13/// }
14///
15/// Component {
16/// id: myDialogComponent
17/// QGCPopupDialog { ... }
18/// }
19///
20/// onFoo: myDialogFactory.open()
21/// onBar: myDialogFactory.open({ title: "My Title", myProp: someValue })
22Item {
23 id: root
24 visible: false
25
26 required property Component dialogComponent
27
28 function open(props) {
29 var dialogParent = root.parent ? root.parent : null
30 var dialog = props === undefined || props === null
31 ? dialogComponent.createObject(dialogParent)
32 : dialogComponent.createObject(dialogParent, props)
33
34 if (!dialog) {
35 console.warn("QGCPopupDialogFactory: Failed to create dialog from dialogComponent");
36 return null;
37 }
38 dialog.open()
39 return dialog
40 }
41}