VehicleSummary.qml 4.1 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
/*=====================================================================

 QGroundControl Open Source Ground Control Station

 (c) 2009 - 2015 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>

 This file is part of the QGROUNDCONTROL project

 QGROUNDCONTROL is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation, either version 3 of the License, or
 (at your option) any later version.

 QGROUNDCONTROL is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.

 ======================================================================*/

24 25 26
import QtQuick                  2.2
import QtQuick.Controls         1.2
import QtQuick.Controls.Styles  1.2
27

28 29 30 31
import QGroundControl.FactSystem            1.0
import QGroundControl.Controls              1.0
import QGroundControl.ScreenTools           1.0
import QGroundControl.MultiVehicleManager   1.0
32
import QGroundControl.Palette               1.0
33 34

Rectangle {
dogmaphobic's avatar
dogmaphobic committed
35 36 37 38
    id:             _summaryRoot
    anchors.fill:   parent
    color:          qgcPal.window

Don Gagne's avatar
Don Gagne committed
39
    readonly property real _margins: ScreenTools.defaultFontPixelHeight
dogmaphobic's avatar
dogmaphobic committed
40 41 42 43

    function capitalizeWords(sentence) {
        return sentence.replace(/(?:^|\s)\S/g, function(a) { return a.toUpperCase(); });
    }
44

Don Gagne's avatar
Don Gagne committed
45
    QGCPalette { id: qgcPal; colorGroupEnabled: enabled }
46

dogmaphobic's avatar
dogmaphobic committed
47 48 49
    Flickable {
        clip:               true
        anchors.fill:       parent
Don Gagne's avatar
Don Gagne committed
50
        contentHeight:      summaryFlow.y + summaryFlow.height
dogmaphobic's avatar
dogmaphobic committed
51
        flickableDirection: Flickable.VerticalFlick
52

Don Gagne's avatar
Don Gagne committed
53 54 55 56 57 58 59 60 61 62 63
        QGCLabel {
            id:             topLabel
            width:			parent.width
            wrapMode:		Text.WordWrap
            color:			setupComplete ? qgcPal.text : qgcPal.warningText
            font.weight:    setupComplete ? Font.Normal : Font.DemiBold
            text:           setupComplete ?
                                "Below you will find a summary of the settings for your vehicle. To the left are the setup menus for each component." :
                                "WARNING: Your vehicle requires setup prior to flight. Please resolve the items marked in red using the menu on the left."
            property bool setupComplete: multiVehicleManager.activeVehicle.autopilot.setupComplete
        }
64

Don Gagne's avatar
Don Gagne committed
65 66 67 68 69 70
        Flow {
            id:                 summaryFlow
            anchors.topMargin:  _margins
            anchors.top:        topLabel.bottom
            width:              parent.width
            spacing:            ScreenTools.defaultFontPixelWidth
71

Don Gagne's avatar
Don Gagne committed
72 73 74 75 76 77 78 79 80 81
            Repeater {
                model: multiVehicleManager.activeVehicle.autopilot.vehicleComponents

                QGCLabel {
                    width:          summaryRectangle.width
                    height:         summaryRectangle.y + summaryRectangle.height
                    text:           capitalizeWords(modelData.name)
                    font.weight:    Font.DemiBold
                    visible:        modelData.summaryQmlSource.toString() != ""
                    color:          modelData.setupComplete ? qgcPal.text : "red"
82

Don Gagne's avatar
Don Gagne committed
83 84 85 86 87 88 89 90 91 92 93 94 95
                    Rectangle {
                        id:     summaryRectangle
                        y:      parent.contentHeight + (_margins / 2)
                        width:  summaryLoader.width + _margins
                        height: summaryLoader.height + _margins
                        color:  qgcPal.windowShade

                        Loader {
                            id:                 summaryLoader
                            anchors.margins:    _margins / 2
                            anchors.left:       parent.left
                            anchors.top:        parent.top
                            source:             modelData.summaryQmlSource
96 97 98 99 100 101 102
                        }
                    }
                }
            }
        }
    }
}