FlightDetails.qml 11.4 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 20 21 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
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
    property real baseHeight:  ScreenTools.defaultFontPixelHeight * 22
    property real baseWidth:   ScreenTools.defaultFontPixelWidth  * 40
    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 74
                                onClicked: {
                                    _dirty = true
75
                                    QGroundControl.airspaceManager.flightPlan.flightStartsNow = !QGroundControl.airspaceManager.flightPlan.flightStartsNow
Gus Grubba's avatar
Gus Grubba committed
76 77 78 79
                                }
                            }
                            QGCButton {
                                text: {
Gus Grubba's avatar
Gus Grubba committed
80 81 82
                                    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
83 84
                                        return qsTr("Today")
                                    } else {
Gus Grubba's avatar
Gus Grubba committed
85
                                        return setTime.toLocaleDateString(Qt.locale())
Gus Grubba's avatar
Gus Grubba committed
86 87 88
                                    }
                                }
                                Layout.fillWidth:   true
89
                                enabled:            !QGroundControl.airspaceManager.flightPlan.flightStartsNow
Gus Grubba's avatar
Gus Grubba committed
90 91 92 93 94
                                iconSource:         "qrc:/airmap/expand.svg"
                                onClicked: {
                                    _dirty = true
                                    datePicker.visible = true
                                }
95 96
                            }
                        }
Gus Grubba's avatar
Gus Grubba committed
97 98 99
                        QGCLabel {
                            text:   qsTr("Flight Start Time")
                        }
100 101 102 103
                        Item {
                            anchors.right:  parent.right
                            anchors.left:   parent.left
                            height:         timeSlider.height
104
                            visible:        !QGroundControl.airspaceManager.flightPlan.flightStartsNow
105 106 107 108
                            QGCSlider {
                                id:             timeSlider
                                width:          parent.width - timeLabel.width - ScreenTools.defaultFontPixelWidth
                                stepSize:       1
109
                                enabled:        !QGroundControl.airspaceManager.flightPlan.flightStartsNow
110 111
                                minimumValue:   0
                                maximumValue:   95 // 96 blocks of 15 minutes in 24 hours
Gus Grubba's avatar
Gus Grubba committed
112
                                anchors.left:   parent.left
113 114 115
                                anchors.verticalCenter: parent.verticalCenter
                                onValueChanged: {
                                    _dirty = true
Gus Grubba's avatar
Gus Grubba committed
116 117 118 119
                                    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
120
                                    today.setMilliseconds(0)
Gus Grubba's avatar
Gus Grubba committed
121
                                    QGroundControl.airspaceManager.flightPlan.flightStartTime = today
122 123
                                }
                                Component.onCompleted: {
Gus Grubba's avatar
Gus Grubba committed
124 125 126 127
                                    updateTime()
                                }
                                function updateTime() {
                                    var today = QGroundControl.airspaceManager.flightPlan.flightStartTime
128 129
                                    var val = (((today.getHours() * 60) + today.getMinutes()) * (96/1440)) + 1
                                    if(val > 95) val = 95
Gus Grubba's avatar
Gus Grubba committed
130
                                    timeSlider.value = Math.ceil(val)
131 132
                                }
                            }
Gus Grubba's avatar
Gus Grubba committed
133 134 135 136 137 138 139 140 141 142 143
                            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 {
144 145 146 147 148 149
                            text:               qsTr("Now")
                            visible:            QGroundControl.airspaceManager.flightPlan.flightStartsNow
                            anchors.horizontalCenter: parent.horizontalCenter
                        }
                        QGCLabel {
                            text:               qsTr("Duration")
Gus Grubba's avatar
Gus Grubba committed
150 151 152 153 154 155 156 157 158 159 160 161 162 163
                        }
                        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: {
164 165 166 167
                                    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
168 169
                                }
                                Component.onCompleted: {
170
                                    var val = ((QGroundControl.airspaceManager.flightPlan.flightDuration / 60) * (96/1440)) + 1
Gus Grubba's avatar
Gus Grubba committed
171 172 173 174 175 176 177 178 179 180 181 182 183
                                    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
                            }
184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206
                        }
                    }
                }
                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
207 208 209
        anchors.centerIn:   parent
        visible:            false;
        minimumDate:        QGroundControl.airspaceManager.flightPlan.flightStartTime
210
        onClicked: {
Gus Grubba's avatar
Gus Grubba committed
211
            QGroundControl.airspaceManager.flightPlan.flightStartTime = datePicker.selectedDate
212 213 214 215
            visible = false;
        }
    }
}