FlightDetails.qml 11.3 KB
Newer Older
1 2 3 4
import QtQuick                  2.3
import QtQuick.Controls         1.2
import QtQuick.Controls.Styles  1.4
import QtQuick.Dialogs          1.2
Gus Grubba's avatar
Gus Grubba committed
5
import QtQuick.Layouts          1.2
6 7 8 9 10 11 12 13 14 15 16 17 18 19
import QtQml                    2.2

import QGroundControl                   1.0
import QGroundControl.Airmap            1.0
import QGroundControl.Airspace          1.0
import QGroundControl.Controls          1.0
import QGroundControl.Palette           1.0
import QGroundControl.ScreenTools       1.0
import QGroundControl.SettingsManager   1.0

Item {
    id:                 _root
    implicitHeight:     detailCol.height
    implicitWidth:      detailCol.width
20 21
    property real baseHeight:   ScreenTools.defaultFontPixelHeight * 22
    property real baseWidth:    ScreenTools.defaultFontPixelWidth  * 40
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
    Column {
        id:             detailCol
        spacing:        ScreenTools.defaultFontPixelHeight * 0.25
        Rectangle {
            color:          qgcPal.windowShade
            anchors.right:  parent.right
            anchors.left:   parent.left
            height:         detailsLabel.height + ScreenTools.defaultFontPixelHeight
            QGCLabel {
                id:             detailsLabel
                text:           qsTr("Flight Details")
                font.pointSize: ScreenTools.mediumFontPointSize
                font.family:    ScreenTools.demiboldFontFamily
                anchors.centerIn: parent
            }
        }
        Item { width: 1; height: ScreenTools.defaultFontPixelHeight * 0.5; }
        Flickable {
            clip:           true
            width:          baseWidth
            height:         baseHeight
            contentHeight:  flContextCol.height
            flickableDirection: Flickable.VerticalFlick
            Column {
                id:                 flContextCol
Gus Grubba's avatar
Gus Grubba committed
47
                spacing:            ScreenTools.defaultFontPixelHeight * 0.25
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
                anchors.right:      parent.right
                anchors.left:       parent.left
                QGCLabel {
                    text:           qsTr("Flight Date & Time")
                }
                Rectangle {
                    id:             dateRect
                    color:          qgcPal.windowShade
                    anchors.right:  parent.right
                    anchors.left:   parent.left
                    height:         datePickerCol.height + (ScreenTools.defaultFontPixelHeight * 2)
                    Column {
                        id:                 datePickerCol
                        spacing:            ScreenTools.defaultFontPixelHeight * 0.5
                        anchors.margins:    ScreenTools.defaultFontPixelWidth
                        anchors.right:      parent.right
                        anchors.left:       parent.left
                        anchors.verticalCenter: parent.verticalCenter
Gus Grubba's avatar
Gus Grubba committed
66 67
                        RowLayout {
                            spacing:        ScreenTools.defaultFontPixelWidth * 0.5
68 69
                            anchors.right:  parent.right
                            anchors.left:   parent.left
Gus Grubba's avatar
Gus Grubba committed
70 71
                            QGCButton {
                                text:       qsTr("Now")
72
                                checked:    QGroundControl.airspaceManager.flightPlan.flightStartsNow
Gus Grubba's avatar
Gus Grubba committed
73
                                onClicked: {
74
                                    QGroundControl.airspaceManager.flightPlan.flightStartsNow = !QGroundControl.airspaceManager.flightPlan.flightStartsNow
Gus Grubba's avatar
Gus Grubba committed
75 76 77 78
                                }
                            }
                            QGCButton {
                                text: {
Gus Grubba's avatar
Gus Grubba committed
79 80 81
                                    var nowTime = new Date()
                                    var setTime = QGroundControl.airspaceManager.flightPlan.flightStartTime
                                    if(setTime.setHours(0,0,0,0) === nowTime.setHours(0,0,0,0)) {
Gus Grubba's avatar
Gus Grubba committed
82 83
                                        return qsTr("Today")
                                    } else {
Gus Grubba's avatar
Gus Grubba committed
84
                                        return setTime.toLocaleDateString(Qt.locale())
Gus Grubba's avatar
Gus Grubba committed
85 86 87
                                    }
                                }
                                Layout.fillWidth:   true
88
                                enabled:            !QGroundControl.airspaceManager.flightPlan.flightStartsNow
Gus Grubba's avatar
Gus Grubba committed
89 90 91 92
                                iconSource:         "qrc:/airmap/expand.svg"
                                onClicked: {
                                    datePicker.visible = true
                                }
93 94
                            }
                        }
Gus Grubba's avatar
Gus Grubba committed
95 96 97
                        QGCLabel {
                            text:   qsTr("Flight Start Time")
                        }
98 99 100 101
                        Item {
                            anchors.right:  parent.right
                            anchors.left:   parent.left
                            height:         timeSlider.height
102
                            visible:        !QGroundControl.airspaceManager.flightPlan.flightStartsNow
103 104 105 106
                            QGCSlider {
                                id:             timeSlider
                                width:          parent.width - timeLabel.width - ScreenTools.defaultFontPixelWidth
                                stepSize:       1
107
                                enabled:        !QGroundControl.airspaceManager.flightPlan.flightStartsNow
108 109
                                minimumValue:   0
                                maximumValue:   95 // 96 blocks of 15 minutes in 24 hours
Gus Grubba's avatar
Gus Grubba committed
110
                                anchors.left:   parent.left
111 112
                                anchors.verticalCenter: parent.verticalCenter
                                onValueChanged: {
Gus Grubba's avatar
Gus Grubba committed
113 114 115 116
                                    var today = QGroundControl.airspaceManager.flightPlan.flightStartTime
                                    today.setHours(Math.floor(timeSlider.value * 0.25))
                                    today.setMinutes((timeSlider.value * 15) % 60)
                                    today.setSeconds(0)
Gus Grubba's avatar
Gus Grubba committed
117
                                    today.setMilliseconds(0)
Gus Grubba's avatar
Gus Grubba committed
118
                                    QGroundControl.airspaceManager.flightPlan.flightStartTime = today
119 120
                                }
                                Component.onCompleted: {
Gus Grubba's avatar
Gus Grubba committed
121 122 123 124
                                    updateTime()
                                }
                                function updateTime() {
                                    var today = QGroundControl.airspaceManager.flightPlan.flightStartTime
125 126
                                    var val = (((today.getHours() * 60) + today.getMinutes()) * (96/1440)) + 1
                                    if(val > 95) val = 95
Gus Grubba's avatar
Gus Grubba committed
127
                                    timeSlider.value = Math.ceil(val)
128 129
                                }
                            }
Gus Grubba's avatar
Gus Grubba committed
130 131 132 133 134 135 136 137 138 139 140
                            QGCLabel {
                                id:             timeLabel
                                text:           ('00' + hour).slice(-2) + ":" + ('00' + minute).slice(-2)
                                width:          ScreenTools.defaultFontPixelWidth * 5
                                anchors.right:  parent.right
                                anchors.verticalCenter: parent.verticalCenter
                                property int hour:   Math.floor(timeSlider.value * 0.25)
                                property int minute: (timeSlider.value * 15) % 60
                            }
                        }
                        QGCLabel {
141 142 143 144 145 146
                            text:               qsTr("Now")
                            visible:            QGroundControl.airspaceManager.flightPlan.flightStartsNow
                            anchors.horizontalCenter: parent.horizontalCenter
                        }
                        QGCLabel {
                            text:               qsTr("Duration")
Gus Grubba's avatar
Gus Grubba committed
147 148 149 150 151 152 153 154 155 156 157 158 159 160
                        }
                        Item {
                            anchors.right:  parent.right
                            anchors.left:   parent.left
                            height:         durationSlider.height
                            QGCSlider {
                                id:             durationSlider
                                width:          parent.width - durationLabel.width - ScreenTools.defaultFontPixelWidth
                                stepSize:       1
                                minimumValue:   1
                                maximumValue:   24 // 24 blocks of 15 minutes in 6 hours
                                anchors.left:  parent.left
                                anchors.verticalCenter: parent.verticalCenter
                                onValueChanged: {
161 162 163 164
                                    var hour   = Math.floor(durationSlider.value * 0.25)
                                    var minute = (durationSlider.value * 15) % 60
                                    var seconds = (hour * 60 * 60) + (minute * 60)
                                    QGroundControl.airspaceManager.flightPlan.flightDuration = seconds
Gus Grubba's avatar
Gus Grubba committed
165 166
                                }
                                Component.onCompleted: {
167
                                    var val = ((QGroundControl.airspaceManager.flightPlan.flightDuration / 60) * (96/1440)) + 1
Gus Grubba's avatar
Gus Grubba committed
168 169 170 171 172 173 174 175 176 177 178 179 180
                                    if(val > 24) val = 24
                                    durationSlider.value = Math.ceil(val)
                                }
                            }
                            QGCLabel {
                                id:             durationLabel
                                text:           ('00' + hour).slice(-2) + ":" + ('00' + minute).slice(-2)
                                width:          ScreenTools.defaultFontPixelWidth * 5
                                anchors.right:  parent.right
                                anchors.verticalCenter: parent.verticalCenter
                                property int hour:   Math.floor(durationSlider.value * 0.25)
                                property int minute: (durationSlider.value * 15) % 60
                            }
181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203
                        }
                    }
                }
                Item { width: 1; height: ScreenTools.defaultFontPixelHeight * 0.25; }
                QGCLabel {
                    text:           qsTr("Flight Context")
                    visible:        QGroundControl.airspaceManager.flightPlan.briefFeatures.count > 0
                }
                Repeater {
                    model:          QGroundControl.airspaceManager.flightPlan.briefFeatures
                    visible:        QGroundControl.airspaceManager.flightPlan.briefFeatures.count > 0
                    delegate:       FlightFeature {
                        feature:    object
                        visible:     object && object.type !== AirspaceRuleFeature.Unknown && object.description !== "" && object.name !== ""
                        anchors.right:  parent.right
                        anchors.left:   parent.left
                    }
                }
            }
        }
    }
    Calendar {
        id: datePicker
Gus Grubba's avatar
Gus Grubba committed
204 205 206
        anchors.centerIn:   parent
        visible:            false;
        minimumDate:        QGroundControl.airspaceManager.flightPlan.flightStartTime
207
        onClicked: {
Gus Grubba's avatar
Gus Grubba committed
208
            QGroundControl.airspaceManager.flightPlan.flightStartTime = datePicker.selectedDate
209 210 211 212
            visible = false;
        }
    }
}