SetupPage.qml 3.82 KB
Newer Older
Don Gagne's avatar
Don Gagne committed
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
Don Gagne's avatar
Don Gagne committed
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
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 {
    id:         setupView
    viewPanel:  setupPanel

27
    property alias  pageComponent:      pageLoader.sourceComponent
28 29
    property string pageName:           vehicleComponent ? vehicleComponent.name : ""
    property string pageDescription:    vehicleComponent ? vehicleComponent.description : ""
30 31
    property real   availableWidth:     width - pageLoader.x
    property real   availableHeight:    height - pageLoader.y
Don Gagne's avatar
Don Gagne committed
32 33 34

    property real _margins: ScreenTools.defaultFontPixelHeight / 2

35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
    property bool visibleWhileArmed: false

    property bool vehicleArmed: QGroundControl.multiVehicleManager.activeVehicle ? QGroundControl.multiVehicleManager.activeVehicle.armed : false

    onVehicleArmedChanged: {
        if (visibleWhileArmed) {
            return
        }

        if (vehicleArmed) {
            disabledWhileArmed.visible = true
            setupView.viewPanel.enabled = false
        } else {
            disabledWhileArmed.visible = false
            setupView.viewPanel.enabled = true
        }
    }

Don Gagne's avatar
Don Gagne committed
53 54
    QGCPalette { id: qgcPal; colorGroupEnabled: setupPanel.enabled }

55 56 57 58 59 60 61 62 63 64 65 66 67 68
    // Overlay to display when vehicle is armed and the setup page needs
    // to be disabled
    Item {
        id: disabledWhileArmed
        visible: false
        z: 9999
        anchors.fill: parent
        Rectangle {
            anchors.fill: parent
            color: "black"
            opacity: 0.5
        }

        QGCLabel {
Jacob Walser's avatar
Jacob Walser committed
69
            anchors.margins:        defaultTextWidth * 2
70 71 72 73 74 75 76 77 78 79
            anchors.fill:           parent
            verticalAlignment:      Text.AlignVCenter
            horizontalAlignment:    Text.AlignHCenter
            wrapMode:               Text.WordWrap
            font.pointSize:         ScreenTools.largeFontPointSize
            color:                  "red"
            text:                   "Setup disabled while the vehicle is armed"
        }
    }

Don Gagne's avatar
Don Gagne committed
80 81 82 83 84 85
    QGCViewPanel {
        id:             setupPanel
        anchors.fill:   parent

        QGCFlickable {
            anchors.fill:   parent
86 87
            contentWidth:   pageLoader.x + pageLoader.item.width
            contentHeight:  pageLoader.y + pageLoader.item.height
Don Gagne's avatar
Don Gagne committed
88 89 90 91
            clip:           true

            Column {
                id:             headingColumn
92
                width:          setupPanel.width
Don Gagne's avatar
Don Gagne committed
93 94 95 96
                spacing:        _margins

                QGCLabel {
                    font.pointSize: ScreenTools.largeFontPointSize
97
                    text:           pageName + " " + qsTr("Setup")
Don Gagne's avatar
Don Gagne committed
98 99 100 101 102 103 104
                    visible:        !ScreenTools.isShortScreen
                }

                QGCLabel {
                    anchors.left:   parent.left
                    anchors.right:  parent.right
                    wrapMode:       Text.WordWrap
105
                    text:           pageDescription
Don Gagne's avatar
Don Gagne committed
106 107 108 109 110
                    visible:        !ScreenTools.isShortScreen
                }
            }

            Loader {
111
                id:                 pageLoader
Don Gagne's avatar
Don Gagne committed
112 113 114 115 116 117
                anchors.topMargin:  _margins
                anchors.top:        headingColumn.bottom
            }
        }
    }
}