APMAirframeComponent.qml 4.32 KB
Newer Older
1 2 3 4 5 6 7 8
/****************************************************************************
 *
 *   (c) 2009-2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
 *
 * QGroundControl is licensed according to the terms in the file
 * COPYING.md in the root of the source code directory.
 *
 ****************************************************************************/
9 10


Don Gagne's avatar
Don Gagne committed
11
import QtQuick          2.5
12
import QtQuick.Controls 1.2
Don Gagne's avatar
Don Gagne committed
13
import QtQuick.Dialogs  1.2
14
import QtQuick.Layouts  1.2
15

Don Gagne's avatar
Don Gagne committed
16 17 18 19 20
import QGroundControl.FactSystem    1.0
import QGroundControl.Palette       1.0
import QGroundControl.Controls      1.0
import QGroundControl.Controllers   1.0
import QGroundControl.ScreenTools   1.0
21

22 23 24
SetupPage {
    id:             airframePage
    pageComponent:  airframePageComponent
25

Don Gagne's avatar
Don Gagne committed
26 27
    property real _margins: ScreenTools.defaultFontPixelWidth
    property Fact _frame:   controller.getParameterFact(-1, "FRAME")
28 29 30

    APMAirframeComponentController {
        id:         controller
31
        factPanel:  airframePage.viewPanel
32 33
    }

Don Gagne's avatar
Don Gagne committed
34 35 36 37
    ExclusiveGroup {
        id: airframeTypeExclusive
    }

38 39 40 41 42 43 44 45 46 47 48 49 50 51
    Component {
        id: applyRestartDialogComponent

        QGCViewDialog {
            id: applyRestartDialog

            Connections {
                target: controller
                onCurrentAirframeTypeChanged: {
                    airframePicker.model = controller.currentAirframeType.airframes;
                }
            }

            QGCLabel {
Don Gagne's avatar
Don Gagne committed
52 53 54 55 56 57
                id:                 applyParamsText
                anchors.top:        parent.top
                anchors.left:       parent.left
                anchors.right:      parent.right
                anchors.margins:    _margins
                wrapMode:           Text.WordWrap
Don Gagne's avatar
Don Gagne committed
58
                text:               qsTr("Select your drone to load the default parameters for it. ")
59 60 61
            }

            Flow {
Don Gagne's avatar
Don Gagne committed
62 63 64 65 66 67 68 69
                anchors.margins:    _margins
                anchors.top:        applyParamsText.bottom
                anchors.left:       parent.left
                anchors.right:      parent.right
                anchors.bottom:     parent.bottom
                spacing :           _margins
                layoutDirection:    Qt.Vertical;

70
                Repeater {
Don Gagne's avatar
Don Gagne committed
71 72
                    id:     airframePicker
                    model:  controller.currentAirframeType.airframes;
73 74

                    delegate: QGCButton {
Don Gagne's avatar
Don Gagne committed
75
                        id:     btnParams
76 77
                        width:  parent.width / 2.1
                        height: (ScreenTools.defaultFontPixelHeight * 14) / 5
Don Gagne's avatar
Don Gagne committed
78
                        text:   controller.currentAirframeType.airframes[index].name;
79

Don Gagne's avatar
Don Gagne committed
80 81 82 83
                        onClicked : {
                            controller.loadParameters(controller.currentAirframeType.airframes[index].params)
                            hideDialog()
                        }
84 85 86 87 88 89
                    }
                }
            }
        }
    }

90 91
    Component {
        id: airframePageComponent
92

93 94 95 96
        Column {
            width:      availableWidth
            height:     1000
            spacing:    _margins
97

98 99
            RowLayout {
                anchors.left:   parent.left
100
                anchors.right:  parent.right
101
                spacing:        _margins
102

103 104 105 106 107 108
                QGCLabel {
                    font.pointSize:     ScreenTools.mediumFontPointSize
                    wrapMode:           Text.WordWrap
                    text:               qsTr("Please select your airframe type")
                    Layout.fillWidth:   true
                }
Don Gagne's avatar
Don Gagne committed
109

110 111 112 113 114
                QGCButton {
                    text:       qsTr("Load common parameters")
                    onClicked:  showDialog(applyRestartDialogComponent, qsTr("Load common parameters"), qgcView.showDialogDefaultWidth, StandardButton.Close)
                }
            }
115

116 117
            Repeater {
                model: controller.airframeTypesModel
118

119 120 121 122
                QGCRadioButton {
                    text: object.name
                    checked: controller.currentAirframeType == object
                    exclusiveGroup: airframeTypeExclusive
123

124 125 126
                    onCheckedChanged: {
                        if (checked) {
                            controller.currentAirframeType = object
127 128 129 130
                        }
                    }
                }
            }
131 132 133
        } // Column
    } // Component - pageComponent
} // SetupPage