Browse Source

Use ToolStrip on fly view

QGC4.4
Don Gagne 8 years ago
parent
commit
6bf85ada2b
  1. 201
      src/FlightDisplay/FlightDisplayViewMap.qml

201
src/FlightDisplay/FlightDisplayViewMap.qml

@ -71,151 +71,106 @@ FlightMap {
Component.onCompleted: start(false /* editMode */) Component.onCompleted: start(false /* editMode */)
} }
QGCMapLabel {
id: flyLabel
map: flightMap
text: qsTr("Fly")
visible: !ScreenTools.isShortScreen
anchors.topMargin: _toolButtonTopMargin
anchors.horizontalCenter: centerMapDropButton.horizontalCenter
anchors.top: parent.top
}
//-- Vertical Tool Buttons
ExclusiveGroup { ExclusiveGroup {
id: dropButtonsExclusiveGroup id: _mapTypeButtonsExclusiveGroup
} }
ExclusiveGroup { ToolStrip {
id: mapTypeButtonsExclusiveGroup id: toolStrip
} anchors.leftMargin: ScreenTools.defaultFontPixelWidth
anchors.left: parent.left
anchors.topMargin: _toolButtonTopMargin
anchors.top: parent.top
color: qgcPal.window
title: qsTr("Fly")
z: QGroundControl.zOrderWidgets
buttonVisible: [ true, true, _showZoom, _showZoom ]
property bool _showZoom: !ScreenTools.isShortScreen
model: [
{
name: "Center",
iconSource: "/qmlimages/MapCenter.svg",
dropPanelComponent: centerMapDropPanel
},
{
name: "Map",
iconSource: "/qmlimages/MapType.svg",
dropPanelComponent: mapTypeDropPanel
},
{
name: "In",
iconSource: "/qmlimages/ZoomPlus.svg"
},
{
name: "Out",
iconSource: "/qmlimages/ZoomMinus.svg"
}
]
//-- Dismiss Drop Down (if any)
MouseArea {
anchors.fill: parent
enabled: dropButtonsExclusiveGroup.current != null
onClicked: { onClicked: {
if (dropButtonsExclusiveGroup.current) { switch (index) {
dropButtonsExclusiveGroup.current.checked = false case 2:
_flightMap.zoomLevel += 0.5
break
case 3:
_flightMap.zoomLevel -= 0.5
break
} }
dropButtonsExclusiveGroup.current = null
} }
} }
// IMPORTANT NOTE: Drop Buttons must be parented directly to the map. If they are placed in a Column for example the drop control positioning // Toolstrip drop panel compomnents
// will not work correctly.
//-- Map Center Control
CenterMapDropButton {
id: centerMapDropButton
anchors.topMargin: flyLabel.visible ? ScreenTools.defaultFontPixelHeight / 2 : _toolButtonTopMargin
anchors.leftMargin: ScreenTools.defaultFontPixelHeight
anchors.left: parent.left
anchors.top: flyLabel.visible ? flyLabel.bottom : parent.top
z: QGroundControl.zOrderWidgets
exclusiveGroup: dropButtonsExclusiveGroup
map: _flightMap
mapFitViewport: Qt.rect(leftToolWidth, _toolButtonTopMargin, flightMap.width - leftToolWidth - rightPanelWidth, flightMap.height - _toolButtonTopMargin)
usePlannedHomePosition: false
geoFenceController: geoFenceController
missionController: missionController
rallyPointController: rallyPointController
showFollowVehicle: true
followVehicle: _followVehicle
onFollowVehicleChanged: _followVehicle = followVehicle
property real leftToolWidth: centerMapDropButton.x + centerMapDropButton.width
}
//-- Map Type Control MapFitFunctions {
DropButton { id: mapFitFunctions
id: mapTypeButton map: _flightMap
anchors.topMargin: ScreenTools.defaultFontPixelHeight mapFitViewport: Qt.rect(leftToolWidth, _toolButtonTopMargin, flightMap.width - leftToolWidth - rightPanelWidth, flightMap.height - _toolButtonTopMargin)
anchors.top: centerMapDropButton.bottom usePlannedHomePosition: false
anchors.left: centerMapDropButton.left mapMissionController: missionController
dropDirection: dropRight mapGeoFenceController: geoFenceController
buttonImage: "/qmlimages/MapType.svg" mapRallyPointController: rallyPointController
viewportMargins: ScreenTools.defaultFontPixelWidth / 2
exclusiveGroup: dropButtonsExclusiveGroup
z: QGroundControl.zOrderWidgets
lightBorders: isSatelliteMap
dropDownComponent: Component { property real leftToolWidth: toolStrip.x + toolStrip.width
Column { }
spacing: ScreenTools.defaultFontPixelWidth
Row { Component {
spacing: ScreenTools.defaultFontPixelWidth id: centerMapDropPanel
Repeater { CenterMapDropPanel {
model: QGroundControl.flightMapSettings.mapTypes map: _flightMap
fitFunctions: mapFitFunctions
}
}
QGCButton { Component {
checkable: true id: mapTypeDropPanel
checked: QGroundControl.flightMapSettings.mapType === text
text: modelData
width: clearButton.width
exclusiveGroup: mapTypeButtonsExclusiveGroup
onClicked: { Column {
QGroundControl.flightMapSettings.mapType = text spacing: ScreenTools.defaultFontPixelHeight / 2
checked = true
dropButtonsExclusiveGroup.current = null
}
}
}
}
QGCButton { QGCLabel { text: qsTr("Map type:") }
id: clearButton Row {
text: qsTr("Clear Flight Trails") spacing: ScreenTools.defaultFontPixelWidth
enabled: QGroundControl.multiVehicleManager.activeVehicle Repeater {
onClicked: { model: QGroundControl.flightMapSettings.mapTypes
QGroundControl.multiVehicleManager.activeVehicle.clearTrajectoryPoints()
dropButtonsExclusiveGroup.current = null QGCButton {
checkable: true
checked: QGroundControl.flightMapSettings.mapType === text
text: modelData
exclusiveGroup: _mapTypeButtonsExclusiveGroup
onClicked: {
QGroundControl.flightMapSettings.mapType = text
dropPanel.hide()
}
} }
} }
} }
} }
} }
//-- Zoom Map In
RoundButton {
id: mapZoomPlus
anchors.topMargin: ScreenTools.defaultFontPixelHeight
anchors.top: mapTypeButton.bottom
anchors.left: mapTypeButton.left
visible: !ScreenTools.isTinyScreen && _mainIsMap
buttonImage: "/qmlimages/ZoomPlus.svg"
exclusiveGroup: dropButtonsExclusiveGroup
z: QGroundControl.zOrderWidgets
lightBorders: isSatelliteMap
onClicked: {
if(_flightMap)
_flightMap.zoomLevel += 0.5
checked = false
}
}
//-- Zoom Map Out
RoundButton {
id: mapZoomMinus
anchors.topMargin: ScreenTools.defaultFontPixelHeight
anchors.top: mapZoomPlus.bottom
anchors.left: mapZoomPlus.left
visible: !ScreenTools.isTinyScreen && _mainIsMap
buttonImage: "/qmlimages/ZoomMinus.svg"
exclusiveGroup: dropButtonsExclusiveGroup
z: QGroundControl.zOrderWidgets
lightBorders: isSatelliteMap
onClicked: {
if(_flightMap)
_flightMap.zoomLevel -= 0.5
checked = false
}
}
// Add trajectory points to the map // Add trajectory points to the map
MapItemView { MapItemView {
model: _mainIsMap ? _activeVehicle ? _activeVehicle.trajectoryPoints : 0 : 0 model: _mainIsMap ? _activeVehicle ? _activeVehicle.trajectoryPoints : 0 : 0

Loading…
Cancel
Save