From 261397484262593ef0136cc18adab6c0981ac81c Mon Sep 17 00:00:00 2001 From: dogmaphobic Date: Sat, 14 Nov 2015 22:42:54 -0500 Subject: [PATCH] Fixed starting map coordinates. --- ios/iOS-Info.plist | 4 + ios/iOSForAppStore-Info.plist | 4 + qgroundcontrol.pro | 2 +- src/FlightDisplay/FlightDisplayView.qml | 2 +- src/FlightDisplay/FlightDisplayViewMap.qml | 4 +- src/FlightMap/FlightMap.qml | 4 +- src/MissionEditor/MissionEditor.qml | 311 ++++++++++++--------- src/QGCApplication.cc | 1 - src/QmlControls/ScreenTools.qml | 1 + src/ui/MainWindow.qml | 28 +- 10 files changed, 207 insertions(+), 154 deletions(-) diff --git a/ios/iOS-Info.plist b/ios/iOS-Info.plist index cef6abd54..c53044cc1 100644 --- a/ios/iOS-Info.plist +++ b/ios/iOS-Info.plist @@ -34,6 +34,10 @@ 6.0 ForAppStore No + NSLocationUsageDescription + Ground Station Location + NSLocationWhenInUseUsageDescription + Ground Station Location UISupportedInterfaceOrientations UIInterfaceOrientationLandscapeLeft diff --git a/ios/iOSForAppStore-Info.plist b/ios/iOSForAppStore-Info.plist index f7da58475..fa6a00820 100644 --- a/ios/iOSForAppStore-Info.plist +++ b/ios/iOSForAppStore-Info.plist @@ -34,6 +34,10 @@ 6.0 ForAppStore Yes + NSLocationUsageDescription + Ground Station Location + NSLocationWhenInUseUsageDescription + Ground Station Location UISupportedInterfaceOrientations UIInterfaceOrientationLandscapeLeft diff --git a/qgroundcontrol.pro b/qgroundcontrol.pro index ad837923c..1cc7b603e 100644 --- a/qgroundcontrol.pro +++ b/qgroundcontrol.pro @@ -54,10 +54,10 @@ CONFIG += qt \ thread QT += \ - network \ concurrent \ gui \ location \ + network \ opengl \ positioning \ qml \ diff --git a/src/FlightDisplay/FlightDisplayView.qml b/src/FlightDisplay/FlightDisplayView.qml index b25ba2078..3f0b4cce3 100644 --- a/src/FlightDisplay/FlightDisplayView.qml +++ b/src/FlightDisplay/FlightDisplayView.qml @@ -49,7 +49,7 @@ Item { property var _activeVehicle: multiVehicleManager.activeVehicle - readonly property var _defaultVehicleCoordinate: QtPositioning.coordinate(37.803784, -122.462276) + readonly property var _defaultVehicleCoordinate: mainWindow.tabletPosition readonly property real _defaultRoll: 0 readonly property real _defaultPitch: 0 readonly property real _defaultHeading: 0 diff --git a/src/FlightDisplay/FlightDisplayViewMap.qml b/src/FlightDisplay/FlightDisplayViewMap.qml index 4133640a9..9eaf51791 100644 --- a/src/FlightDisplay/FlightDisplayViewMap.qml +++ b/src/FlightDisplay/FlightDisplayViewMap.qml @@ -39,8 +39,8 @@ FlightMap { id: flightMap anchors.fill: parent mapName: _mapName - latitude: root._defaultCoordinate.latitude - longitude: root._defaultCoordinate.longitude + latitude: mainWindow.tabletPosition.latitude + longitude: mainWindow.tabletPosition.longitude property var rootVehicleCoordinate: _vehicleCoordinate property bool _followVehicle: true diff --git a/src/FlightMap/FlightMap.qml b/src/FlightMap/FlightMap.qml index d572ed810..cf1474a47 100644 --- a/src/FlightMap/FlightMap.qml +++ b/src/FlightMap/FlightMap.qml @@ -43,8 +43,8 @@ import QGroundControl.Mavlink 1.0 Map { id: _map - property real latitude: 0 - property real longitude: 0 + property real latitude: 64.154549 //-- If you find yourself here on startup, something went wrong :) + property real longitude: -22.023540 property real heading: 0 property bool interactive: true property string mapName: 'defaultMap' diff --git a/src/MissionEditor/MissionEditor.qml b/src/MissionEditor/MissionEditor.qml index 95ae418d6..b30858c9e 100644 --- a/src/MissionEditor/MissionEditor.qml +++ b/src/MissionEditor/MissionEditor.qml @@ -46,7 +46,7 @@ QGCView { z: QGroundControl.zOrderTopMost readonly property int _decimalPlaces: 8 - readonly property real _horizontalMargin: ScreenTools.defaultFontPixelWidth / 2 + readonly property real _horizontalMargin: ScreenTools.defaultFontPixelWidth / 2 readonly property real _margin: ScreenTools.defaultFontPixelHeight / 2 readonly property var _activeVehicle: multiVehicleManager.activeVehicle readonly property real _editFieldWidth: ScreenTools.defaultFontPixelWidth * 16 @@ -103,7 +103,10 @@ QGCView { MissionController { id: controller - Component.onCompleted: start(true /* editMode */) + Component.onCompleted: { + start(true /* editMode */) + } + /* FIXME: autoSync is temporarily disconnected since it's still buggy @@ -142,8 +145,12 @@ QGCView { id: editorMap anchors.fill: parent mapName: "MissionEditor" - latitude: tabletPosition.latitude - longitude: tabletPosition.longitude + latitude: mainWindow.tabletPosition.latitude + longitude: mainWindow.tabletPosition.longitude + + Component.onCompleted: { + console.log("Init coordinate " + mainWindow.tabletPosition.latitude) + } readonly property real animationDuration: 500 @@ -695,6 +702,17 @@ QGCView { } // Item - Home Position Manager */ + //-- Dismiss Drop Down (if any) + MouseArea { + anchors.fill: parent + enabled: _dropButtonsExclusiveGroup.current != null + onClicked: { + if(_dropButtonsExclusiveGroup.current) + _dropButtonsExclusiveGroup.current.checked = false + _dropButtonsExclusiveGroup.current = null + } + } + //-- Help Panel Loader { id: helpPanel @@ -705,169 +723,186 @@ QGCView { anchors.horizontalCenter: parent.horizontalCenter } + Item { + id: toolbarSpacer + height: mainWindow.tbHeight + width: 1 + } - RoundButton { - id: addMissionItemsButton - anchors.margins: _margin - anchors.left: parent.left - y: (parent.height - (_toolButtonCount * height) - ((_toolButtonCount - 1) * _margin)) / 2 - buttonImage: "/qmlimages/MapAddMission.svg" - exclusiveGroup: _dropButtonsExclusiveGroup - z: QGroundControl.zOrderWidgets + //-- Vertical Tool Buttons + Column { + id: toolColumn + anchors.margins: ScreenTools.defaultFontPixelHeight + anchors.left: parent.left + anchors.top: toolbarSpacer.bottom + spacing: ScreenTools.defaultFontPixelHeight + + RoundButton { + id: addMissionItemsButton + buttonImage: "/qmlimages/MapAddMission.svg" + z: QGroundControl.zOrderWidgets + + onCheckedChanged: { + if (checked) { + addMissionItemsButtonAutoOffTimer.start() + } else { + addMissionItemsButtonAutoOffTimer.stop() + } + } - onCheckedChanged: { - if (checked) { - addMissionItemsButtonAutoOffTimer.start() - } else { - addMissionItemsButtonAutoOffTimer.stop() + Timer { + id: addMissionItemsButtonAutoOffTimer + interval: _addMissionItemsButtonAutoOffTimeout + repeat: false + + onTriggered: addMissionItemsButton.checked = false } } - Timer { - id: addMissionItemsButtonAutoOffTimer - interval: _addMissionItemsButtonAutoOffTimeout - repeat: false + RoundButton { + id: deleteMissionItemButton + buttonImage: "/qmlimages/TrashDelete.svg" + z: QGroundControl.zOrderWidgets + onClicked: { + addMissionItemsButton.checked = false + itemDragger.clearItem() + controller.deleteCurrentMissionItem() + checked = false + } + } - onTriggered: addMissionItemsButton.checked = false + /* + Home Position manager temporarily disable + RoundButton { + id: homePositionManagerButton + buttonImage: "/qmlimages/MapHome.svg" + //exclusiveGroup: _dropButtonsExclusiveGroup + z: QGroundControl.zOrderWidgets } - } + */ - RoundButton { - id: deleteMissionItemButton - anchors.margins: _margin - anchors.left: parent.left - anchors.top: addMissionItemsButton.bottom - buttonImage: "/qmlimages/TrashDelete.svg" - exclusiveGroup: _dropButtonsExclusiveGroup - z: QGroundControl.zOrderWidgets + DropButton { + id: centerMapButton + dropDirection: dropRight + buttonImage: "/qmlimages/MapCenter.svg" + viewportMargins: ScreenTools.defaultFontPixelWidth / 2 + exclusiveGroup: _dropButtonsExclusiveGroup + z: QGroundControl.zOrderWidgets - onClicked: { - itemDragger.clearItem() - controller.deleteCurrentMissionItem() - checked = false - } - } + dropDownComponent: Component { + Column { + QGCLabel { text: "Center map:" } - /* - Home Position manager temporarily disable - RoundButton { - id: homePositionManagerButton - anchors.margins: _margin - anchors.left: parent.left - anchors.top: deleteMissionItemButton.bottom - buttonImage: "/qmlimages/MapHome.svg" - exclusiveGroup: _dropButtonsExclusiveGroup - z: QGroundControl.zOrderWidgets - } - */ + Row { + spacing: ScreenTools.defaultFontPixelWidth - DropButton { - id: centerMapButton - anchors.margins: _margin - anchors.left: parent.left - anchors.top: deleteMissionItemButton.bottom - dropDirection: dropRight - buttonImage: "/qmlimages/MapCenter.svg" - viewportMargins: ScreenTools.defaultFontPixelWidth / 2 - exclusiveGroup: _dropButtonsExclusiveGroup - z: QGroundControl.zOrderWidgets - - dropDownComponent: Component { - Column { - QGCLabel { text: "Center map:" } - - Row { - spacing: ScreenTools.defaultFontPixelWidth - - QGCButton { - text: "Home" - enabled: liveHomePositionAvailable - - onClicked: { - centerMapButton.hideDropDown() - editorMap.center = liveHomePosition + QGCButton { + text: "Home" + enabled: liveHomePositionAvailable + + onClicked: { + centerMapButton.hideDropDown() + editorMap.center = liveHomePosition + } } - } - QGCButton { - text: "Vehicle" - enabled: activeVehicle && activeVehicle.latitude != 0 && activeVehicle.longitude != 0 + QGCButton { + text: "Vehicle" + enabled: activeVehicle && activeVehicle.latitude != 0 && activeVehicle.longitude != 0 - property var activeVehicle: multiVehicleManager.activeVehicle + property var activeVehicle: multiVehicleManager.activeVehicle - onClicked: { - centerMapButton.hideDropDown() - editorMap.latitude = activeVehicle.latitude - editorMap.longitude = activeVehicle.longitude + onClicked: { + centerMapButton.hideDropDown() + editorMap.latitude = activeVehicle.latitude + editorMap.longitude = activeVehicle.longitude + } } } } } } - } - - DropButton { - id: syncButton - anchors.margins: _margin - anchors.left: parent.left - anchors.top: centerMapButton.bottom - dropDirection: dropRight - buttonImage: _syncNeeded ? "/qmlimages/MapSyncChanged.svg" : "/qmlimages/MapSync.svg" - viewportMargins: ScreenTools.defaultFontPixelWidth / 2 - exclusiveGroup: _dropButtonsExclusiveGroup - z: QGroundControl.zOrderWidgets - dropDownComponent: syncDropDownComponent - enabled: !_syncInProgress - } - - DropButton { - id: mapTypeButton - anchors.margins: _margin - anchors.left: parent.left - anchors.top: syncButton.bottom - dropDirection: dropRight - buttonImage: "/qmlimages/MapType.svg" - viewportMargins: ScreenTools.defaultFontPixelWidth / 2 - exclusiveGroup: _dropButtonsExclusiveGroup - z: QGroundControl.zOrderWidgets - - dropDownComponent: Component { - Column { - QGCLabel { text: "Map type:" } - Row { - spacing: ScreenTools.defaultFontPixelWidth - - Repeater { - model: QGroundControl.flightMapSettings.mapTypes - - QGCButton { - checkable: true - checked: editorMap.mapType == text - text: modelData - exclusiveGroup: _mapTypeButtonsExclusiveGroup + DropButton { + id: syncButton + dropDirection: dropRight + buttonImage: _syncNeeded ? "/qmlimages/MapSyncChanged.svg" : "/qmlimages/MapSync.svg" + viewportMargins: ScreenTools.defaultFontPixelWidth / 2 + exclusiveGroup: _dropButtonsExclusiveGroup + z: QGroundControl.zOrderWidgets + dropDownComponent: syncDropDownComponent + enabled: !_syncInProgress + } - onClicked: { - editorMap.mapType = text - checked = true - mapTypeButton.hideDropDown() + DropButton { + id: mapTypeButton + dropDirection: dropRight + buttonImage: "/qmlimages/MapType.svg" + viewportMargins: ScreenTools.defaultFontPixelWidth / 2 + exclusiveGroup: _dropButtonsExclusiveGroup + z: QGroundControl.zOrderWidgets + + dropDownComponent: Component { + Column { + QGCLabel { text: "Map type:" } + + Row { + spacing: ScreenTools.defaultFontPixelWidth + + Repeater { + model: QGroundControl.flightMapSettings.mapTypes + + QGCButton { + checkable: true + checked: editorMap.mapType == text + text: modelData + exclusiveGroup: _mapTypeButtonsExclusiveGroup + + onClicked: { + editorMap.mapType = text + checked = true + mapTypeButton.hideDropDown() + } } } } } } } - } - RoundButton { - id: helpButton - anchors.margins: _margin - anchors.left: parent.left - anchors.top: mapTypeButton.bottom - buttonImage: "/qmlimages/Help.svg" - exclusiveGroup: _dropButtonsExclusiveGroup - z: QGroundControl.zOrderWidgets - checked: _showHelp + //-- Zoom Map In + RoundButton { + id: mapZoomPlus + visible: !ScreenTools.isTinyScreen && !ScreenTools.isShortScreen + buttonImage: "/qmlimages/ZoomPlus.svg" + z: QGroundControl.zOrderWidgets + onClicked: { + if(editorMap) + editorMap.zoomLevel += 0.5 + checked = false + } + } + + //-- Zoom Map Out + RoundButton { + id: mapZoomMinus + visible: !ScreenTools.isTinyScreen && !ScreenTools.isShortScreen + buttonImage: "/qmlimages/ZoomMinus.svg" + z: QGroundControl.zOrderWidgets + onClicked: { + if(editorMap) + editorMap.zoomLevel -= 0.5 + checked = false + } + } + + RoundButton { + id: helpButton + buttonImage: "/qmlimages/Help.svg" + exclusiveGroup: _dropButtonsExclusiveGroup + z: QGroundControl.zOrderWidgets + checked: _showHelp + } } Rectangle { diff --git a/src/QGCApplication.cc b/src/QGCApplication.cc index 9f74e768d..94c4025ef 100644 --- a/src/QGCApplication.cc +++ b/src/QGCApplication.cc @@ -323,7 +323,6 @@ QGCApplication::~QGCApplication() if (mainWindow) { delete mainWindow; } - shutdownVideoStreaming(); delete _toolbox; } diff --git a/src/QmlControls/ScreenTools.qml b/src/QmlControls/ScreenTools.qml index b2c3c4c39..63ea2e508 100644 --- a/src/QmlControls/ScreenTools.qml +++ b/src/QmlControls/ScreenTools.qml @@ -31,6 +31,7 @@ Item { property bool isMobile: ScreenToolsController.isMobile property bool isDebug: ScreenToolsController.isDebug property bool isTinyScreen: (Screen.width / Screen.pixelDensity) < 120 // 120mm + property bool isShortScreen: (Screen.desktopAvailableHeight / Screen.desktopAvailableWidth) < 0.6 // Nexus 7 for example function mouseX() { return ScreenToolsController.mouseX() diff --git a/src/ui/MainWindow.qml b/src/ui/MainWindow.qml index edfc0d8ad..d33e39982 100644 --- a/src/ui/MainWindow.qml +++ b/src/ui/MainWindow.qml @@ -47,6 +47,9 @@ Item { property real avaiableHeight: height - tbHeight property real menuButtonWidth: (tbButtonWidth * 2) + (tbSpacing * 4) + 1 + property var defaultPosition: QtPositioning.coordinate(37.803784, -122.462276) + property var tabletPosition: defaultPosition + Connections { target: controller @@ -86,17 +89,23 @@ Item { } //-- Detect tablet position - property var tabletPosition: QtPositioning.coordinate(37.803784, -122.462276) PositionSource { id: positionSource updateInterval: 1000 - active: true // ScreenTools.isMobile - + active: false onPositionChanged: { - tabletPosition = positionSource.position.coordinate - flightView.latitude = tabletPosition.latitude - flightView.longitude = tabletPosition.longitude - positionSource.active = false + if(positionSource.valid) { + if(positionSource.position.coordinate.latitude) { + if(Math.abs(positionSource.position.coordinate.latitude) > 0.001) { + if(positionSource.position.coordinate.longitude) { + if(Math.abs(positionSource.position.coordinate.longitude) > 0.001) { + tabletPosition = positionSource.position.coordinate + } + } + } + } + } + positionSource.stop() } } @@ -146,20 +155,21 @@ Item { anchors.fill: parent avaiableHeight: mainWindow.avaiableHeight visible: true + Component.onCompleted: { + positionSource.start() + } } Loader { id: planViewLoader anchors.fill: parent visible: false - property var tabletPosition: mainWindow.tabletPosition } Loader { id: setupViewLoader anchors.fill: parent visible: false - property var tabletPosition: mainWindow.tabletPosition } } -- 2.22.0