import QtQuick 2.3 import QtQuick.Controls.Styles 1.4 import QtQuick.Dialogs 1.2 import QtLocation 5.3 import QtPositioning 5.3 import QtQuick.Controls 2.4 import QtQuick.Layouts 1.2 import QGroundControl 1.0 import QGroundControl.ScreenTools 1.0 import QGroundControl.Controls 1.0 import QGroundControl.Palette 1.0 import QGroundControl.Vehicle 1.0 import QGroundControl.FlightMap 1.0 import QGroundControl.Airspace 1.0 import QGroundControl.Airmap 1.0 import QGroundControl.FactSystem 1.0 import QGroundControl.FactControls 1.0 Item { id: _root height: 600 width: 300 property var wimaController // must be provided by the user property var planMasterController // must be provided by the user property bool _controllerValid: planMasterController !== undefined property real _controllerProgressPct: _controllerValid ? planMasterController.missionController.progressPct : 0 signal initSmartRTL(); // Progress bar visibility on_ControllerProgressPctChanged: { if (_controllerProgressPct === 1) { uploadCompleteText.visible = true progressBar.visible = false } else if (_controllerProgressPct > 0) { progressBar.visible = true uploadCompleteText.visible = false } } function getTime(time) { // time is a double if(isNaN(time)) { return "00:00:00" } var t = new Date(0, 0, 0, 0, 0, Number(time)) return Qt.formatTime(t, 'hh:mm:ss') } QGCPalette { id: qgcPal } // box containing all items Rectangle { // maybe replace with column and remove anchors => dynamic height: id: mainFrame anchors.left: parent.left anchors.bottom: parent.bottom height: enableWima.enableWimaBoolean ? parent.height : enableWima.height width: enableWima.enableWimaBoolean ? parent.width : enableWima.width color: enableWima.enableWimaBoolean ? qgcPal.window : "transparent" radius: ScreenTools.defaultFontPixelHeight / 4 // checkbox to enable/ disable wima SliderSwitch { id: enableWima anchors.horizontalCenter: parent.horizontalCenter anchors.topMargin: ScreenTools.defaultFontPixelHeight * 0.25 anchors.top: parent.top confirmText: enableWimaBoolean ? qsTr("disable WiMA") : qsTr("enable WiMA") property var enableWimaFact: wimaController.enableWimaController property bool enableWimaBoolean: enableWimaFact.value onAccept: { if (enableWimaBoolean) { enableWimaFact.value = false } else { enableWimaFact.value = true } } } Item { id: flickableWrapper anchors.top: enableWima.bottom anchors.left: parent.left anchors.right: parent.right anchors.bottom: parent.bottom anchors.margins: ScreenTools.defaultFontPixelHeight*0.5 QGCFlickable { clip: true anchors.fill: parent contentHeight: wrapperItem.height contentWidth: wrapperItem.width Item { id: wrapperItem width: Math.max(flickableWrapper.width, mainColumn.width) height: mainColumn.height property int itemWidth: 120 Column { id: mainColumn anchors.horizontalCenter: parent.horizontalCenter spacing: ScreenTools.defaultFontPixelHeight * 0.3 SectionHeader{ id: settingsHeader text: qsTr("Settings") } GridLayout { columns: 2 rowSpacing: ScreenTools.defaultFontPixelHeight * 0.5 columnSpacing: ScreenTools.defaultFontPixelHeight * 0.5 visible: settingsHeader.checked QGCLabel { text: qsTr("Next Waypoint") Layout.fillWidth: true } FactTextField { fact: wimaController.startWaypointIndex Layout.fillWidth: true } QGCLabel { text: qsTr("Max Waypoints") Layout.fillWidth: true } FactTextField { fact: wimaController.maxWaypointsPerPhase Layout.fillWidth: true } QGCLabel { text: qsTr("Overlap") Layout.fillWidth: true } FactTextField { fact: wimaController.overlapWaypoints Layout.fillWidth: true } } GridLayout { columns: 2 rowSpacing: ScreenTools.defaultFontPixelHeight * 0.5 columnSpacing: ScreenTools.defaultFontPixelHeight * 0.5 visible: settingsHeader.checked FactCheckBox { text: qsTr("Show All") fact: wimaController.showAllMissionItems Layout.fillWidth: true } FactCheckBox { text: qsTr("Show Current") fact: wimaController.showCurrentMissionItems Layout.fillWidth: true } FactCheckBox { text: qsTr("Reverse") fact: wimaController.reverse Layout.fillWidth: true } } // Grid SectionHeader{ id: missionHeader text: qsTr("Mission") } GridLayout { columns: 2 rowSpacing: ScreenTools.defaultFontPixelHeight * 0.5 columnSpacing: ScreenTools.defaultFontPixelHeight * 0.5 visible: missionHeader.checked width: parent.width QGCLabel { text: qsTr("Speed") Layout.fillWidth: true } FactTextField { fact: wimaController.flightSpeed Layout.fillWidth: true } QGCLabel { text: qsTr("Altitude") Layout.fillWidth: true } FactTextField { fact: wimaController.altitude Layout.fillWidth: true } } GridLayout { columns: 2 rowSpacing: ScreenTools.defaultFontPixelHeight * 0.5 columnSpacing: ScreenTools.defaultFontPixelHeight * 0.5 visible: missionHeader.checked width: parent.width // Buttons QGCButton { id: buttonPreviousMissionPhase text: qsTr("Reverse") onClicked: wimaController.previousPhase() Layout.fillWidth: true } QGCButton { id: buttonNextMissionPhase text: qsTr("Forward") onClicked: wimaController.nextPhase() Layout.fillWidth: true } QGCButton { id: buttonResetPhase text: qsTr("Reset Phase") onClicked: wimaController.resetPhase(); Layout.columnSpan: 2 Layout.fillWidth: true } } // Grid SectionHeader{ id: vehicleHeader text: qsTr("Vehicle") } GridLayout { columns: 2 rowSpacing: ScreenTools.defaultFontPixelHeight * 0.5 columnSpacing: ScreenTools.defaultFontPixelHeight * 0.5 visible: vehicleHeader.checked width: parent.width QGCButton { id: buttonUpload text: qsTr("Upload") onClicked: wimaController.uploadToVehicle() Layout.fillWidth: true } QGCButton { id: buttonRemoveFromVehicle text: qsTr("Remove") onClicked: wimaController.removeFromVehicle() Layout.fillWidth: true } QGCButton { id: buttonSmartRTL text: qsTr("Smart RTL") onClicked: initSmartRTL() Layout.columnSpan: 2 Layout.fillWidth: true } // progess bar Rectangle { id: progressBar height: 4 width: _controllerProgressPct * parent.width color: qgcPal.colorGreen visible: false Layout.columnSpan: 2 Layout.fillWidth: true } QGCLabel { id: uploadCompleteText font.pointSize: ScreenTools.largeFontPointSize Layout.columnSpan: 2 horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter text: "Done" visible: false Layout.fillWidth: true } } SectionHeader { id: statsHeader text: qsTr("Statistics") } GridLayout { columns: 2 rowSpacing: ScreenTools.defaultFontPixelHeight * 0.5 anchors.topMargin: ScreenTools.defaultFontPixelHeight * 0.5 visible: statsHeader.checked QGCLabel { text: qsTr("Phase Length: ") wrapMode: Text.WordWrap Layout.fillWidth: true } QGCLabel { text: wimaController.phaseDistance >= 0 ? wimaController.phaseDistance.toFixed(2) + " m": "" wrapMode: Text.WordWrap Layout.fillWidth: true } QGCLabel { text: qsTr("Phase Duration: ") wrapMode: Text.WordWrap Layout.fillWidth: true } QGCLabel { text: wimaController.phaseDuration >= 0 ? getTime(wimaController.phaseDuration) : "" wrapMode: Text.WordWrap Layout.fillWidth: true } QGCLabel { text: "" Layout.columnSpan: 2 } } } // settingsColumn } // wrapperItem } // QGCFlickable } // Item } }