Commit 8ff2956f authored by Don Gagne's avatar Don Gagne

Make DropButton's actually do commands

parent f50329c1
...@@ -43,6 +43,7 @@ ...@@ -43,6 +43,7 @@
<file alias="PowerComponentBattery_04cell.svg">src/AutoPilotPlugins/PX4/Images/PowerComponentBattery_04cell.svg</file> <file alias="PowerComponentBattery_04cell.svg">src/AutoPilotPlugins/PX4/Images/PowerComponentBattery_04cell.svg</file>
<file alias="PowerComponentBattery_05cell.svg">src/AutoPilotPlugins/PX4/Images/PowerComponentBattery_05cell.svg</file> <file alias="PowerComponentBattery_05cell.svg">src/AutoPilotPlugins/PX4/Images/PowerComponentBattery_05cell.svg</file>
<file alias="PowerComponentBattery_06cell.svg">src/AutoPilotPlugins/PX4/Images/PowerComponentBattery_06cell.svg</file> <file alias="PowerComponentBattery_06cell.svg">src/AutoPilotPlugins/PX4/Images/PowerComponentBattery_06cell.svg</file>
<file alias="attitudeDial.svg">src/FlightMap/Images/attitudeDial.svg</file> <file alias="attitudeDial.svg">src/FlightMap/Images/attitudeDial.svg</file>
<file alias="attitudeInstrument.svg">src/FlightMap/Images/attitudeInstrument.svg</file> <file alias="attitudeInstrument.svg">src/FlightMap/Images/attitudeInstrument.svg</file>
<file alias="attitudePointer.svg">src//FlightMap/Images/attitudePointer.svg</file> <file alias="attitudePointer.svg">src//FlightMap/Images/attitudePointer.svg</file>
...@@ -61,6 +62,8 @@ ...@@ -61,6 +62,8 @@
<file alias="scale_end.png">src/FlightMap/Images/scale_end.png</file> <file alias="scale_end.png">src/FlightMap/Images/scale_end.png</file>
<file alias="airplaneOutline.svg">src/FlightMap/Images/airplaneOutline.svg</file> <file alias="airplaneOutline.svg">src/FlightMap/Images/airplaneOutline.svg</file>
<file alias="airplaneOpaque.svg">src/FlightMap/Images/airplaneOpaque.svg</file> <file alias="airplaneOpaque.svg">src/FlightMap/Images/airplaneOpaque.svg</file>
<file alias="MapType.svg">src/FlightMap/Images/MapType.svg</file>
<file alias="MapCenter.svg">src/FlightMap/Images/MapCenter.svg</file>
</qresource> </qresource>
<qresource prefix="/qml"> <qresource prefix="/qml">
<file alias="test.qml">src/test.qml</file> <file alias="test.qml">src/test.qml</file>
...@@ -102,6 +105,7 @@ ...@@ -102,6 +105,7 @@
<file alias="QGroundControl/Controls/MissionItemSummary.qml">src/QmlControls/MissionItemSummary.qml</file> <file alias="QGroundControl/Controls/MissionItemSummary.qml">src/QmlControls/MissionItemSummary.qml</file>
<file alias="QGroundControl/Controls/MissionItemEditor.qml">src/QmlControls/MissionItemEditor.qml</file> <file alias="QGroundControl/Controls/MissionItemEditor.qml">src/QmlControls/MissionItemEditor.qml</file>
<file alias="QGroundControl/Controls/DropButton.qml">src/QmlControls/DropButton.qml</file> <file alias="QGroundControl/Controls/DropButton.qml">src/QmlControls/DropButton.qml</file>
<file alias="QGroundControl/Controls/QGCCanvas.qml">src/QmlControls/QGCCanvas.qml</file>
<!-- Vehicle Setup --> <!-- Vehicle Setup -->
<file alias="SetupView.qml">src/VehicleSetup/SetupView.qml</file> <file alias="SetupView.qml">src/VehicleSetup/SetupView.qml</file>
......
...@@ -27,6 +27,7 @@ import QtQuick.Controls.Styles 1.2 ...@@ -27,6 +27,7 @@ import QtQuick.Controls.Styles 1.2
import QtQuick.Dialogs 1.2 import QtQuick.Dialogs 1.2
import QtLocation 5.3 import QtLocation 5.3
import QGroundControl 1.0
import QGroundControl.FlightMap 1.0 import QGroundControl.FlightMap 1.0
import QGroundControl.ScreenTools 1.0 import QGroundControl.ScreenTools 1.0
import QGroundControl.Controls 1.0 import QGroundControl.Controls 1.0
...@@ -66,7 +67,7 @@ Item { ...@@ -66,7 +67,7 @@ Item {
property real _airSpeed: _activeVehicle ? _activeVehicle.airSpeed : _defaultAirSpeed property real _airSpeed: _activeVehicle ? _activeVehicle.airSpeed : _defaultAirSpeed
property real _climbRate: _activeVehicle ? _activeVehicle.climbRate : _defaultClimbRate property real _climbRate: _activeVehicle ? _activeVehicle.climbRate : _defaultClimbRate
property bool _showMap: getBool(multiVehicleManager.loadSetting(_mapName + _showMapBackgroundKey, "1")) property bool _showMap: getBool(QGroundControl.flightMapSettings.loadMapSetting(flightMap.mapName, _showMapBackgroundKey, "1"))
// Validate _showMap setting // Validate _showMap setting
Component.onCompleted: _setShowMap(_showMap) Component.onCompleted: _setShowMap(_showMap)
...@@ -81,7 +82,7 @@ Item { ...@@ -81,7 +82,7 @@ Item {
function _setShowMap(showMap) { function _setShowMap(showMap) {
_showMap = flightDisplay.hasVideo ? showMap : true _showMap = flightDisplay.hasVideo ? showMap : true
multiVehicleManager.saveSetting(_mapName + _showMapBackgroundKey, setBool(_showMap)) QGroundControl.flightMapSettings.saveMapSetting(flightMap.mapName, _showMapBackgroundKey, setBool(_showMap))
} }
FlightMap { FlightMap {
...@@ -141,7 +142,6 @@ Item { ...@@ -141,7 +142,6 @@ Item {
size: ScreenTools.defaultFontPixelSize * (13.3) size: ScreenTools.defaultFontPixelSize * (13.3)
heading: _heading heading: _heading
active: multiVehicleManager.activeVehicleAvailable active: multiVehicleManager.activeVehicleAvailable
z: flightMap.z + 2
} }
QGCAttitudeWidget { QGCAttitudeWidget {
...@@ -152,8 +152,39 @@ Item { ...@@ -152,8 +152,39 @@ Item {
rollAngle: _roll rollAngle: _roll
pitchAngle: _pitch pitchAngle: _pitch
active: multiVehicleManager.activeVehicleAvailable active: multiVehicleManager.activeVehicleAvailable
z: flightMap.z + 2
} }
DropButton {
id: mapTypeButton
anchors.margins: ScreenTools.defaultFontPixelHeight
anchors.top: parent.top
anchors.right: parent.right
dropDirection: dropDown
buttonImage: "/qmlimages/MapType.svg"
viewportMargins: ScreenTools.defaultFontPixelWidth / 2
dropDownComponent: Component {
Row {
spacing: ScreenTools.defaultFontPixelWidth
Repeater {
model: QGroundControl.flightMapSettings.mapTypes
QGCButton {
checkable: true
checked: flightMap.mapType == text
text: modelData
onClicked: {
flightMap.mapType = text
mapTypeButton.hideDropDown()
}
}
}
}
}
}
} // Flight Map } // Flight Map
QGCVideoBackground { QGCVideoBackground {
...@@ -280,8 +311,6 @@ Item { ...@@ -280,8 +311,6 @@ Item {
MenuSeparator { MenuSeparator {
visible: flightDisplay.hasVideo && _showMap visible: flightDisplay.hasVideo && _showMap
} }
Component.onCompleted: flightMap.addMapMenuItems(optionsMenu)
} }
} }
} }
...@@ -32,6 +32,7 @@ import QtQuick.Controls 1.3 ...@@ -32,6 +32,7 @@ import QtQuick.Controls 1.3
import QtLocation 5.3 import QtLocation 5.3
import QtPositioning 5.3 import QtPositioning 5.3
import QGroundControl 1.0
import QGroundControl.Controls 1.0 import QGroundControl.Controls 1.0
import QGroundControl.FlightMap 1.0 import QGroundControl.FlightMap 1.0
import QGroundControl.ScreenTools 1.0 import QGroundControl.ScreenTools 1.0
...@@ -47,6 +48,7 @@ Map { ...@@ -47,6 +48,7 @@ Map {
property real heading: 0 property real heading: 0
property bool interactive: true property bool interactive: true
property string mapName: 'defaultMap' property string mapName: 'defaultMap'
property string mapType: QGroundControl.flightMapSettings.mapTypeForMapName(mapName)
property alias mapWidgets: controlWidgets property alias mapWidgets: controlWidgets
property bool isSatelliteMap: false property bool isSatelliteMap: false
...@@ -61,45 +63,20 @@ Map { ...@@ -61,45 +63,20 @@ Map {
plugin: Plugin { name: "QGroundControl" } plugin: Plugin { name: "QGroundControl" }
ExclusiveGroup { id: mapTypeGroup } ExclusiveGroup { id: mapTypeGroup }
// Map type selection MenuItem Component.onCompleted: onMapTypeChanged
Component {
id: menuItemComponent onMapTypeChanged: {
QGroundControl.flightMapSettings.setMapTypeForMapName(mapName, mapType)
MenuItem { var fullMapName = QGroundControl.flightMapSettings.mapProvider + " " + mapType
checkable: true
checked: text == _map.activeMapType.name
exclusiveGroup: mapTypeGroup
visible: _map.visible
onTriggered: setCurrentMap(text)
}
}
// Set the current map type to the specified type name
function setCurrentMap(name) {
for (var i = 0; i < _map.supportedMapTypes.length; i++) { for (var i = 0; i < _map.supportedMapTypes.length; i++) {
if (name === _map.supportedMapTypes[i].name) { if (fullMapName === _map.supportedMapTypes[i].name) {
_map.activeMapType = _map.supportedMapTypes[i] _map.activeMapType = _map.supportedMapTypes[i]
multiVehicleManager.saveSetting(_map.mapName + "/currentMapType", name); return
return;
} }
} }
} }
// Add menu map types to the specified menu and sets the current map type from settings
function addMapMenuItems(menu) {
var savedMapName = multiVehicleManager.loadSetting(_map.mapName + "/currentMapType", "")
setCurrentMap(savedMapName)
for (var i = 0; i < _map.supportedMapTypes.length; i++) {
var menuItem = menuItemComponent.createObject()
menuItem.text = _map.supportedMapTypes[i].name
menu.insertItem(menu.items.length, menuItem)
}
}
/// Map control widgets /// Map control widgets
Column { Column {
id: controlWidgets id: controlWidgets
......
...@@ -104,7 +104,7 @@ QGCView { ...@@ -104,7 +104,7 @@ QGCView {
anchors.right: mapTypeButton.left anchors.right: mapTypeButton.left
anchors.top: mapTypeButton.top anchors.top: mapTypeButton.top
dropDirection: dropDown dropDirection: dropDown
label: "C" buttonImage: "/qmlimages/MapCenter.svg"
viewportMargins: ScreenTools.defaultFontPixelWidth / 2 viewportMargins: ScreenTools.defaultFontPixelWidth / 2
dropDownComponent: Component { dropDownComponent: Component {
...@@ -114,14 +114,48 @@ QGCView { ...@@ -114,14 +114,48 @@ QGCView {
QGCButton { QGCButton {
text: "Home" text: "Home"
onClicked: centerMapButton.hideDropDown() onClicked: {
centerMapButton.hideDropDown()
editorMap.center = QtPositioning.coordinate(_homePositionCoordinate.latitude, _homePositionCoordinate.longitude)
_showHomePositionManager = true
}
} }
/*
This code will need to wait for Qml 5.5 support since Map.visibleRegion is only in Qt 5.5
QGCButton { QGCButton {
text: "All Items" text: "All Items"
onClicked: centerMapButton.hideDropDown() onClicked: {
centerMapButton.hideDropDown()
// Begin with only the home position in the region
var region = QtPositioning.rectangle(QtPositioning.coordinate(_homePositionCoordinate.latitude, _homePositionCoordinate.longitude),
QtPositioning.coordinate(_homePositionCoordinate.latitude, _homePositionCoordinate.longitude))
// Now expand the region to include all mission items
for (var i=0; i<_missionItems.count; i++) {
var missionItem = _missionItems.get(i)
region.topLeft.latitude = Math.max(missionItem.coordinate.latitude, region.topLeft.latitude)
region.topLeft.longitude = Math.min(missionItem.coordinate.longitude, region.topLeft.longitude)
region.topRight.latitude = Math.max(missionItem.coordinate.latitude, region.topRight.latitude)
region.topRight.longitude = Math.max(missionItem.coordinate.longitude, region.topRight.longitude)
region.bottomLeft.latitude = Math.min(missionItem.coordinate.latitude, region.bottomLeft.latitude)
region.bottomLeft.longitude = Math.min(missionItem.coordinate.longitude, region.bottomLeft.longitude)
region.bottomRight.latitude = Math.min(missionItem.coordinate.latitude, region.bottomRight.latitude)
region.bottomRight.longitude = Math.max(missionItem.coordinate.longitude, region.bottomRight.longitude)
}
editorMap.visibleRegion = region
}
} }
*/
} }
} }
} }
...@@ -132,29 +166,26 @@ QGCView { ...@@ -132,29 +166,26 @@ QGCView {
anchors.top: parent.top anchors.top: parent.top
anchors.right: parent.right anchors.right: parent.right
dropDirection: dropDown dropDirection: dropDown
label: "M" buttonImage: "/qmlimages/MapType.svg"
viewportMargins: ScreenTools.defaultFontPixelWidth / 2 viewportMargins: ScreenTools.defaultFontPixelWidth / 2
dropDownComponent: Component { dropDownComponent: Component {
Row { Row {
spacing: ScreenTools.defaultFontPixelWidth spacing: ScreenTools.defaultFontPixelWidth
QGCButton { Repeater {
text: "Street" model: QGroundControl.flightMapSettings.mapTypes
onClicked: mapTypeButton.hideDropDown()
}
QGCButton {
text: "Satellite"
onClicked: mapTypeButton.hideDropDown()
}
QGCButton { QGCButton {
text: "Hybrid" checkable: true
checked: editorMap.mapType == text
text: modelData
onClicked: mapTypeButton.hideDropDown() onClicked: {
editorMap.mapType = text
mapTypeButton.hideDropDown()
}
}
} }
} }
} }
......
...@@ -8,8 +8,8 @@ import QGroundControl.Palette 1.0 ...@@ -8,8 +8,8 @@ import QGroundControl.Palette 1.0
Item { Item {
id: _root id: _root
property alias label: buttonLabel.text property alias buttonImage: button.source
property alias radius: button.radius property real radius: (ScreenTools.defaultFontPixelHeight * 3) / 2
property int dropDirection: dropDown property int dropDirection: dropDown
property alias dropDownComponent: dropDownLoader.sourceComponent property alias dropDownComponent: dropDownLoader.sourceComponent
property real viewportMargins: 0 property real viewportMargins: 0
...@@ -144,33 +144,24 @@ Item { ...@@ -144,33 +144,24 @@ Item {
} }
// Button // Button
Rectangle { Image {
id: button id: button
anchors.fill: parent anchors.fill: parent
radius: (ScreenTools.defaultFontPixelHeight * 3) / 2 fillMode: Image.PreserveAspectFit
color: qgcPal.button
opacity: _showDropDown ? 1.0 : 0.75 opacity: _showDropDown ? 1.0 : 0.75
QGCLabel {
id: buttonLabel
anchors.fill: parent
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
color: "white"
}
MouseArea { MouseArea {
anchors.fill: parent anchors.fill: parent
onClicked: _showDropDown = !_showDropDown onClicked: _showDropDown = !_showDropDown
} }
} // Rectangle - button } // Image - button
Item { Item {
id: dropDownItem id: dropDownItem
visible: _showDropDown visible: _showDropDown
Canvas { QGCCanvas {
id: arrowCanvas id: arrowCanvas
anchors.fill: parent anchors.fill: parent
...@@ -224,6 +215,13 @@ Item { ...@@ -224,6 +215,13 @@ Item {
id: dropDownLoader id: dropDownLoader
x: _dropMargin x: _dropMargin
y: _dropMargin y: _dropMargin
Connections {
target: dropDownLoader.item
onWidthChanged: _calcPositions()
onHeightChanged: _calcPositions()
}
} }
} }
} // Item - dropDownItem } // Item - dropDownItem
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment