MissionSettingsEditor.qml 15.3 KB
Newer Older
1 2 3
import QtQuick          2.3
import QtQuick.Controls 1.2
import QtQuick.Layouts  1.2
4

5 6 7 8 9 10 11
import QGroundControl                   1.0
import QGroundControl.ScreenTools       1.0
import QGroundControl.Vehicle           1.0
import QGroundControl.Controls          1.0
import QGroundControl.FactControls      1.0
import QGroundControl.Palette           1.0
import QGroundControl.SettingsManager   1.0
DonLakeFlyer's avatar
DonLakeFlyer committed
12
import QGroundControl.Controllers       1.0
13 14 15 16 17 18 19 20 21 22

// Editor for Mission Settings
Rectangle {
    id:                 valuesRect
    width:              availableWidth
    height:             deferedload.status == Loader.Ready ? (visible ? deferedload.item.height : 0) : 0
    color:              qgcPal.windowShadeDark
    visible:            missionItem.isCurrentItem
    radius:             _radius

DonLakeFlyer's avatar
DonLakeFlyer committed
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
    property var    _missionVehicle:            missionController.vehicle
    property bool   _vehicleHasHomePosition:    _missionVehicle.homePosition.isValid
    property bool   _offlineEditing:            _missionVehicle.isOfflineEditingVehicle
    property bool   _showOfflineVehicleCombos:  _offlineEditing && _multipleFirmware && _noMissionItemsAdded
    property bool   _showCruiseSpeed:           !_missionVehicle.multiRotor
    property bool   _showHoverSpeed:            _missionVehicle.multiRotor || _missionVehicle.vtol
    property bool   _multipleFirmware:          QGroundControl.supportedFirmwareCount > 2
    property real   _fieldWidth:                ScreenTools.defaultFontPixelWidth * 16
    property bool   _mobile:                    ScreenTools.isMobile
    property var    _savePath:                  QGroundControl.settingsManager.appSettings.missionSavePath
    property var    _fileExtension:             QGroundControl.settingsManager.appSettings.missionFileExtension
    property bool   _newMissionAlreadyExists:   false
    property bool   _noMissionName:             missionItem.missionName.valueString === ""
    property bool   _showMissionList:           _noMissionItemsAdded && (_noMissionName || _newMissionAlreadyExists)
    property bool   _existingMissionLoaded:     missionItem.existingMission
38
    property var    _appSettings:               QGroundControl.settingsManager.appSettings
DonLakeFlyer's avatar
DonLakeFlyer committed
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55

    readonly property string _firmwareLabel:    qsTr("Firmware")
    readonly property string _vehicleLabel:     qsTr("Vehicle")

    QGCPalette { id: qgcPal }
    QFileDialogController { id: fileController }

    Connections {
        target:             missionItem.missionName

        onRawValueChanged: {
            if (!_existingMissionLoaded) {
                _newMissionAlreadyExists = !_noMissionName && fileController.fileExists(_savePath + "/" + missionItem.missionName.valueString + "." + _fileExtension)
            }
        }
    }

56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
    Loader {
        id:              deferedload
        active:          valuesRect.visible
        asynchronous:    true
        anchors.margins: _margin
        anchors.left:    valuesRect.left
        anchors.right:   valuesRect.right
        anchors.top:     valuesRect.top

        sourceComponent: Component {
            Item {
                id:                 valuesItem
                height:             valuesColumn.height + (_margin * 2)

                Column {
                    id:             valuesColumn
                    anchors.left:   parent.left
                    anchors.right:  parent.right
                    anchors.top:    parent.top
                    spacing:        _margin

DonLakeFlyer's avatar
DonLakeFlyer committed
77 78 79
                    QGCLabel {
                        text:           qsTr("Mission name")
                        font.pointSize: ScreenTools.smallFontPointSize
80
                    }
81

DonLakeFlyer's avatar
DonLakeFlyer committed
82
                    FactTextField {
83 84
                        anchors.left:   parent.left
                        anchors.right:  parent.right
DonLakeFlyer's avatar
DonLakeFlyer committed
85 86 87
                        fact:           missionItem.missionName
                        visible:        !_existingMissionLoaded
                    }
88

DonLakeFlyer's avatar
DonLakeFlyer committed
89 90 91 92
                    QGCLabel {
                        text:       missionItem.missionName.valueString
                        visible:    _existingMissionLoaded
                    }
93

DonLakeFlyer's avatar
DonLakeFlyer committed
94 95 96 97 98
                    QGCLabel {
                        text:           qsTr("Mission already exists")
                        font.pointSize: ScreenTools.smallFontPointSize
                        color:          qgcPal.warningText
                        visible:        !_existingMissionLoaded && _newMissionAlreadyExists
Gus Grubba's avatar
Gus Grubba committed
99
                    }
100

101 102 103 104 105 106 107 108 109 110 111
                    FactCheckBox {
                        id:     automaticUploadCheckbox
                        text:   qsTr("Automatically upload on exit")
                        fact:   _appSettings.automaticMissionUpload
                    }

                    RowLayout {
                        anchors.left:   parent.left
                        anchors.right:  parent.right

                        QGCButton {
112
                            text:               qsTr("Remove All")
113 114 115 116 117 118
                            visible:            !_noMissionItemsAdded
                            Layout.fillWidth:   true
                            onClicked:          missionController.clearMission()
                        }

                        QGCButton {
119
                            text:               qsTr("New Mission")
120 121 122 123
                            visible:            !_noMissionItemsAdded
                            Layout.fillWidth:   true
                            onClicked:          missionController.closeMission()
                        }
124 125
                    }

DonLakeFlyer's avatar
DonLakeFlyer committed
126 127 128 129 130 131 132 133 134
                    Loader {
                        anchors.left:       parent.left
                        anchors.right:      parent.right
                        sourceComponent:    _showMissionList ? missionList : missionSettings
                    }
                } // Column
            } // Item
        } // Component
    } // Loader
135

DonLakeFlyer's avatar
DonLakeFlyer committed
136 137
    Component {
        id: missionList
138

DonLakeFlyer's avatar
DonLakeFlyer committed
139 140 141 142
        QGCFlickable {
            anchors.left:   parent.left
            anchors.right:  parent.right
            height:         missionColumn.height
143

DonLakeFlyer's avatar
DonLakeFlyer committed
144 145 146 147 148 149 150 151 152 153
            Column {
                id:             missionColumn
                anchors.left:   parent.left
                anchors.right:  parent.right
                spacing:        _margin

                SectionHeader {
                    text:       qsTr("Load Mission")
                    showSpacer: false
                }
154

155
                RowLayout {
DonLakeFlyer's avatar
DonLakeFlyer committed
156 157 158
                    anchors.left:   parent.left
                    anchors.right:  parent.right

159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184
                    QGCButton {
                        text:               qsTr("From Vehicle")
                        visible:            !_offlineEditing
                        Layout.fillWidth:   true
                        onClicked:          missionController.loadFromVehicle()
                    }

                    QGCButton {
                        text:               qsTr("Browse")
                        Layout.fillWidth:   true
                        onClicked:          fileDialog.openForLoad()

                        QGCFileDialog {
                            id:             fileDialog
                            qgcView:        rootQgcView
                            title:          qsTr("Select mission file")
                            selectExisting: true
                            folder:         _appSettings.missionSavePath
                            fileExtension:  _appSettings.missionFileExtension
                            nameFilters:    [ qsTr("Mission Files (*.%1)").arg(fileExtension) , qsTr("All Files (*.*)") ]

                            onAcceptedForLoad: {
                                missionController.loadFromFile(file)
                                fileDialog.close()
                            }
                        }
185
                    }
DonLakeFlyer's avatar
DonLakeFlyer committed
186 187 188 189 190 191
                }

                QGCLabel {
                    text:       qsTr("No mission files")
                    visible:    missionRepeater.model.length === 0
                }
192

DonLakeFlyer's avatar
DonLakeFlyer committed
193 194 195 196 197
                Repeater {
                    id:     missionRepeater
                    model:  fileController.getFiles(_savePath, _fileExtension);

                    QGCButton {
198 199
                        anchors.left:   parent.left
                        anchors.right:  parent.right
DonLakeFlyer's avatar
DonLakeFlyer committed
200 201 202 203
                        text:           modelData

                        onClicked: {
                            missionController.loadFromFile(fileController.fullyQualifiedFilename(_savePath, modelData, _fileExtension))
204 205
                        }
                    }
DonLakeFlyer's avatar
DonLakeFlyer committed
206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247
                }
            }
        }
    }

    Component {
        id: missionSettings

        Column {
            id:             valuesColumn
            anchors.left:   parent.left
            anchors.right:  parent.right
            anchors.top:    parent.top
            spacing:        _margin

            SectionHeader {
                id:         missionDefaultsSectionHeader
                text:       qsTr("Mission Defaults")
                checked:    true
                showSpacer: false
            }

            Column {
                anchors.left:   parent.left
                anchors.right:  parent.right
                spacing:        _margin
                visible:        missionDefaultsSectionHeader.checked

                GridLayout {
                    anchors.left:   parent.left
                    anchors.right:  parent.right
                    columnSpacing:  ScreenTools.defaultFontPixelWidth
                    rowSpacing:     columnSpacing
                    columns:        2

                    QGCLabel {
                        text:       qsTr("Waypoint alt")
                    }
                    FactTextField {
                        fact:               QGroundControl.settingsManager.appSettings.defaultMissionItemAltitude
                        Layout.fillWidth:   true
                    }
248

DonLakeFlyer's avatar
DonLakeFlyer committed
249 250 251 252 253 254 255 256 257 258 259 260
                    QGCCheckBox {
                        id:         flightSpeedCheckBox
                        text:       qsTr("Flight speed")
                        visible:    !_missionVehicle.vtol
                        checked:    missionItem.specifyMissionFlightSpeed
                        onClicked:  missionItem.specifyMissionFlightSpeed = checked
                    }
                    FactTextField {
                        Layout.fillWidth:   true
                        fact:               missionItem.missionFlightSpeed
                        visible:            flightSpeedCheckBox.visible
                        enabled:            flightSpeedCheckBox.checked
261
                    }
DonLakeFlyer's avatar
DonLakeFlyer committed
262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356
                } // GridLayout

                FactComboBox {
                    anchors.left:   parent.left
                    anchors.right:  parent.right
                    fact:           missionItem.missionEndAction
                    indexModel:     false
                }
            }

            CameraSection {
                checked: missionItem.cameraSection.settingsSpecified
            }

            SectionHeader {
                id:         vehicleInfoSectionHeader
                text:       qsTr("Vehicle Info")
                visible:    _offlineEditing
                checked:    false
            }

            GridLayout {
                anchors.left:   parent.left
                anchors.right:  parent.right
                columnSpacing:  ScreenTools.defaultFontPixelWidth
                rowSpacing:     columnSpacing
                columns:        2
                visible:        vehicleInfoSectionHeader.visible && vehicleInfoSectionHeader.checked

                QGCLabel {
                    text:               _firmwareLabel
                    Layout.fillWidth:   true
                    visible:            _showOfflineVehicleCombos
                }
                FactComboBox {
                    fact:                   QGroundControl.settingsManager.appSettings.offlineEditingFirmwareType
                    indexModel:             false
                    Layout.preferredWidth:  _fieldWidth
                    visible:                _showOfflineVehicleCombos
                }

                QGCLabel {
                    text:               _vehicleLabel
                    Layout.fillWidth:   true
                    visible:            _showOfflineVehicleCombos
                }
                FactComboBox {
                    fact:                   QGroundControl.settingsManager.appSettings.offlineEditingVehicleType
                    indexModel:             false
                    Layout.preferredWidth:  _fieldWidth
                    visible:                _showOfflineVehicleCombos
                }

                QGCLabel {
                    text:               qsTr("Cruise speed")
                    visible:            _showCruiseSpeed
                    Layout.fillWidth:   true
                }
                FactTextField {
                    fact:                   QGroundControl.settingsManager.appSettings.offlineEditingCruiseSpeed
                    visible:                _showCruiseSpeed
                    Layout.preferredWidth:  _fieldWidth
                }

                QGCLabel {
                    text:               qsTr("Hover speed")
                    visible:            _showHoverSpeed
                    Layout.fillWidth:   true
                }
                FactTextField {
                    fact:                   QGroundControl.settingsManager.appSettings.offlineEditingHoverSpeed
                    visible:                _showHoverSpeed
                    Layout.preferredWidth:  _fieldWidth
                }
            } // GridLayout

            SectionHeader {
                id:         plannedHomePositionSection
                text:       qsTr("Planned Home Position")
                visible:    !_vehicleHasHomePosition
                checked:    false
            }

            Column {
                anchors.left:   parent.left
                anchors.right:  parent.right
                spacing:        _margin
                visible:        plannedHomePositionSection.checked && !_vehicleHasHomePosition

                GridLayout {
                    anchors.left:   parent.left
                    anchors.right:  parent.right
                    columnSpacing:  ScreenTools.defaultFontPixelWidth
                    rowSpacing:     columnSpacing
                    columns:        2
357

358
                    QGCLabel {
DonLakeFlyer's avatar
DonLakeFlyer committed
359
                        text: qsTr("Altitude")
Gus Grubba's avatar
Gus Grubba committed
360
                    }
DonLakeFlyer's avatar
DonLakeFlyer committed
361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381
                    FactTextField {
                        fact:               missionItem.plannedHomePositionAltitude
                        Layout.fillWidth:   true
                    }
                }

                QGCLabel {
                    width:                  parent.width
                    wrapMode:               Text.WordWrap
                    font.pointSize:         ScreenTools.smallFontPointSize
                    text:                   qsTr("Actual position set by vehicle at flight time.")
                    horizontalAlignment:    Text.AlignHCenter
                }

                QGCButton {
                    text:                       qsTr("Set Home To Map Center")
                    onClicked:                  missionItem.coordinate = map.center
                    anchors.horizontalCenter:   parent.horizontalCenter
                }
            }
        } // Column
382
    } // Deferred loader
383
} // Rectangle