Commit 4e099083 authored by Don Gagne's avatar Don Gagne

Merge pull request #1903 from DonLakeFlyer/MoreDropdown

More Drop Button, Mission Editor, Map work
parents d2eb80af 8ff2956f
...@@ -141,6 +141,7 @@ INCLUDEPATH += \ ...@@ -141,6 +141,7 @@ INCLUDEPATH += \
src/AutoPilotPlugins \ src/AutoPilotPlugins \
src/comm \ src/comm \
src/FlightDisplay \ src/FlightDisplay \
src/FlightMap \
src/input \ src/input \
src/Joystick \ src/Joystick \
src/lib/qmapcontrol \ src/lib/qmapcontrol \
...@@ -239,6 +240,7 @@ HEADERS += \ ...@@ -239,6 +240,7 @@ HEADERS += \
src/comm/UDPLink.h \ src/comm/UDPLink.h \
src/FlightDisplay/FlightDisplayWidget.h \ src/FlightDisplay/FlightDisplayWidget.h \
src/FlightDisplay/FlightDisplayView.h \ src/FlightDisplay/FlightDisplayView.h \
src/FlightMap/FlightMapSettings.h \
src/GAudioOutput.h \ src/GAudioOutput.h \
src/HomePositionManager.h \ src/HomePositionManager.h \
src/Joystick/Joystick.h \ src/Joystick/Joystick.h \
...@@ -374,6 +376,7 @@ SOURCES += \ ...@@ -374,6 +376,7 @@ SOURCES += \
src/comm/UDPLink.cc \ src/comm/UDPLink.cc \
src/FlightDisplay/FlightDisplayWidget.cc \ src/FlightDisplay/FlightDisplayWidget.cc \
src/FlightDisplay/FlightDisplayView.cc \ src/FlightDisplay/FlightDisplayView.cc \
src/FlightMap/FlightMapSettings.cc \
src/GAudioOutput.cc \ src/GAudioOutput.cc \
src/HomePositionManager.cc \ src/HomePositionManager.cc \
src/Joystick/Joystick.cc \ src/Joystick/Joystick.cc \
......
...@@ -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>
......
...@@ -91,19 +91,3 @@ FlightDisplayView::FlightDisplayView(QWidget *parent) ...@@ -91,19 +91,3 @@ FlightDisplayView::FlightDisplayView(QWidget *parent)
FlightDisplayView::~FlightDisplayView() FlightDisplayView::~FlightDisplayView()
{ {
} }
void FlightDisplayView::saveSetting(const QString &name, const QString& value)
{
QSettings settings;
QString key(kMainFlightDisplayViewGroup);
key += "/" + name;
settings.setValue(key, value);
}
QString FlightDisplayView::loadSetting(const QString &name, const QString& defaultValue)
{
QSettings settings;
QString key(kMainFlightDisplayViewGroup);
key += "/" + name;
return settings.value(key, defaultValue).toString();
}
...@@ -38,9 +38,6 @@ public: ...@@ -38,9 +38,6 @@ public:
Q_PROPERTY(bool hasVideo READ hasVideo CONSTANT) Q_PROPERTY(bool hasVideo READ hasVideo CONSTANT)
Q_INVOKABLE void saveSetting (const QString &key, const QString& value);
Q_INVOKABLE QString loadSetting (const QString &key, const QString& defaultValue);
#if defined(QGC_GST_STREAMING) #if defined(QGC_GST_STREAMING)
bool hasVideo () { return true; } bool hasVideo () { return true; }
#else #else
......
...@@ -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
...@@ -62,42 +64,17 @@ Map { ...@@ -62,42 +64,17 @@ Map {
ExclusiveGroup { id: mapTypeGroup } ExclusiveGroup { id: mapTypeGroup }
// Map type selection MenuItem Component.onCompleted: onMapTypeChanged
Component {
id: menuItemComponent
MenuItem { onMapTypeChanged: {
checkable: true QGroundControl.flightMapSettings.setMapTypeForMapName(mapName, mapType)
checked: text == _map.activeMapType.name var fullMapName = QGroundControl.flightMapSettings.mapProvider + " " + mapType
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
......
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009 - 2015 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
QGROUNDCONTROL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
#include "FlightMapSettings.h"
#include <QSettings>
#include <QtQml>
IMPLEMENT_QGC_SINGLETON(FlightMapSettings, FlightMapSettings)
const char* FlightMapSettings::_defaultMapProvider = "Bing"; // Bing is default since it support full street/satellite/hybrid set
const char* FlightMapSettings::_settingsGroup = "FlightMapSettings";
const char* FlightMapSettings::_mapProviderKey = "MapProvider";
const char* FlightMapSettings::_mapTypeKey = "MapType";
FlightMapSettings::FlightMapSettings(QObject* parent)
: QObject(parent)
, _mapProvider(_defaultMapProvider)
{
qmlRegisterUncreatableType<FlightMapSettings> ("QGroundControl", 1, 0, "FlightMapSetting", "Reference only");
_supportedMapProviders << "Bing" << "Google" << "Open";
_loadSettings();
}
FlightMapSettings::~FlightMapSettings()
{
}
void FlightMapSettings::_storeSettings(void)
{
QSettings settings;
settings.beginGroup(_settingsGroup);
settings.setValue(_mapProviderKey, _supportedMapProviders.contains(_mapProvider) ? _mapProvider : _defaultMapProvider);
}
void FlightMapSettings::_loadSettings(void)
{
QSettings settings;
settings.beginGroup(_settingsGroup);
_mapProvider = settings.value(_mapProviderKey, _defaultMapProvider).toString();
if (!_supportedMapProviders.contains(_mapProvider)) {
_mapProvider = _defaultMapProvider;
}
_setMapTypesForCurrentProvider();
}
QString FlightMapSettings::mapProvider(void)
{
return _mapProvider;
}
void FlightMapSettings::setMapProvider(const QString& mapProvider)
{
if (_supportedMapProviders.contains(mapProvider)) {
_mapProvider = mapProvider;
_storeSettings();
_setMapTypesForCurrentProvider();
emit mapProviderChanged(mapProvider);
}
}
void FlightMapSettings::_setMapTypesForCurrentProvider(void)
{
_mapTypes.clear();
if (_mapProvider == "Bing") {
_mapTypes << "Street Map" << "Satellite Map" << "Hybrid Map";
} else if (_mapProvider == "Google") {
_mapTypes << "Street Map" << "Satellite Map" << "Terrain Map";
} else if (_mapProvider == "Open") {
_mapTypes << "Street Map";
}
emit mapTypesChanged(_mapTypes);
}
QString FlightMapSettings::mapTypeForMapName(const QString& mapName)
{
QSettings settings;
settings.beginGroup(_settingsGroup);
settings.beginGroup(mapName);
settings.beginGroup(_mapProvider);
return settings.value(_mapTypeKey, "Street Map").toString();
}
void FlightMapSettings::setMapTypeForMapName(const QString& mapName, const QString& mapType)
{
QSettings settings;
settings.beginGroup(_settingsGroup);
settings.beginGroup(mapName);
settings.beginGroup(_mapProvider);
settings.setValue(_mapTypeKey, mapType);
}
void FlightMapSettings::saveMapSetting (const QString &mapName, const QString& key, const QString& value)
{
QSettings settings;
settings.beginGroup(_settingsGroup);
settings.beginGroup(mapName);
settings.setValue(key, value);
}
QString FlightMapSettings::loadMapSetting (const QString &mapName, const QString& key, const QString& defaultValue)
{
QSettings settings;
settings.beginGroup(_settingsGroup);
settings.beginGroup(mapName);
return settings.value(key, defaultValue).toString();
}
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009 - 2015 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
QGROUNDCONTROL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
#ifndef FlightMapSettings_H
#define FlightMapSettings_H
#include "QGCSingleton.h"
#include <QStringList>
class FlightMapSettings : public QObject
{
Q_OBJECT
DECLARE_QGC_SINGLETON(FlightMapSettings, FlightMapSettings)
public:
/// mapProvider is either Bing, Google or Open to specify to set of maps available
Q_PROPERTY(QString mapProvider READ mapProvider WRITE setMapProvider NOTIFY mapProviderChanged)
/// Map types associated with current map provider
Q_PROPERTY(QStringList mapTypes MEMBER _mapTypes NOTIFY mapTypesChanged)
Q_INVOKABLE QString mapTypeForMapName(const QString& mapName);
Q_INVOKABLE void setMapTypeForMapName(const QString& mapName, const QString& mapType);
Q_INVOKABLE void saveMapSetting (const QString &mapName, const QString& key, const QString& value);
Q_INVOKABLE QString loadMapSetting (const QString &mapName, const QString& key, const QString& defaultValue);
// Property accessors
QString mapProvider(void);
void setMapProvider(const QString& mapProvider);
signals:
void mapProviderChanged(const QString& mapProvider);
void mapTypesChanged(const QStringList& mapTypes);
private:
/// @brief All access to FlightMapSettings singleton is through FlightMapSettings::instance
FlightMapSettings(QObject* parent = NULL);
~FlightMapSettings();
void _storeSettings(void);
void _loadSettings(void);
void _setMapTypesForCurrentProvider(void);
QString _mapProvider; ///< Current map provider
QStringList _supportedMapProviders;
QStringList _mapTypes; ///< Map types associated with current map provider
static const char* _defaultMapProvider;
static const char* _settingsGroup;
static const char* _mapProviderKey;
static const char* _mapTypeKey;
};
#endif
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include <QApplication> #include <QApplication>
#include <QTimer> #include <QTimer>
#include <QSettings> #include <QSettings>
#include <QtQml>
#include "UAS.h" #include "UAS.h"
#include "UASInterface.h" #include "UASInterface.h"
...@@ -51,6 +52,8 @@ HomePositionManager::HomePositionManager(QObject* parent) ...@@ -51,6 +52,8 @@ HomePositionManager::HomePositionManager(QObject* parent)
, homeLon(8.549444) , homeLon(8.549444)
, homeAlt(470.0) , homeAlt(470.0)
{ {
qmlRegisterUncreatableType<HomePositionManager> ("QGroundControl", 1, 0, "HomePositionManager", "Reference only");
_loadSettings(); _loadSettings();
} }
......
...@@ -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 { QGCButton {
text: "Satellite" checkable: true
checked: editorMap.mapType == text
text: modelData
onClicked: mapTypeButton.hideDropDown() onClicked: {
editorMap.mapType = text
mapTypeButton.hideDropDown()
}
} }
QGCButton {
text: "Hybrid"
onClicked: mapTypeButton.hideDropDown()
} }
} }
} }
......
...@@ -83,6 +83,7 @@ ...@@ -83,6 +83,7 @@
#include "MissionManager.h" #include "MissionManager.h"
#include "QGroundControlQmlGlobal.h" #include "QGroundControlQmlGlobal.h"
#include "HomePositionManager.h" #include "HomePositionManager.h"
#include "FlightMapSettings.h"
#ifndef __ios__ #ifndef __ios__
#include "SerialLink.h" #include "SerialLink.h"
...@@ -313,7 +314,6 @@ void QGCApplication::_initCommon(void) ...@@ -313,7 +314,6 @@ void QGCApplication::_initCommon(void)
qmlRegisterUncreatableType<JoystickManager> ("QGroundControl.JoystickManager", 1, 0, "JoystickManager", "Reference only"); qmlRegisterUncreatableType<JoystickManager> ("QGroundControl.JoystickManager", 1, 0, "JoystickManager", "Reference only");
qmlRegisterUncreatableType<Joystick> ("QGroundControl.JoystickManager", 1, 0, "Joystick", "Reference only"); qmlRegisterUncreatableType<Joystick> ("QGroundControl.JoystickManager", 1, 0, "Joystick", "Reference only");
qmlRegisterUncreatableType<QmlObjectListModel> ("QGroundControl", 1, 0, "QmlObjectListModel", "Reference only"); qmlRegisterUncreatableType<QmlObjectListModel> ("QGroundControl", 1, 0, "QmlObjectListModel", "Reference only");
qmlRegisterUncreatableType<HomePositionManager> ("QGroundControl", 1, 0, "HomePositionManager", "Reference only");
qmlRegisterType<ViewWidgetController> ("QGroundControl.Controllers", 1, 0, "ViewWidgetController"); qmlRegisterType<ViewWidgetController> ("QGroundControl.Controllers", 1, 0, "ViewWidgetController");
qmlRegisterType<ParameterEditorController> ("QGroundControl.Controllers", 1, 0, "ParameterEditorController"); qmlRegisterType<ParameterEditorController> ("QGroundControl.Controllers", 1, 0, "ParameterEditorController");
...@@ -550,6 +550,16 @@ void QGCApplication::_createSingletons(void) ...@@ -550,6 +550,16 @@ void QGCApplication::_createSingletons(void)
{ {
// The order here is important since the singletons reference each other // The order here is important since the singletons reference each other
// No dependencies
FlightMapSettings* flightMapSettings = FlightMapSettings::_createSingleton();
Q_UNUSED(flightMapSettings);
Q_ASSERT(flightMapSettings);
// No dependencies
HomePositionManager* homePositionManager = HomePositionManager::_createSingleton();
Q_UNUSED(homePositionManager);
Q_ASSERT(homePositionManager);
// No dependencies // No dependencies
FirmwarePlugin* firmwarePlugin = GenericFirmwarePlugin::_createSingleton(); FirmwarePlugin* firmwarePlugin = GenericFirmwarePlugin::_createSingleton();
Q_UNUSED(firmwarePlugin); Q_UNUSED(firmwarePlugin);
...@@ -584,22 +594,17 @@ void QGCApplication::_createSingletons(void) ...@@ -584,22 +594,17 @@ void QGCApplication::_createSingletons(void)
Q_UNUSED(linkManager); Q_UNUSED(linkManager);
Q_ASSERT(linkManager); Q_ASSERT(linkManager);
// Needs LinkManager // Need MultiVehicleManager
HomePositionManager* uasManager = HomePositionManager::_createSingleton();
Q_UNUSED(uasManager);
Q_ASSERT(uasManager);
// Need HomePositionManager
AutoPilotPluginManager* pluginManager = AutoPilotPluginManager::_createSingleton(); AutoPilotPluginManager* pluginManager = AutoPilotPluginManager::_createSingleton();
Q_UNUSED(pluginManager); Q_UNUSED(pluginManager);
Q_ASSERT(pluginManager); Q_ASSERT(pluginManager);
// Need HomePositionManager // Need MultiVehicleManager
UASMessageHandler* messageHandler = UASMessageHandler::_createSingleton(); UASMessageHandler* messageHandler = UASMessageHandler::_createSingleton();
Q_UNUSED(messageHandler); Q_UNUSED(messageHandler);
Q_ASSERT(messageHandler); Q_ASSERT(messageHandler);
// Needs HomePositionManager // Needs MultiVehicleManager
FactSystem* factSystem = FactSystem::_createSingleton(); FactSystem* factSystem = FactSystem::_createSingleton();
Q_UNUSED(factSystem); Q_UNUSED(factSystem);
Q_ASSERT(factSystem); Q_ASSERT(factSystem);
...@@ -631,7 +636,6 @@ void QGCApplication::_destroySingletons(void) ...@@ -631,7 +636,6 @@ void QGCApplication::_destroySingletons(void)
FactSystem::_deleteSingleton(); FactSystem::_deleteSingleton();
UASMessageHandler::_deleteSingleton(); UASMessageHandler::_deleteSingleton();
AutoPilotPluginManager::_deleteSingleton(); AutoPilotPluginManager::_deleteSingleton();
HomePositionManager::_deleteSingleton();
LinkManager::_deleteSingleton(); LinkManager::_deleteSingleton();
GAudioOutput::_deleteSingleton(); GAudioOutput::_deleteSingleton();
JoystickManager::_deleteSingleton(); JoystickManager::_deleteSingleton();
...@@ -640,6 +644,8 @@ void QGCApplication::_destroySingletons(void) ...@@ -640,6 +644,8 @@ void QGCApplication::_destroySingletons(void)
GenericFirmwarePlugin::_deleteSingleton(); GenericFirmwarePlugin::_deleteSingleton();
PX4FirmwarePlugin::_deleteSingleton(); PX4FirmwarePlugin::_deleteSingleton();
APMFirmwarePlugin::_deleteSingleton(); APMFirmwarePlugin::_deleteSingleton();
HomePositionManager::_deleteSingleton();
FlightMapSettings::_deleteSingleton();
} }
void QGCApplication::informationMessageBoxOnMainThread(const QString& title, const QString& msg) void QGCApplication::informationMessageBoxOnMainThread(const QString& title, const QString& msg)
......
...@@ -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
......
import QtQuick 2.2
import QtQuick.Controls 1.2
import QtQuick.Controls.Styles 1.2
import QGroundControl.Palette 1.0
import QGroundControl.ScreenTools 1.0
/// Canvas has some sort of bug in it which can cause it to not paint when top level Views
/// are switched. In order to fix this we ahve a signal hacked into ScreenTools to force
/// a repaint.
Canvas {
Connections {
target: ScreenTools
onRepaintRequested: arrowCanvas.requestPaint()
}
}
...@@ -9,6 +9,7 @@ QGCComboBox 1.0 QGCComboBox.qml ...@@ -9,6 +9,7 @@ QGCComboBox 1.0 QGCComboBox.qml
QGCColoredImage 1.0 QGCColoredImage.qml QGCColoredImage 1.0 QGCColoredImage.qml
QGCToolBarButton 1.0 QGCToolBarButton.qml QGCToolBarButton 1.0 QGCToolBarButton.qml
QGCMovableItem 1.0 QGCMovableItem.qml QGCMovableItem 1.0 QGCMovableItem.qml
QGCCanvas 1.0 QGCCanvas.qml
SubMenuButton 1.0 SubMenuButton.qml SubMenuButton 1.0 SubMenuButton.qml
IndicatorButton 1.0 IndicatorButton.qml IndicatorButton 1.0 IndicatorButton.qml
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
QGroundControlQmlGlobal::QGroundControlQmlGlobal(QObject* parent) QGroundControlQmlGlobal::QGroundControlQmlGlobal(QObject* parent)
: QObject(parent) : QObject(parent)
, _homePositionManager(HomePositionManager::instance()) , _homePositionManager(HomePositionManager::instance())
, _flightMapSettings(FlightMapSettings::instance())
{ {
} }
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include <QObject> #include <QObject>
#include "HomePositionManager.h" #include "HomePositionManager.h"
#include "FlightMapSettings.h"
class QGroundControlQmlGlobal : public QObject class QGroundControlQmlGlobal : public QObject
{ {
...@@ -40,13 +41,16 @@ public: ...@@ -40,13 +41,16 @@ public:
~QGroundControlQmlGlobal(); ~QGroundControlQmlGlobal();
Q_PROPERTY(HomePositionManager* homePositionManager READ homePositionManager CONSTANT) Q_PROPERTY(HomePositionManager* homePositionManager READ homePositionManager CONSTANT)
Q_PROPERTY(FlightMapSettings* flightMapSettings READ flightMapSettings CONSTANT)
// Property accesors // Property accesors
HomePositionManager* homePositionManager(void) { return _homePositionManager; } HomePositionManager* homePositionManager(void) { return _homePositionManager; }
FlightMapSettings* flightMapSettings(void) { return _flightMapSettings; }
private: private:
HomePositionManager* _homePositionManager; HomePositionManager* _homePositionManager;
FlightMapSettings* _flightMapSettings;
}; };
#endif #endif
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
#include "QGCFileDialog.h" #include "QGCFileDialog.h"
#include "QGCMessageBox.h" #include "QGCMessageBox.h"
#include "MainToolBar.h" #include "MainToolBar.h"
#include "FlightMapSettings.h"
SettingsDialog::SettingsDialog(QWidget *parent, int showTab, Qt::WindowFlags flags) : SettingsDialog::SettingsDialog(QWidget *parent, int showTab, Qt::WindowFlags flags) :
QDialog(parent, flags), QDialog(parent, flags),
...@@ -95,6 +96,17 @@ _ui(new Ui::SettingsDialog) ...@@ -95,6 +96,17 @@ _ui(new Ui::SettingsDialog)
connect(_ui->browseSavedFilesLocation, &QPushButton::clicked, this, &SettingsDialog::_selectSavedFilesDirectory); connect(_ui->browseSavedFilesLocation, &QPushButton::clicked, this, &SettingsDialog::_selectSavedFilesDirectory);
connect(_ui->buttonBox, &QDialogButtonBox::accepted, this, &SettingsDialog::_validateBeforeClose); connect(_ui->buttonBox, &QDialogButtonBox::accepted, this, &SettingsDialog::_validateBeforeClose);
// Flight Map settings
FlightMapSettings* fmSettings = FlightMapSettings::instance();
_ui->bingMapRadio->setChecked(fmSettings->mapProvider() == "Bing");
_ui->googleMapRadio->setChecked(fmSettings->mapProvider() == "Google");
_ui->openMapRadio->setChecked(fmSettings->mapProvider() == "Open");
connect(_ui->bingMapRadio, &QRadioButton::clicked, this, &SettingsDialog::_bingMapRadioClicked);
connect(_ui->googleMapRadio, &QRadioButton::clicked, this, &SettingsDialog::_googleMapRadioClicked);
connect(_ui->openMapRadio, &QRadioButton::clicked, this, &SettingsDialog::_openMapRadioClicked);
switch (showTab) { switch (showTab) {
case ShowCommLinks: case ShowCommLinks:
_ui->tabWidget->setCurrentWidget(pLinkConf); _ui->tabWidget->setCurrentWidget(pLinkConf);
...@@ -193,3 +205,24 @@ void SettingsDialog::on_showRSSI_clicked(bool checked) ...@@ -193,3 +205,24 @@ void SettingsDialog::on_showRSSI_clicked(bool checked)
{ {
_mainWindow->getMainToolBar()->viewStateChanged(TOOL_BAR_SHOW_RSSI, checked); _mainWindow->getMainToolBar()->viewStateChanged(TOOL_BAR_SHOW_RSSI, checked);
} }
void SettingsDialog::_bingMapRadioClicked(bool checked)
{
if (checked) {
FlightMapSettings::instance()->setMapProvider("Bing");
}
}
void SettingsDialog::_googleMapRadioClicked(bool checked)
{
if (checked) {
FlightMapSettings::instance()->setMapProvider("Google");
}
}
void SettingsDialog::_openMapRadioClicked(bool checked)
{
if (checked) {
FlightMapSettings::instance()->setMapProvider("Open");
}
}
...@@ -63,6 +63,10 @@ private slots: ...@@ -63,6 +63,10 @@ private slots:
void on_showRSSI_clicked(bool checked); void on_showRSSI_clicked(bool checked);
void _bingMapRadioClicked(bool checked);
void _googleMapRadioClicked(bool checked);
void _openMapRadioClicked(bool checked);
private: private:
MainWindow* _mainWindow; MainWindow* _mainWindow;
Ui::SettingsDialog* _ui; Ui::SettingsDialog* _ui;
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>500</width> <width>500</width>
<height>596</height> <height>689</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">
...@@ -115,6 +115,36 @@ ...@@ -115,6 +115,36 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QGroupBox" name="groupBox_4">
<property name="title">
<string>Map Provider</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QRadioButton" name="bingMapRadio">
<property name="text">
<string>Bing</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="googleMapRadio">
<property name="text">
<string>Google</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="openMapRadio">
<property name="text">
<string>Open Streets</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item> <item>
<widget class="QGroupBox" name="groupBox"> <widget class="QGroupBox" name="groupBox">
<property name="sizePolicy"> <property name="sizePolicy">
......
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