SetupPage.qml 3.38 KB
Newer Older
1 2 3 4 5 6 7 8 9
/****************************************************************************
 *
 *   (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.
 *
 ****************************************************************************/

10 11
import QtQuick          2.3
import QtQuick.Controls 1.2
12 13 14 15 16 17 18 19 20 21 22 23
import QtQuick.Dialogs  1.2

import QGroundControl               1.0
import QGroundControl.FactSystem    1.0
import QGroundControl.FactControls  1.0
import QGroundControl.Palette       1.0
import QGroundControl.Controls      1.0
import QGroundControl.ScreenTools   1.0
import QGroundControl.Controllers   1.0

/// Base view control for all Setup pages
QGCView {
24 25 26
    id:             setupView
    viewPanel:      setupPanel
    enabled:        !_shouldDisableWhenArmed
27

28
    property alias  pageComponent:      pageLoader.sourceComponent
29 30
    property string pageName:           vehicleComponent ? vehicleComponent.name : ""
    property string pageDescription:    vehicleComponent ? vehicleComponent.description : ""
31 32
    property real   availableWidth:     width - pageLoader.x
    property real   availableHeight:    height - pageLoader.y
33

34 35
    property bool _vehicleArmed:         QGroundControl.multiVehicleManager.activeVehicle ? QGroundControl.multiVehicleManager.activeVehicle.armed : false
    property bool _shouldDisableWhenArmed: _vehicleArmed ? (vehicleComponent ? !vehicleComponent.allowSetupWhileArmed : false) : false
36

37
    property real _margins:             ScreenTools.defaultFontPixelHeight * 0.5
Gus Grubba's avatar
Gus Grubba committed
38 39
    property string _pageTitle:         qsTr("%1 Setup").arg(pageName)

40

41 42 43 44 45 46 47 48
    QGCPalette { id: qgcPal; colorGroupEnabled: setupPanel.enabled }

    QGCViewPanel {
        id:             setupPanel
        anchors.fill:   parent

        QGCFlickable {
            anchors.fill:   parent
49 50
            contentWidth:   pageLoader.x + pageLoader.item.width
            contentHeight:  pageLoader.y + pageLoader.item.height
51 52 53
            clip:           true

            Column {
54 55 56
                id:                 headingColumn
                width:              setupPanel.width
                spacing:            _margins
57 58 59

                QGCLabel {
                    font.pointSize: ScreenTools.largeFontPointSize
Gus Grubba's avatar
Gus Grubba committed
60
                    text:           _shouldDisableWhenArmed ? _pageTitle + "<font color=\"red\">" + qsTr(" (Disabled while the vehicle is armed)") + "</font>" : _pageTitle
61 62 63 64 65 66 67
                    visible:        !ScreenTools.isShortScreen
                }

                QGCLabel {
                    anchors.left:   parent.left
                    anchors.right:  parent.right
                    wrapMode:       Text.WordWrap
68
                    text:           pageDescription
69 70 71 72 73
                    visible:        !ScreenTools.isShortScreen
                }
            }

            Loader {
74
                id:                 pageLoader
75 76 77
                anchors.topMargin:  _margins
                anchors.top:        headingColumn.bottom
            }
Gus Grubba's avatar
Gus Grubba committed
78 79 80 81 82 83 84 85
            // Overlay to display when vehicle is armed and this setup page needs
            // to be disabled
            Rectangle {
                visible:            _shouldDisableWhenArmed
                anchors.fill:       pageLoader
                color:              "black"
                opacity:            0.5
            }
86 87 88
        }
    }
}