APMAirframeComponent.qml 5.23 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

Don Gagne's avatar
Don Gagne committed
15 16 17 18 19 20
import QGroundControl.FactSystem    1.0
import QGroundControl.FactControls  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 25 26 27

QGCView {
    id:         qgcView
    viewPanel:  panel

    QGCPalette { id: qgcPal; colorGroupEnabled: panel.enabled }

Don Gagne's avatar
Don Gagne committed
28 29
    property real _margins: ScreenTools.defaultFontPixelWidth
    property Fact _frame:   controller.getParameterFact(-1, "FRAME")
30 31 32 33 34 35

    APMAirframeComponentController {
        id:         controller
        factPanel:  panel
    }

Don Gagne's avatar
Don Gagne committed
36 37 38 39
    ExclusiveGroup {
        id: airframeTypeExclusive
    }

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

        QGCViewDialog {
            id: applyRestartDialog

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

            QGCLabel {
Don Gagne's avatar
Don Gagne committed
54 55 56 57 58 59
                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
60
                text:               qsTr("Select your drone to load the default parameters for it. ")
61 62 63
            }

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

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

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

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

92 93 94 95
    QGCViewPanel {
        id:             panel
        anchors.fill:   parent

96 97 98 99 100 101 102 103
        Item {
            id:             helpApplyRow
            anchors.top:    parent.top
            anchors.left:   parent.left
            anchors.right:  parent.right
            height:         Math.max(helpText.contentHeight, applyButton.height)

            QGCLabel {
Don Gagne's avatar
Don Gagne committed
104 105 106 107
                id:                     helpText
                anchors.rightMargin:    _margins
                anchors.left:           parent.left
                anchors.right:          applyButton.right
108
                text:                   qsTr("Please select your airframe type")
109
                font.pointSize:         ScreenTools.mediumFontPointSize
Don Gagne's avatar
Don Gagne committed
110
                wrapMode:               Text.WordWrap
111 112 113 114 115
            }

            QGCButton {
                id:             applyButton
                anchors.right:  parent.right
116 117
                text:           qsTr("Load common parameters")
                onClicked:      showDialog(applyRestartDialogComponent, qsTr("Load common parameters"), qgcView.showDialogDefaultWidth, StandardButton.Close)
118 119 120 121
            }
        }

        Item {
Don Gagne's avatar
Don Gagne committed
122
            id:             helpSpacer
123 124 125
            anchors.top:    helpApplyRow.bottom
            height:         parent.spacerHeight
            width:          10
126 127
        }

Don Gagne's avatar
Don Gagne committed
128
        QGCFlickable {
129
            id:             scroll
Don Gagne's avatar
Don Gagne committed
130 131 132 133 134 135
            anchors.top:    helpSpacer.bottom
            anchors.bottom: parent.bottom
            anchors.left:   parent.left
            anchors.right:  parent.right
            contentHeight:  frameColumn.height
            contentWidth:   frameColumn.width
136 137


Don Gagne's avatar
Don Gagne committed
138 139 140 141

            Column {
                id:         frameColumn
                spacing:    _margins
142 143 144 145

                Repeater {
                    model: controller.airframeTypesModel

Don Gagne's avatar
Don Gagne committed
146 147 148 149
                    QGCRadioButton {
                        text: object.name
                        checked: controller.currentAirframeType == object
                        exclusiveGroup: airframeTypeExclusive
150

Don Gagne's avatar
Don Gagne committed
151 152 153
                        onCheckedChanged: {
                            if (checked) {
                                controller.currentAirframeType = object
154 155 156 157 158
                            }
                        }
                    }
                }
            }
Don Gagne's avatar
Don Gagne committed
159
        }
160 161
    } // QGCViewPanel
} // QGCView