diff --git a/src/FlightDisplay/FlightDisplayView.qml b/src/FlightDisplay/FlightDisplayView.qml index 847245c3cfde529ea0708698f8dc6de17d3314e6..2c2faefdbccd5998cda503440af5588c13bb4eaf 100644 --- a/src/FlightDisplay/FlightDisplayView.qml +++ b/src/FlightDisplay/FlightDisplayView.qml @@ -41,6 +41,9 @@ import QGroundControl.Controllers 1.0 Item { id: root + property alias latitude: flightMap.latitude + property alias longitude: flightMap.longitude + // Top margin for all widgets. Used to prevent overlap with the toolbar property real topMargin: 0 @@ -114,7 +117,6 @@ Item { QGroundControl.flightMapSettings.saveMapSetting(flightMap.mapName, _showMapBackgroundKey, setBool(_showMap)) } - FlightMap { id: flightMap anchors.fill: parent @@ -126,6 +128,8 @@ Item { property var rootVehicleCoordinate: _vehicleCoordinate property bool rootLoadCompleted: false + property bool _followVehicle: true + onRootVehicleCoordinateChanged: updateMapPosition(false /* force */) Component.onCompleted: flightMapDelayLoader.source = "FlightDisplayViewDelayLoadInner.qml" @@ -136,9 +140,6 @@ Item { flightMap.longitude = root._vehicleCoordinate.longitude } } - - property bool _followVehicle: true - // Home position MissionItemIndicator { label: "H" @@ -194,6 +195,11 @@ Item { id: flightMapDelayLoader anchors.fill: parent } + + // Used to make pinch zoom work + MouseArea { + anchors.fill: parent + } } // Flight Map Loader { diff --git a/src/MissionEditor/MissionEditor.qml b/src/MissionEditor/MissionEditor.qml index 39a82e86ca3692c66773aafae13412f80b5bbdc0..30bf963bc6ed73e2e5de02bc2ec60545a8ab8baa 100644 --- a/src/MissionEditor/MissionEditor.qml +++ b/src/MissionEditor/MissionEditor.qml @@ -60,10 +60,10 @@ QGCView { property var _homePositionManager: QGroundControl.homePositionManager property string _homePositionName: _homePositionManager.homePositions.get(0).name - property var offlineHomePosition: _homePositionManager.homePositions.get(0).coordinate + //property var offlineHomePosition: _homePositionManager.homePositions.get(0).coordinate property var liveHomePosition: controller.liveHomePosition property var liveHomePositionAvailable: controller.liveHomePositionAvailable - property var homePosition: offlineHomePosition // live or offline depending on state + //property var homePosition: offlineHomePosition // live or offline depending on state property bool _syncNeeded: controller.missionItems.dirty property bool _syncInProgress: _activeVehicle ? _activeVehicle.missionManager.inProgress : false @@ -103,13 +103,14 @@ QGCView { } function updateHomePosition() { - homePosition = liveHomePositionAvailable ? liveHomePosition : offlineHomePosition - _missionItems.get(0).coordinate = homePosition - _missionItems.get(0).homePositionValid = true + if (liveHomePositionAvailable) { + _missionItems.get(0).coordinate = liveHomePosition + _missionItems.get(0).homePositionValid = true + } } Component.onCompleted: updateHomePosition() - onOfflineHomePositionChanged: updateHomePosition() + //onOfflineHomePositionChanged: updateHomePosition() onLiveHomePositionAvailableChanged: updateHomePosition() onLiveHomePositionChanged: updateHomePosition() @@ -124,11 +125,8 @@ QGCView { id: editorMap anchors.fill: parent mapName: "MissionEditor" - - Component.onCompleted: { - latitude = homePosition.latitude - longitude = homePosition.longitude - } + latitude: tabletPosition.latitude + longitude: tabletPosition.longitude readonly property real animationDuration: 500 @@ -161,8 +159,8 @@ QGCView { coordinate.latitude = coordinate.latitude.toFixed(_decimalPlaces) coordinate.longitude = coordinate.longitude.toFixed(_decimalPlaces) coordinate.altitude = coordinate.altitude.toFixed(_decimalPlaces) - if (homePositionManagerButton.checked) { - offlineHomePosition = coordinate + if (false /*homePositionManagerButton.checked*/) { + //offlineHomePosition = coordinate } else if (addMissionItemsButton.checked) { var index = controller.addMissionItem(coordinate) addMissionItemsButtonAutoOffTimer.start() @@ -242,7 +240,7 @@ QGCView { anchors.bottom: parent.bottom anchors.right: parent.right width: _rightPanelWidth - visible: !homePositionManagerButton.checked && _missionItems.count > 1 + visible: _missionItems.count > 1 opacity: _rightPanelOpacity z: editorMap.zOrderTopMost @@ -259,7 +257,8 @@ QGCView { MissionItemEditor { missionItem: object width: parent.width - readOnly: object.sequenceNumber == 0 && liveHomePositionAvailable + readOnly: object.sequenceNumber == 0 + visible: !readOnly || object.homePositionValid onClicked: setCurrentItem(object.sequenceNumber) @@ -283,6 +282,9 @@ QGCView { } } // Item - Mission Item editor +/* +Home Position Manager is commented out for now until a better implementation is completed + // Home Position Manager Rectangle { id: homePositionManager @@ -554,6 +556,7 @@ QGCView { } } // Column - Online view } // Item - Home Position Manager +*/ // Help Panel Rectangle { @@ -651,6 +654,9 @@ QGCView { "Delete the currently selected mission item." } + /* + Home Position Manager commented until more complete implementation is done + Image { id: homePositionManagerHelpIcon anchors.topMargin: ScreenTools.defaultFontPixelHeight @@ -673,11 +679,12 @@ QGCView { "When enabled, allows you to select/add/update flying field locations. " + "You can save multiple flying field locations for use while creating missions while you are not connected to your vehicle." } +*/ Image { id: mapCenterHelpIcon anchors.topMargin: ScreenTools.defaultFontPixelHeight - anchors.top: homePositionManagerHelpText.bottom + anchors.top: deleteHelpText.bottom width: ScreenTools.defaultFontPixelHeight * 3 fillMode: Image.PreserveAspectFit mipmap: true @@ -793,6 +800,9 @@ QGCView { } } + /* + Home Position Manager commented until more complete implementation is done + RoundButton { id: homePositionManagerButton anchors.margins: _margin @@ -802,12 +812,13 @@ QGCView { exclusiveGroup: _dropButtonsExclusiveGroup z: editorMap.zOrderWidgets } + */ DropButton { id: centerMapButton anchors.margins: _margin anchors.left: parent.left - anchors.top: homePositionManagerButton.bottom + anchors.top: deleteMissionItemButton.bottom dropDirection: dropRight buttonImage: "/qmlimages/MapCenter.svg" viewportMargins: ScreenTools.defaultFontPixelWidth / 2 @@ -822,11 +833,12 @@ QGCView { spacing: ScreenTools.defaultFontPixelWidth QGCButton { - text: "Home" + text: "Home" + enabled: liveHomePositionAvailable onClicked: { centerMapButton.hideDropDown() - editorMap.center = QtPositioning.coordinate(homePosition.latitude, homePosition.longitude) + editorMap.center = liveHomePosition } } diff --git a/src/ui/MainWindow.qml b/src/ui/MainWindow.qml index 1df0380532c370ac97ecbe0e623fd0935b0f3f72..b0c86459563e191eb404d160ee0586b32f17b737 100644 --- a/src/ui/MainWindow.qml +++ b/src/ui/MainWindow.qml @@ -82,6 +82,21 @@ FlightDisplayView { toolbarLoader.source = "MainToolBar.qml" } + // Detect tablet position + property var tabletPosition: QtPositioning.coordinate(37.803784, -122.462276) + PositionSource { + id: positionSource + updateInterval: 1000 + active: ScreenTools.isMobile + + onPositionChanged: { + tabletPosition = positionSource.position.coordinate + _root.latitude = tabletPosition.latitude + _root.longitude = tabletPosition.longitude + positionSource.active = false + } + } + Loader { id: toolbarLoader width: parent.width @@ -97,7 +112,8 @@ FlightDisplayView { anchors.bottom: parent.bottom visible: false - property real zOrder: _root.zOrderTopMost + property real zOrder: _root.zOrderTopMost + property var tabletPosition: _root.tabletPosition } Loader { @@ -108,6 +124,7 @@ FlightDisplayView { anchors.bottom: parent.bottom visible: false - property real zOrder: _root.zOrderTopMost + property real zOrder: _root.zOrderTopMost + property var tabletPosition: _root.tabletPosition } }