diff --git a/qgroundcontrol.pro b/qgroundcontrol.pro
index 1772719..b1ee3d0 100644
--- a/qgroundcontrol.pro
+++ b/qgroundcontrol.pro
@@ -659,6 +659,8 @@ HEADERS += \
src/QmlControls/RCToParamDialogController.h \
src/QmlControls/ScreenToolsController.h \
src/QmlControls/TerrainProfile.h \
+ src/QmlControls/ToolStripAction.h \
+ src/QmlControls/ToolStripActionList.h \
src/QtLocationPlugin/QMLControl/QGCMapEngineManager.h \
src/Settings/ADSBVehicleManagerSettings.h \
src/Settings/AppSettings.h \
@@ -867,6 +869,8 @@ SOURCES += \
src/QmlControls/RCToParamDialogController.cc \
src/QmlControls/ScreenToolsController.cc \
src/QmlControls/TerrainProfile.cc \
+ src/QmlControls/ToolStripAction.cc \
+ src/QmlControls/ToolStripActionList.cc \
src/QtLocationPlugin/QMLControl/QGCMapEngineManager.cc \
src/Settings/ADSBVehicleManagerSettings.cc \
src/Settings/AppSettings.cc \
diff --git a/qgroundcontrol.qrc b/qgroundcontrol.qrc
index 1d2f9aa..bdf6dfe 100644
--- a/qgroundcontrol.qrc
+++ b/qgroundcontrol.qrc
@@ -203,12 +203,19 @@
src/FlightDisplay/FlyViewMissionCompleteDialog.qml
src/FlightDisplay/FlyViewPreFlightChecklistPopup.qml
src/FlightDisplay/FlyViewToolStrip.qml
+ src/FlightDisplay/FlyViewToolStripActionList.qml
src/FlightDisplay/FlyViewVideo.qml
src/FlightDisplay/FlyViewWidgetLayer.qml
+ src/FlightDisplay/GuidedActionActionList.qml
src/FlightDisplay/GuidedActionConfirm.qml
- src/FlightDisplay/GuidedActionList.qml
src/FlightDisplay/GuidedActionsController.qml
+ src/FlightDisplay/GuidedActionLand.qml
+ src/FlightDisplay/GuidedActionList.qml
+ src/FlightDisplay/GuidedActionTakeoff.qml
+ src/FlightDisplay/GuidedActionPause.qml
+ src/FlightDisplay/GuidedActionRTL.qml
src/FlightDisplay/GuidedAltitudeSlider.qml
+ src/FlightDisplay/GuidedToolStripAction.qml
src/FlightDisplay/MultiVehicleList.qml
src/FlightDisplay/MultiVehiclePanel.qml
src/FlightDisplay/PreFlightBatteryCheck.qml
@@ -216,6 +223,7 @@
src/FlightDisplay/PreFlightRCCheck.qml
src/FlightDisplay/PreFlightSensorsHealthCheck.qml
src/FlightDisplay/PreFlightSoundCheck.qml
+ src/FlightDisplay/PreFlightCheckListShowAction.qml
src/FlightDisplay/TerrainProgress.qml
src/FlightDisplay/VehicleWarnings.qml
src/QmlControls/QGroundControl/FlightDisplay/qmldir
diff --git a/src/FlightDisplay/FlyViewCustomLayer.qml b/src/FlightDisplay/FlyViewCustomLayer.qml
index a123f47..a8ead7d 100644
--- a/src/FlightDisplay/FlyViewCustomLayer.qml
+++ b/src/FlightDisplay/FlyViewCustomLayer.qml
@@ -34,8 +34,8 @@ import QGroundControl.Vehicle 1.0
Item {
id: _root
- property var parentToolInsets // These insets tell you what screen real estate is available for positioning the controls in your overlay
- property var toolInsets: _toolInsets // These are the insets for your custom overlay additions
+ property var parentToolInsets // These insets tell you what screen real estate is available for positioning the controls in your overlay
+ property var totalToolInsets: _toolInsets // These are the insets for your custom overlay additions
property var mapControl
QGCToolInsets {
diff --git a/src/FlightDisplay/FlyViewPreFlightChecklistPopup.qml b/src/FlightDisplay/FlyViewPreFlightChecklistPopup.qml
index 22c4ba0..697d604 100644
--- a/src/FlightDisplay/FlyViewPreFlightChecklistPopup.qml
+++ b/src/FlightDisplay/FlyViewPreFlightChecklistPopup.qml
@@ -27,10 +27,9 @@ Popup {
clip: true
}
- property bool useChecklist: QGroundControl.settingsManager.appSettings.useChecklist.rawValue && QGroundControl.corePlugin.options.preFlightChecklistUrl.toString().length
-
property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle
- property bool _enforceChecklist: useChecklist && QGroundControl.settingsManager.appSettings.enforceChecklist.rawValue
+ property bool _useChecklist: QGroundControl.settingsManager.appSettings.useChecklist.rawValue && QGroundControl.corePlugin.options.preFlightChecklistUrl.toString().length
+ property bool _enforceChecklist: _useChecklist && QGroundControl.settingsManager.appSettings.enforceChecklist.rawValue
property bool _checklistComplete: _activeVehicle && (_activeVehicle.checkListState === Vehicle.CheckListPassed)
on_ActiveVehicleChanged: _showPreFlightChecklistIfNeeded()
diff --git a/src/FlightDisplay/FlyViewToolStrip.qml b/src/FlightDisplay/FlyViewToolStrip.qml
index 674dd31..c2b151f 100644
--- a/src/FlightDisplay/FlyViewToolStrip.qml
+++ b/src/FlightDisplay/FlyViewToolStrip.qml
@@ -7,103 +7,26 @@
*
****************************************************************************/
-import QGroundControl 1.0
-import QGroundControl.Controls 1.0
+import QtQml.Models 2.12
+
+import QGroundControl 1.0
+import QGroundControl.Controls 1.0
+import QGroundControl.FlightDisplay 1.0
ToolStrip {
- title: qsTr("Fly")
+ id: _root
+ title: qsTr("Fly")
property var guidedActionsController
property var guidedActionList
- property bool usePreFlightChecklist
signal displayPreFlightChecklist
- property bool _anyActionAvailable: guidedActionsController.showStartMission || guidedActionsController.showResumeMission || guidedActionsController.showChangeAlt || guidedActionsController.showLandAbort
- property var _actionModel: [
- {
- title: guidedActionsController.startMissionTitle,
- text: guidedActionsController.startMissionMessage,
- action: guidedActionsController.actionStartMission,
- visible: guidedActionsController.showStartMission
- },
- {
- title: guidedActionsController.continueMissionTitle,
- text: guidedActionsController.continueMissionMessage,
- action: guidedActionsController.actionContinueMission,
- visible: guidedActionsController.showContinueMission
- },
- {
- title: guidedActionsController.changeAltTitle,
- text: guidedActionsController.changeAltMessage,
- action: guidedActionsController.actionChangeAlt,
- visible: guidedActionsController.showChangeAlt
- },
- {
- title: guidedActionsController.landAbortTitle,
- text: guidedActionsController.landAbortMessage,
- action: guidedActionsController.actionLandAbort,
- visible: guidedActionsController.showLandAbort
- }
- ]
-
- model: [
- {
- name: "Checklist",
- iconSource: "/qmlimages/check.svg",
- buttonVisible: usePreFlightChecklist,
- buttonEnabled: usePreFlightChecklist && activeVehicle && !activeVehicle.armed,
- },
- {
- name: guidedActionsController.takeoffTitle,
- iconSource: "/res/takeoff.svg",
- buttonVisible: guidedActionsController.showTakeoff || !guidedActionsController.showLand,
- buttonEnabled: guidedActionsController.showTakeoff,
- action: guidedActionsController.actionTakeoff
- },
- {
- name: guidedActionsController.landTitle,
- iconSource: "/res/land.svg",
- buttonVisible: guidedActionsController.showLand && !guidedActionsController.showTakeoff,
- buttonEnabled: guidedActionsController.showLand,
- action: guidedActionsController.actionLand
- },
- {
- name: guidedActionsController.rtlTitle,
- iconSource: "/res/rtl.svg",
- buttonVisible: true,
- buttonEnabled: guidedActionsController.showRTL,
- action: guidedActionsController.actionRTL
- },
- {
- name: guidedActionsController.pauseTitle,
- iconSource: "/res/pause-mission.svg",
- buttonVisible: guidedActionsController.showPause,
- buttonEnabled: guidedActionsController.showPause,
- action: guidedActionsController.actionPause
- },
- {
- name: qsTr("Action"),
- iconSource: "/res/action.svg",
- buttonVisible: _anyActionAvailable,
- buttonEnabled: true,
- action: -1
- }
- ]
-
- onClicked: {
- if(index === 0) {
- displayPreFlightChecklist()
- } else {
- guidedActionsController.closeAll()
- var action = model[index].action
- if (action === -1) {
- guidedActionList.model = _actionModel
- guidedActionList.visible = true
- } else {
- guidedActionsController.confirmAction(action)
- }
- }
+ FlyViewToolStripActionList {
+ id: flyViewToolStripActionList
+ onDisplayPreFlightChecklist: _root.displayPreFlightChecklist()
}
+
+ model: flyViewToolStripActionList.model
}
diff --git a/src/FlightDisplay/FlyViewToolStripActionList.qml b/src/FlightDisplay/FlyViewToolStripActionList.qml
new file mode 100644
index 0000000..e08227e
--- /dev/null
+++ b/src/FlightDisplay/FlyViewToolStripActionList.qml
@@ -0,0 +1,38 @@
+/****************************************************************************
+ *
+ * (c) 2009-2020 QGROUNDCONTROL PROJECT
+ *
+ * QGroundControl is licensed according to the terms in the file
+ * COPYING.md in the root of the source code directory.
+ *
+ ****************************************************************************/
+
+import QtQml.Models 2.12
+
+import QGroundControl 1.0
+import QGroundControl.Controls 1.0
+
+ToolStripActionList {
+ signal displayPreFlightChecklist
+
+ model: [
+ PreFlightCheckListShowAction {
+ onTriggered: displayPreFlightChecklist()
+ },
+ GuidedActionTakeoff {
+ guidedController: guidedActionsController
+ },
+ GuidedActionLand {
+ guidedController: guidedActionsController
+ },
+ GuidedActionRTL {
+ guidedController: guidedActionsController
+ },
+ GuidedActionPause {
+ guidedController: guidedActionsController
+ },
+ GuidedActionActionList {
+ guidedController: guidedActionsController
+ }
+ ]
+}
diff --git a/src/FlightDisplay/FlyViewWidgetLayer.qml b/src/FlightDisplay/FlyViewWidgetLayer.qml
index 99f4a4d..2d0067e 100644
--- a/src/FlightDisplay/FlyViewWidgetLayer.qml
+++ b/src/FlightDisplay/FlyViewWidgetLayer.qml
@@ -38,7 +38,7 @@ Item {
property var mapControl
property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle
- property var _planMasterController: mainWindow.planMasterControllerPlanView
+ property var _planMasterController: mainWindow.planMasterControllerFlyView
property var _missionController: _planMasterController.missionController
property var _geoFenceController: _planMasterController.geoFenceController
property var _rallyPointController: _planMasterController.rallyPointController
@@ -115,7 +115,6 @@ Item {
maxHeight: parent.height - y - parentToolInsets.leftEdgeBottomInset - _toolsMargin
guidedActionsController: _guidedController
guidedActionList: _guidedActionList
- usePreFlightChecklist: preFlightChecklistPopup.useChecklist
visible: !QGroundControl.videoManager.fullScreen
onDisplayPreFlightChecklist: preFlightChecklistPopup.open()
diff --git a/src/FlightDisplay/GuidedActionActionList.qml b/src/FlightDisplay/GuidedActionActionList.qml
new file mode 100644
index 0000000..383e8a9
--- /dev/null
+++ b/src/FlightDisplay/GuidedActionActionList.qml
@@ -0,0 +1,18 @@
+/****************************************************************************
+ *
+ * (c) 2009-2020 QGROUNDCONTROL PROJECT
+ *
+ * QGroundControl is licensed according to the terms in the file
+ * COPYING.md in the root of the source code directory.
+ *
+ ****************************************************************************/
+
+import QGroundControl.FlightDisplay 1.0
+
+GuidedToolStripAction {
+ text: guidedController.actionListTitle
+ iconSource: "/res/action.svg"
+ visible: guidedController.showActionList
+ enabled: true
+ actionID: guidedController.actionActionList
+}
diff --git a/src/FlightDisplay/GuidedActionLand.qml b/src/FlightDisplay/GuidedActionLand.qml
new file mode 100644
index 0000000..164598b
--- /dev/null
+++ b/src/FlightDisplay/GuidedActionLand.qml
@@ -0,0 +1,19 @@
+/****************************************************************************
+ *
+ * (c) 2009-2020 QGROUNDCONTROL PROJECT
+ *
+ * QGroundControl is licensed according to the terms in the file
+ * COPYING.md in the root of the source code directory.
+ *
+ ****************************************************************************/
+
+import QGroundControl.FlightDisplay 1.0
+
+GuidedToolStripAction {
+ text: guidedController.landTitle
+ message: guidedController.landMessage
+ iconSource: "/res/land.svg"
+ visible: guidedController.showLand && !guidedController.showTakeoff
+ enabled: guidedController.showLand
+ actionID: guidedController.actionLand
+}
diff --git a/src/FlightDisplay/GuidedActionList.qml b/src/FlightDisplay/GuidedActionList.qml
index c4a43e7..f72e253 100644
--- a/src/FlightDisplay/GuidedActionList.qml
+++ b/src/FlightDisplay/GuidedActionList.qml
@@ -14,6 +14,7 @@ import QtQuick.Layouts 1.2
import QGroundControl 1.0
import QGroundControl.ScreenTools 1.0
import QGroundControl.Controls 1.0
+import QGroundControl.FlightDisplay 1.0
import QGroundControl.Palette 1.0
/// Dialog showing list of available guided actions
@@ -28,12 +29,41 @@ Rectangle {
property var guidedController
property var altitudeSlider
- property alias model: actionRepeater.model
+
+ function show() {
+ visible = true
+ }
property real _margins: Math.round(ScreenTools.defaultFontPixelHeight * 0.66)
property real _actionWidth: ScreenTools.defaultFontPixelWidth * 25
property real _actionHorizSpacing: ScreenTools.defaultFontPixelHeight * 2
+ property var _model: [
+ {
+ title: guidedController.startMissionTitle,
+ text: guidedController.startMissionMessage,
+ action: guidedController.actionStartMission,
+ visible: guidedController.showStartMission
+ },
+ {
+ title: guidedController.continueMissionTitle,
+ text: guidedController.continueMissionMessage,
+ action: guidedController.actionContinueMission,
+ visible: guidedController.showContinueMission
+ },
+ {
+ title: guidedController.changeAltTitle,
+ text: guidedController.changeAltMessage,
+ action: guidedController.actionChangeAlt,
+ visible: guidedController.showChangeAlt
+ },
+ {
+ title: guidedController.landAbortTitle,
+ text: guidedController.landAbortMessage,
+ action: guidedController.actionLandAbort,
+ visible: guidedController.showLandAbort
+ }
+ ]
QGCPalette { id: qgcPal }
@@ -67,7 +97,8 @@ Rectangle {
spacing: _actionHorizSpacing
Repeater {
- id: actionRepeater
+ id: actionRepeater
+ model: _model
ColumnLayout {
spacing: ScreenTools.defaultFontPixelHeight / 2
diff --git a/src/FlightDisplay/GuidedActionPause.qml b/src/FlightDisplay/GuidedActionPause.qml
new file mode 100644
index 0000000..ce90804
--- /dev/null
+++ b/src/FlightDisplay/GuidedActionPause.qml
@@ -0,0 +1,18 @@
+/****************************************************************************
+ *
+ * (c) 2009-2020 QGROUNDCONTROL PROJECT
+ *
+ * QGroundControl is licensed according to the terms in the file
+ * COPYING.md in the root of the source code directory.
+ *
+ ****************************************************************************/
+
+import QGroundControl.FlightDisplay 1.0
+
+GuidedToolStripAction {
+ text: guidedController.pauseTitle
+ iconSource: "/res/pause-mission.svg"
+ visible: guidedController.showPause
+ enabled: guidedController.showPause
+ actionID: guidedController.actionPause
+}
diff --git a/src/FlightDisplay/GuidedActionRTL.qml b/src/FlightDisplay/GuidedActionRTL.qml
new file mode 100644
index 0000000..7280edd
--- /dev/null
+++ b/src/FlightDisplay/GuidedActionRTL.qml
@@ -0,0 +1,18 @@
+/****************************************************************************
+ *
+ * (c) 2009-2020 QGROUNDCONTROL PROJECT
+ *
+ * QGroundControl is licensed according to the terms in the file
+ * COPYING.md in the root of the source code directory.
+ *
+ ****************************************************************************/
+
+import QGroundControl.FlightDisplay 1.0
+
+GuidedToolStripAction {
+ text: guidedController.rtlTitle
+ iconSource: "/res/rtl.svg"
+ visible: true
+ enabled: guidedController.showRTL
+ actionID: guidedController.actionRTL
+}
diff --git a/src/FlightDisplay/GuidedActionTakeoff.qml b/src/FlightDisplay/GuidedActionTakeoff.qml
new file mode 100644
index 0000000..04805b2
--- /dev/null
+++ b/src/FlightDisplay/GuidedActionTakeoff.qml
@@ -0,0 +1,18 @@
+/****************************************************************************
+ *
+ * (c) 2009-2020 QGROUNDCONTROL PROJECT
+ *
+ * QGroundControl is licensed according to the terms in the file
+ * COPYING.md in the root of the source code directory.
+ *
+ ****************************************************************************/
+
+import QGroundControl.FlightDisplay 1.0
+
+GuidedToolStripAction {
+ text: guidedController.takeoffTitle
+ iconSource: "/res/takeoff.svg"
+ visible: guidedController.showTakeoff || !guidedController.showLand
+ enabled: guidedController.showTakeoff
+ actionID: guidedController.actionTakeoff
+}
diff --git a/src/FlightDisplay/GuidedActionsController.qml b/src/FlightDisplay/GuidedActionsController.qml
index 1179b66..9d52930 100644
--- a/src/FlightDisplay/GuidedActionsController.qml
+++ b/src/FlightDisplay/GuidedActionsController.qml
@@ -52,6 +52,7 @@ Item {
readonly property string gotoTitle: qsTr("Go To Location")
readonly property string vtolTransitionTitle: qsTr("VTOL Transition")
readonly property string roiTitle: qsTr("ROI")
+ readonly property string actionListTitle: qsTr("Action")
readonly property string armMessage: qsTr("Arm the vehicle.")
readonly property string disarmMessage: qsTr("Disarm the vehicle")
@@ -95,6 +96,7 @@ Item {
readonly property int actionVtolTransitionToFwdFlight: 20
readonly property int actionVtolTransitionToMRFlight: 21
readonly property int actionROI: 22
+ readonly property int actionActionList: 23
property bool _useChecklist: QGroundControl.settingsManager.appSettings.useChecklist.rawValue && QGroundControl.corePlugin.options.preFlightChecklistUrl.toString().length
property bool _enforceChecklist: _useChecklist && QGroundControl.settingsManager.appSettings.enforceChecklist.rawValue
@@ -114,6 +116,7 @@ Item {
property bool showROI: _guidedActionsEnabled && !_hideROI && _vehicleFlying && activeVehicle.roiModeSupported && !_missionActive
property bool showLandAbort: _guidedActionsEnabled && _vehicleFlying && _fixedWingOnApproach
property bool showGotoLocation: _guidedActionsEnabled && _vehicleFlying
+ property bool showActionList: _guidedActionsEnabled && (showStartMission || showResumeMission || showChangeAlt || showLandAbort)
// Note: The '_missionItemCount - 2' is a hack to not trigger resume mission when a mission ends with an RTL item
property bool showResumeMission: activeVehicle && !_vehicleArmed && _vehicleWasFlying && _missionAvailable && _resumeMissionIndex > 0 && (_resumeMissionIndex < _missionItemCount - 2)
@@ -412,6 +415,9 @@ Item {
confirmDialog.message = roiMessage
confirmDialog.hideTrigger = Qt.binding(function() { return !showROI })
break;
+ case actionActionList:
+ actionList.show()
+ return
default:
console.warn("Unknown actionCode", actionCode)
return
diff --git a/src/FlightDisplay/GuidedToolStripAction.qml b/src/FlightDisplay/GuidedToolStripAction.qml
new file mode 100644
index 0000000..3b76dcf
--- /dev/null
+++ b/src/FlightDisplay/GuidedToolStripAction.qml
@@ -0,0 +1,27 @@
+/****************************************************************************
+ *
+ * (c) 2009-2020 QGROUNDCONTROL PROJECT
+ *
+ * QGroundControl is licensed according to the terms in the file
+ * COPYING.md in the root of the source code directory.
+ *
+ ****************************************************************************/
+
+import QGroundControl.Controls 1.0
+
+ToolStripAction {
+ property var guidedController
+ property int actionID
+ property string message
+
+ onTriggered: {
+ guidedActionsController.closeAll()
+ if (actionID === -1) {
+ // FIXME: NYI
+ guidedActionList.model = _actionModel
+ guidedActionList.visible = true
+ } else {
+ guidedController.confirmAction(actionID)
+ }
+ }
+}
diff --git a/src/FlightDisplay/PreFlightCheckListShowAction.qml b/src/FlightDisplay/PreFlightCheckListShowAction.qml
new file mode 100644
index 0000000..8626a06
--- /dev/null
+++ b/src/FlightDisplay/PreFlightCheckListShowAction.qml
@@ -0,0 +1,21 @@
+/****************************************************************************
+ *
+ * (c) 2009-2020 QGROUNDCONTROL PROJECT
+ *
+ * QGroundControl is licensed according to the terms in the file
+ * COPYING.md in the root of the source code directory.
+ *
+ ****************************************************************************/
+
+import QGroundControl 1.0
+import QGroundControl.Controls 1.0
+
+ToolStripAction {
+ text: qsTr("Checklist")
+ iconSource: "/qmlimages/check.svg"
+ visible: _useChecklist
+ enabled: _useChecklist && _activeVehicle && !_activeVehicle.armed
+
+ property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle
+ property bool _useChecklist: QGroundControl.settingsManager.appSettings.useChecklist.rawValue && QGroundControl.corePlugin.options.preFlightChecklistUrl.toString().length
+}
diff --git a/src/PlanView/PlanView.qml b/src/PlanView/PlanView.qml
index 2a71bb7..560697f 100644
--- a/src/PlanView/PlanView.qml
+++ b/src/PlanView/PlanView.qml
@@ -277,13 +277,11 @@ Item {
function insertROIAfterCurrent(coordinate) {
var nextIndex = _missionController.currentPlanViewVIIndex + 1
_missionController.insertROIMissionItem(coordinate, nextIndex, true /* makeCurrentItem */)
- _addROIOnClick = false
}
function insertCancelROIAfterCurrent() {
var nextIndex = _missionController.currentPlanViewVIIndex + 1
_missionController.insertCancelROIMissionItem(nextIndex, true /* makeCurrentItem */)
- _addROIOnClick = false
}
function insertComplexItemAfterCurrent(complexItemName) {
@@ -421,8 +419,8 @@ Item {
if (_addWaypointOnClick) {
insertSimpleItemAfterCurrent(coordinate)
} else if (_addROIOnClick) {
- _addROIOnClick = false
insertROIAfterCurrent(coordinate)
+ _addROIOnClick = false
}
break
@@ -589,117 +587,95 @@ Item {
property bool _isRallyLayer: _editingLayer == _layerRallyPoints
property bool _isMissionLayer: _editingLayer == _layerMission
- model: [
- /*{
- name: qsTr("Fly"),
- iconSource: "/qmlimages/PaperPlane.svg",
- buttonEnabled: true,
- buttonVisible: true,
- },*/
- {
- name: qsTr("File"),
- iconSource: "/qmlimages/MapSync.svg",
- buttonEnabled: !_planMasterController.syncInProgress,
- buttonVisible: true,
- showAlternateIcon: _planMasterController.dirty,
- alternateIconSource:"/qmlimages/MapSyncChanged.svg",
- dropPanelComponent: syncDropPanel
- },
- {
- name: qsTr("Takeoff"),
- iconSource: "/res/takeoff.svg",
- buttonEnabled: _missionController.isInsertTakeoffValid,
- buttonVisible: _isMissionLayer
- },
- {
- name: _editingLayer == _layerRallyPoints ? qsTr("Rally Point") : qsTr("Waypoint"),
- iconSource: "/qmlimages/MapAddMission.svg",
- buttonEnabled: _isRallyLayer ? true : _missionController.flyThroughCommandsAllowed,
- buttonVisible: _isRallyLayer || _isMissionLayer,
- toggle: true,
- checked: _addWaypointOnClick
- },
- {
- name: _missionController.isROIActive ? qsTr("Cancel ROI") : qsTr("ROI"),
- iconSource: "/qmlimages/MapAddMission.svg",
- buttonEnabled: !_missionController.onlyInsertTakeoffValid,
- buttonVisible: _isMissionLayer && _planMasterController.controllerVehicle.roiModeSupported,
- toggle: !_missionController.isROIActive
- },
- {
- name: _singleComplexItem ? _missionController.complexMissionItemNames[0] : qsTr("Pattern"),
- iconSource: "/qmlimages/MapDrawShape.svg",
- buttonEnabled: _missionController.flyThroughCommandsAllowed,
- buttonVisible: _isMissionLayer,
- dropPanelComponent: _singleComplexItem ? undefined : patternDropPanel
- },
- {
- name: _planMasterController.controllerVehicle.multiRotor ? qsTr("Return") : qsTr("Land"),
- iconSource: "/res/rtl.svg",
- buttonEnabled: _missionController.isInsertLandValid,
- buttonVisible: _isMissionLayer
- },
- {
- name: qsTr("Center"),
- iconSource: "/qmlimages/MapCenter.svg",
- buttonEnabled: true,
- buttonVisible: true,
- dropPanelComponent: centerMapDropPanel
- }
- ]
+ ToolStripActionList {
+ id: toolStripActionList
+ model: [
+ ToolStripAction {
+ text: qsTr("File")
+ enabled: !_planMasterController.syncInProgress
+ visible: true
+ showAlternateIcon: _planMasterController.dirty
+ iconSource: "/qmlimages/MapSync.svg"
+ alternateIconSource: "/qmlimages/MapSyncChanged.svg"
+ dropPanelComponent: syncDropPanel
+ },
+ ToolStripAction {
+ text: qsTr("Takeoff")
+ iconSource: "/res/takeoff.svg"
+ enabled: _missionController.isInsertTakeoffValid
+ visible: toolStrip._isMissionLayer
+ onTriggered: {
+ toolStrip.allAddClickBoolsOff()
+ insertTakeItemAfterCurrent()
+ }
+ },
+ ToolStripAction {
+ text: _editingLayer == _layerRallyPoints ? qsTr("Rally Point") : qsTr("Waypoint")
+ iconSource: "/qmlimages/MapAddMission.svg"
+ enabled: toolStrip._isRallyLayer ? true : _missionController.flyThroughCommandsAllowed
+ visible: toolStrip._isRallyLayer || toolStrip._isMissionLayer
+ checkable: true
+ onCheckedChanged: _addWaypointOnClick = checked
+ property bool myAddWaypointOnClick: _addWaypointOnClick
+ onMyAddWaypointOnClickChanged: checked = _addWaypointOnClick
+ },
+ ToolStripAction {
+ text: _missionController.isROIActive ? qsTr("Cancel ROI") : qsTr("ROI")
+ iconSource: "/qmlimages/MapAddMission.svg"
+ enabled: !_missionController.onlyInsertTakeoffValid
+ visible: toolStrip._isMissionLayer && _planMasterController.controllerVehicle.roiModeSupported
+ checkable: !_missionController.isROIActive
+ onCheckedChanged: _addROIOnClick = checked
+ onTriggered: {
+ if (_missionController.isROIActive) {
+ toolStrip.allAddClickBoolsOff()
+ insertCancelROIAfterCurrent()
+ }
+ }
+ property bool myAddROIOnClick: _addROIOnClick
+ onMyAddROIOnClickChanged: checked = _addROIOnClick
+ },
+ ToolStripAction {
+ text: _singleComplexItem ? _missionController.complexMissionItemNames[0] : qsTr("Pattern")
+ iconSource: "/qmlimages/MapDrawShape.svg"
+ enabled: _missionController.flyThroughCommandsAllowed
+ visible: toolStrip._isMissionLayer
+ dropPanelComponent: _singleComplexItem ? undefined : patternDropPanel
+ onTriggered: {
+ toolStrip.allAddClickBoolsOff()
+ if (_singleComplexItem) {
+ insertComplexItemAfterCurrent(_missionController.complexMissionItemNames[0])
+ }
+ }
+ },
+ ToolStripAction {
+ text: _planMasterController.controllerVehicle.multiRotor ? qsTr("Return") : qsTr("Land")
+ iconSource: "/res/rtl.svg"
+ enabled: _missionController.isInsertLandValid
+ visible: toolStrip._isMissionLayer
+ onTriggered: {
+ toolStrip.allAddClickBoolsOff()
+ insertLandItemAfterCurrent()
+ }
+ },
+ ToolStripAction {
+ text: qsTr("Center")
+ iconSource: "/qmlimages/MapCenter.svg"
+ enabled: true
+ visible: true
+ dropPanelComponent: centerMapDropPanel
+ }
+ ]
+ }
+
+ model: toolStripActionList.model
function allAddClickBoolsOff() {
_addROIOnClick = false
_addWaypointOnClick = false
}
- onClicked: {
- switch (index) {
- /*case flyButtonIndex:
- mainWindow.showFlyView()
- break*/
- case takeoffButtonIndex:
- allAddClickBoolsOff()
- insertTakeItemAfterCurrent()
- break
- case waypointButtonIndex:
- if (_addWaypointOnClick) {
- allAddClickBoolsOff()
- setChecked(index, false)
- } else {
- allAddClickBoolsOff()
- _addWaypointOnClick = checked
- }
- break
- case roiButtonIndex:
- if (_addROIOnClick) {
- allAddClickBoolsOff()
- setChecked(index, false)
- } else {
- allAddClickBoolsOff()
- if (_missionController.isROIActive) {
- insertCancelROIAfterCurrent()
- } else {
- _addROIOnClick = checked
- }
- }
- break
- case patternButtonIndex:
- allAddClickBoolsOff()
- if (_singleComplexItem) {
- insertComplexItemAfterCurrent(_missionController.complexMissionItemNames[0])
- }
- break
- case landButtonIndex:
- allAddClickBoolsOff()
- insertLandItemAfterCurrent()
- break
- }
- }
-
- onDropped: {
- allAddClickBoolsOff()
- }
+ onDropped: allAddClickBoolsOff()
}
//-----------------------------------------------------------
@@ -879,26 +855,6 @@ Item {
}
}
- /*MissionItemStatus {
- id: waypointValuesDisplay
- anchors.margins: _toolsMargin
- anchors.left: toolStrip.right
- anchors.bottom: mapScale.top
- height: ScreenTools.defaultFontPixelHeight * 7
- maxWidth: rightPanel.x - x - anchors.margins
- missionController: _missionController
- visible: _internalVisible && _editingLayer === _layerMission && QGroundControl.corePlugin.options.showMissionStatus
-
- onSetCurrentSeqNum: _missionController.setCurrentPlanViewSeqNum(seqNum, true)
-
- property bool _internalVisible: _planViewSettings.showMissionItemStatus.rawValue
-
- function toggleVisible() {
- _internalVisible = !_internalVisible
- _planViewSettings.showMissionItemStatus.rawValue = _internalVisible
- }
- }*/
-
TerrainStatus {
id: terrainStatus
anchors.margins: _toolsMargin
@@ -929,7 +885,6 @@ Item {
buttonsOnLeft: true
terrainButtonVisible: _editingLayer === _layerMission
terrainButtonChecked: terrainStatus.visible
- //z: QGroundControl.zOrderMapItems
onTerrainButtonClicked: terrainStatus.toggleVisible()
}
}
diff --git a/src/QGCApplication.cc b/src/QGCApplication.cc
index 249062a..526fab0 100644
--- a/src/QGCApplication.cc
+++ b/src/QGCApplication.cc
@@ -106,6 +106,8 @@
#include "RCToParamDialogController.h"
#include "QGCImageProvider.h"
#include "TerrainProfile.h"
+#include "ToolStripAction.h"
+#include "ToolStripActionList.h"
#if defined(QGC_ENABLE_PAIRING)
#include "PairingManager.h"
@@ -559,6 +561,8 @@ void QGCApplication::_initCommon()
qmlRegisterType (kQGCControllers, 1, 0, "RCToParamDialogController");
qmlRegisterType ("QGroundControl.Controls", 1, 0, "TerrainProfile");
+ qmlRegisterType ("QGroundControl.Controls", 1, 0, "ToolStripAction");
+ qmlRegisterType ("QGroundControl.Controls", 1, 0, "ToolStripActionList");
#ifndef __mobile__
#ifndef NO_SERIAL_LINK
diff --git a/src/QmlControls/DropPanel.qml b/src/QmlControls/DropPanel.qml
index 2137ccc..068fe55 100644
--- a/src/QmlControls/DropPanel.qml
+++ b/src/QmlControls/DropPanel.qml
@@ -40,8 +40,10 @@ Item {
property real _viewportMaxBottom: parent.parent.height - parent.y
property real _viewportMaxHeight: _viewportMaxBottom - _viewportMaxTop
property var _dropPanelCancel
+ property var _parentButton
- function show(panelEdgeTopPoint, panelComponent) {
+ function show(panelEdgeTopPoint, panelComponent, parentButton) {
+ _parentButton = parentButton
_dropEdgeTopPoint = panelEdgeTopPoint
_dropDownComponent = panelComponent
_calcPositions()
@@ -52,13 +54,9 @@ Item {
function hide() {
if (_dropPanelCancel) {
_dropPanelCancel.destroy()
- }
- if (visible) {
+ _parentButton.checked = false
visible = false
_dropDownComponent = undefined
- if (toolStrip.lastClickedButton) {
- toolStrip.lastClickedButton.checked = false
- }
}
}
diff --git a/src/QmlControls/QGroundControl/FlightDisplay/qmldir b/src/QmlControls/QGroundControl/FlightDisplay/qmldir
index 073474c..662b1b1 100644
--- a/src/QmlControls/QGroundControl/FlightDisplay/qmldir
+++ b/src/QmlControls/QGroundControl/FlightDisplay/qmldir
@@ -9,12 +9,19 @@ FlyViewMap 1.0 FlyViewMap.qml
FlyViewMissionCompleteDialog 1.0 FlyViewMissionCompleteDialog.qml
FlyViewPreFlightChecklistPopup 1.0 FlyViewPreFlightChecklistPopup.qml
FlyViewToolStrip 1.0 FlyViewToolStrip.qml
+FlyViewToolStripActionList 1.0 FlyViewToolStripActionList.qml
FlyViewVideo 1.0 FlyViewVideo.qml
FlyViewWidgetLayer 1.0 FlyViewWidgetLayer.qml
+GuidedActionActionList 1.0 GuidedActionActionList.qml
GuidedActionConfirm 1.0 GuidedActionConfirm.qml
-GuidedActionList 1.0 GuidedActionList.qml
GuidedActionsController 1.0 GuidedActionsController.qml
+GuidedActionLand 1.0 GuidedActionLand.qml
+GuidedActionList 1.0 GuidedActionList.qml
+GuidedActionPause 1.0 GuidedActionPause.qml
+GuidedActionRTL 1.0 GuidedActionRTL.qml
GuidedAltitudeSlider 1.0 GuidedAltitudeSlider.qml
+GuidedActionTakeoff 1.0 GuidedActionTakeoff.qml
+GuidedToolStripAction 1.0 GuidedToolStripAction.qml
MultiVehicleList 1.0 MultiVehicleList.qml
MultiVehiclePanel 1.0 MultiVehiclePanel.qml
PreFlightBatteryCheck 1.0 PreFlightBatteryCheck.qml
diff --git a/src/QmlControls/ToolStrip.qml b/src/QmlControls/ToolStrip.qml
index 249d731..4740836 100644
--- a/src/QmlControls/ToolStrip.qml
+++ b/src/QmlControls/ToolStrip.qml
@@ -26,35 +26,16 @@ Rectangle {
property real maxHeight ///< Maximum height for control, determines whether text is hidden to make control shorter
property alias title: titleLabel.text
- property AbstractButton lastClickedButton: null
-
function simulateClick(buttonIndex) {
buttonIndex = buttonIndex + 1 // skip over title
- if (!toolStripColumn.children[buttonIndex].checked) {
- toolStripColumn.children[buttonIndex].checked = true
- toolStripColumn.children[buttonIndex].clicked()
- }
+ toolStripColumn.children[buttonIndex].clicked()
}
// Ensure we don't get narrower than content
property real _idealWidth: (ScreenTools.isMobile ? ScreenTools.minTouchPixels : ScreenTools.defaultFontPixelWidth * 8) + toolStripColumn.anchors.margins * 2
- signal clicked(int index, bool checked)
signal dropped(int index)
- function setChecked(idx, check) {
- repeater.itemAt(idx).checked = check
- }
-
- function getChecked(idx) {
- return repeater.itemAt(idx).checked
- }
-
- ButtonGroup {
- id: buttonGroup
- buttons: toolStripColumn.children
- }
-
DeadMouseArea {
anchors.fill: parent
}
@@ -98,27 +79,25 @@ Rectangle {
fontPointSize: ScreenTools.smallFontPointSize
autoExclusive: true
- enabled: modelData.buttonEnabled
- visible: modelData.buttonVisible
+ enabled: modelData.enabled
+ visible: modelData.visible
imageSource: modelData.showAlternateIcon ? modelData.alternateIconSource : modelData.iconSource
- text: modelData.name
- checked: modelData.checked !== undefined ? modelData.checked : checked
+ text: modelData.text
+ checked: modelData.checked
+ checkable: modelData.dropPanelComponent || modelData.checkable
- ButtonGroup.group: buttonGroup
- // Only drop panel and toggleable are checkable
- checkable: modelData.dropPanelComponent !== undefined || (modelData.toggle !== undefined && modelData.toggle)
+ onCheckedChanged: modelData.checked = checked
onClicked: {
- dropPanel.hide() // DropPanel will call hide on "lastClickedButton"
- if (modelData.dropPanelComponent === undefined) {
- _root.clicked(index, checked)
+ dropPanel.hide()
+ if (!modelData.dropPanelComponent) {
+ modelData.triggered(this)
} else if (checked) {
var panelEdgeTopPoint = mapToItem(_root, width, 0)
- dropPanel.show(panelEdgeTopPoint, modelData.dropPanelComponent)
+ dropPanel.show(panelEdgeTopPoint, modelData.dropPanelComponent, this)
+ checked = true
_root.dropped(index)
}
- if(_root && buttonTemplate)
- _root.lastClickedButton = buttonTemplate
}
}
}
diff --git a/src/QmlControls/ToolStripAction.cc b/src/QmlControls/ToolStripAction.cc
new file mode 100644
index 0000000..97fd27c
--- /dev/null
+++ b/src/QmlControls/ToolStripAction.cc
@@ -0,0 +1,92 @@
+/****************************************************************************
+ *
+ * (c) 2009-2020 QGROUNDCONTROL PROJECT
+ *
+ * QGroundControl is licensed according to the terms in the file
+ * COPYING.md in the root of the source code directory.
+ *
+ ****************************************************************************/
+
+#include "ToolStripAction.h"
+
+ToolStripAction::ToolStripAction(QObject* parent)
+ : QObject(parent)
+{
+
+}
+
+void ToolStripAction::setEnabled(bool enabled)
+{
+ if (enabled != _enabled) {
+ _enabled = enabled;
+ emit enabledChanged(enabled);
+ }
+}
+
+void ToolStripAction::setVisible(bool visible)
+{
+ if (visible != _visible) {
+ _visible = visible;
+ emit visibleChanged(visible);
+ }
+
+}
+
+void ToolStripAction::setCheckable(bool checkable)
+{
+ if (checkable != _checkable) {
+ _checkable = checkable;
+ emit checkableChanged(checkable);
+ }
+
+}
+
+void ToolStripAction::setChecked(bool checked)
+{
+ if (checked != _checked) {
+ _checked = checked;
+ emit checkedChanged(checked);
+ }
+
+}
+
+void ToolStripAction::setShowAlternateIcon(bool showAlternateIcon)
+{
+ if (showAlternateIcon != _showAlternateIcon) {
+ _showAlternateIcon = showAlternateIcon;
+ emit showAlternateIconChanged(showAlternateIcon);
+ }
+
+}
+
+void ToolStripAction::setText(const QString& text)
+{
+ if (text != _text) {
+ _text = text;
+ emit textChanged(text);
+ }
+
+}
+
+void ToolStripAction::setIconSource(const QString& iconSource)
+{
+ if (iconSource != _iconSource) {
+ _iconSource = iconSource;
+ emit iconSourceChanged(iconSource);
+ }
+
+}
+
+void ToolStripAction::setAlternateIconSource(const QString& alternateIconSource)
+{
+ if (alternateIconSource != _alternateIconSource) {
+ _alternateIconSource = alternateIconSource;
+ emit alternateIconSourceChanged(alternateIconSource);
+ }
+}
+
+void ToolStripAction::setDropPanelComponent(QQmlComponent* dropPanelComponent)
+{
+ _dropPanelComponent = dropPanelComponent;
+ emit dropPanelComponentChanged();
+}
diff --git a/src/QmlControls/ToolStripAction.h b/src/QmlControls/ToolStripAction.h
new file mode 100644
index 0000000..8fb3098
--- /dev/null
+++ b/src/QmlControls/ToolStripAction.h
@@ -0,0 +1,75 @@
+/****************************************************************************
+ *
+ * (c) 2009-2020 QGROUNDCONTROL PROJECT
+ *
+ * QGroundControl is licensed according to the terms in the file
+ * COPYING.md in the root of the source code directory.
+ *
+ ****************************************************************************/
+
+#pragma once
+
+#include
+#include
+#include
+
+class ToolStripAction : public QObject
+{
+ Q_OBJECT
+
+public:
+ ToolStripAction(QObject* parent = nullptr);
+
+ Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged)
+ Q_PROPERTY(bool visible READ visible WRITE setVisible NOTIFY visibleChanged)
+ Q_PROPERTY(bool checkable READ checkable WRITE setCheckable NOTIFY checkableChanged)
+ Q_PROPERTY(bool checked READ checked WRITE setChecked NOTIFY checkedChanged)
+ Q_PROPERTY(bool showAlternateIcon READ showAlternateIcon WRITE setShowAlternateIcon NOTIFY showAlternateIconChanged)
+ Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged)
+ Q_PROPERTY(QString iconSource READ iconSource WRITE setIconSource NOTIFY iconSourceChanged)
+ Q_PROPERTY(QString alternateIconSource READ alternateIconSource WRITE setAlternateIconSource NOTIFY alternateIconSourceChanged)
+ Q_PROPERTY(QQmlComponent* dropPanelComponent READ dropPanelComponent WRITE setDropPanelComponent NOTIFY dropPanelComponentChanged)
+
+ bool enabled (void) const { return _enabled; }
+ bool visible (void) const { return _visible; }
+ bool checkable (void) const { return _checkable; }
+ bool checked (void) const { return _checked; }
+ bool showAlternateIcon (void) const { return _showAlternateIcon; }
+ QString text (void) const { return _text; }
+ QString iconSource (void) const { return _iconSource; }
+ QString alternateIconSource (void) const { return _alternateIconSource; }
+ QQmlComponent* dropPanelComponent (void) const { return _dropPanelComponent; }
+
+ void setEnabled (bool enabled);
+ void setVisible (bool visible);
+ void setCheckable (bool checkable);
+ void setChecked (bool checked);
+ void setShowAlternateIcon (bool showAlternateIcon);
+ void setText (const QString& text);
+ void setIconSource (const QString& iconSource);
+ void setAlternateIconSource (const QString& alternateIconSource);
+ void setDropPanelComponent (QQmlComponent* dropPanelComponent);
+
+signals:
+ void enabledChanged (bool enabled);
+ void visibleChanged (bool visible);
+ void checkableChanged (bool checkable);
+ void checkedChanged (bool checked);
+ void showAlternateIconChanged (bool showAlternateIcon);
+ void textChanged (QString text);
+ void iconSourceChanged (QString iconSource);
+ void alternateIconSourceChanged (QString alternateIconSource);
+ void triggered (QObject* source);
+ void dropPanelComponentChanged (void);
+
+protected:
+ bool _enabled = true;
+ bool _visible = true;
+ bool _checkable = false;
+ bool _checked = false;
+ bool _showAlternateIcon = false;
+ QString _text;
+ QString _iconSource;
+ QString _alternateIconSource;
+ QQmlComponent* _dropPanelComponent = nullptr;
+};
diff --git a/src/QmlControls/ToolStripActionList.cc b/src/QmlControls/ToolStripActionList.cc
new file mode 100644
index 0000000..8425305
--- /dev/null
+++ b/src/QmlControls/ToolStripActionList.cc
@@ -0,0 +1,41 @@
+/****************************************************************************
+ *
+ * (c) 2009-2020 QGROUNDCONTROL PROJECT
+ *
+ * QGroundControl is licensed according to the terms in the file
+ * COPYING.md in the root of the source code directory.
+ *
+ ****************************************************************************/
+
+#include "ToolStripActionList.h"
+
+ToolStripActionList::ToolStripActionList(QObject* parent)
+ : QObject(parent)
+{
+
+}
+
+QQmlListProperty ToolStripActionList::model(void)
+{
+ return QQmlListProperty(this, this,
+ &ToolStripActionList::append,
+ &ToolStripActionList::count,
+ &ToolStripActionList::at,
+ &ToolStripActionList::clear);
+}
+
+void ToolStripActionList::append(QQmlListProperty* qmlListProperty, QObject* value) {
+ reinterpret_cast(qmlListProperty->data)->_objectList.append(value);
+}
+
+void ToolStripActionList::clear(QQmlListProperty* qmlListProperty) {
+ reinterpret_cast(qmlListProperty->data)->_objectList.clear();
+}
+
+QObject* ToolStripActionList::at(QQmlListProperty* qmlListProperty, int index) {
+ return reinterpret_cast(qmlListProperty->data)->_objectList[index];
+}
+
+int ToolStripActionList::count(QQmlListProperty* qmlListProperty) {
+ return reinterpret_cast(qmlListProperty->data)->_objectList.count();
+}
diff --git a/src/QmlControls/ToolStripActionList.h b/src/QmlControls/ToolStripActionList.h
new file mode 100644
index 0000000..ac01765
--- /dev/null
+++ b/src/QmlControls/ToolStripActionList.h
@@ -0,0 +1,36 @@
+/****************************************************************************
+ *
+ * (c) 2009-2020 QGROUNDCONTROL PROJECT
+ *
+ * QGroundControl is licensed according to the terms in the file
+ * COPYING.md in the root of the source code directory.
+ *
+ ****************************************************************************/
+
+#pragma once
+
+#include
+#include
+
+class ToolStripActionList : public QObject
+{
+ Q_OBJECT
+
+public:
+ ToolStripActionList(QObject* parent = nullptr);
+
+ Q_PROPERTY(QQmlListProperty model READ model NOTIFY modelChanged)
+
+ QQmlListProperty model();
+
+signals:
+ void modelChanged(void);
+
+private:
+ static void append (QQmlListProperty* qmlListProperty, QObject* value);
+ static int count (QQmlListProperty* qmlListProperty);
+ static QObject* at (QQmlListProperty*, int index);
+ static void clear (QQmlListProperty* qmlListProperty);
+
+ QList _objectList;
+};