Commit 12b1624e authored by DonLakeFlyer's avatar DonLakeFlyer

More work on Plan sync user model

parent 62fb732c
...@@ -65,11 +65,11 @@ ColumnLayout { ...@@ -65,11 +65,11 @@ ColumnLayout {
QGCButton { QGCButton {
text: qsTr("Current Location") text: qsTr("Current Location")
Layout.fillWidth: true Layout.fillWidth: true
enabled: mainWindow.gcsPosition.isValid enabled: _map.gcsPosition.isValid
onClicked: { onClicked: {
dropPanel.hide() dropPanel.hide()
map.center = mainWindow.gcsPosition map.center = _map.gcsPosition
} }
} }
......
...@@ -56,6 +56,7 @@ MissionController::MissionController(QObject *parent) ...@@ -56,6 +56,7 @@ MissionController::MissionController(QObject *parent)
, _queuedSend(false) , _queuedSend(false)
, _surveyMissionItemName(tr("Survey")) , _surveyMissionItemName(tr("Survey"))
, _fwLandingMissionItemName(tr("Fixed Wing Landing")) , _fwLandingMissionItemName(tr("Fixed Wing Landing"))
, _appSettings(qgcApp()->toolbox()->settingsManager()->appSettings())
{ {
_missionFlightStatus.maxTelemetryDistance = 0; _missionFlightStatus.maxTelemetryDistance = 0;
_missionFlightStatus.totalDistance = 0; _missionFlightStatus.totalDistance = 0;
...@@ -449,18 +450,18 @@ bool MissionController::_loadJsonMissionFileV2(Vehicle* vehicle, const QJsonObje ...@@ -449,18 +450,18 @@ bool MissionController::_loadJsonMissionFileV2(Vehicle* vehicle, const QJsonObje
// Mission Settings // Mission Settings
QGeoCoordinate homeCoordinate; QGeoCoordinate homeCoordinate;
SettingsManager* settingsManager = qgcApp()->toolbox()->settingsManager(); AppSettings* appSettings = qgcApp()->toolbox()->settingsManager()->appSettings();
if (!JsonHelper::loadGeoCoordinate(json[_jsonPlannedHomePositionKey], true /* altitudeRequired */, homeCoordinate, errorString)) { if (!JsonHelper::loadGeoCoordinate(json[_jsonPlannedHomePositionKey], true /* altitudeRequired */, homeCoordinate, errorString)) {
return false; return false;
} }
if (json.contains(_jsonVehicleTypeKey) && vehicle->isOfflineEditingVehicle()) { if (json.contains(_jsonVehicleTypeKey) && vehicle->isOfflineEditingVehicle()) {
settingsManager->appSettings()->offlineEditingVehicleType()->setRawValue(json[_jsonVehicleTypeKey].toDouble()); appSettings->offlineEditingVehicleType()->setRawValue(json[_jsonVehicleTypeKey].toDouble());
} }
if (json.contains(_jsonCruiseSpeedKey)) { if (json.contains(_jsonCruiseSpeedKey)) {
settingsManager->appSettings()->offlineEditingCruiseSpeed()->setRawValue(json[_jsonCruiseSpeedKey].toDouble()); appSettings->offlineEditingCruiseSpeed()->setRawValue(json[_jsonCruiseSpeedKey].toDouble());
} }
if (json.contains(_jsonHoverSpeedKey)) { if (json.contains(_jsonHoverSpeedKey)) {
settingsManager->appSettings()->offlineEditingHoverSpeed()->setRawValue(json[_jsonHoverSpeedKey].toDouble()); appSettings->offlineEditingHoverSpeed()->setRawValue(json[_jsonHoverSpeedKey].toDouble());
} }
MissionSettingsItem* settingsItem = new MissionSettingsItem(vehicle, visualItems); MissionSettingsItem* settingsItem = new MissionSettingsItem(vehicle, visualItems);
...@@ -647,17 +648,27 @@ void MissionController::loadFromFile(const QString& filename) ...@@ -647,17 +648,27 @@ void MissionController::loadFromFile(const QString& filename)
_initAllVisualItems(); _initAllVisualItems();
// Split the filename into directory and filename
QString filenameOnly = filename; QString filenameOnly = filename;
int lastSepIndex = filename.lastIndexOf(QStringLiteral("/")); int lastSepIndex = filename.lastIndexOf(QStringLiteral("/"));
if (lastSepIndex != -1) { if (lastSepIndex != -1) {
filenameOnly = filename.right(filename.length() - lastSepIndex - 1); filenameOnly = filename.right(filename.length() - lastSepIndex - 1);
} }
QString directoryOnly = filename.left(filename.length() - filenameOnly.length() - 1);
QString extension = AppSettings::missionFileExtension; QString extension = AppSettings::missionFileExtension;
if (filenameOnly.endsWith("." + extension)) { if (filenameOnly.endsWith("." + extension)) {
filenameOnly = filenameOnly.left(filenameOnly.length() - extension.length() - 1); filenameOnly = filenameOnly.left(filenameOnly.length() - extension.length() - 1);
} }
_settingsItem->missionName()->setRawValue(filenameOnly); _settingsItem->missionName()->setRawValue(filenameOnly);
if (directoryOnly == qgcApp()->toolbox()->settingsManager()->appSettings()->missionSavePath()) {
QString emptyString;
_settingsItem->setLoadedMissionDirectory(emptyString);
} else {
_settingsItem->setLoadedMissionDirectory(directoryOnly);
}
_settingsItem->setExistingMission(true); _settingsItem->setExistingMission(true);
sendToVehicle(); sendToVehicle();
...@@ -704,8 +715,6 @@ bool MissionController::loadItemsFromFile(Vehicle* vehicle, const QString& filen ...@@ -704,8 +715,6 @@ bool MissionController::loadItemsFromFile(Vehicle* vehicle, const QString& filen
void MissionController::saveToFile(const QString& filename) void MissionController::saveToFile(const QString& filename)
{ {
qDebug() << filename;
if (filename.isEmpty()) { if (filename.isEmpty()) {
return; return;
} }
...@@ -718,7 +727,7 @@ void MissionController::saveToFile(const QString& filename) ...@@ -718,7 +727,7 @@ void MissionController::saveToFile(const QString& filename)
QFile file(missionFilename); QFile file(missionFilename);
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) { if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
qgcApp()->showMessage(file.errorString()); qgcApp()->showMessage(tr("Mission save %1 : %2").arg(filename).arg(file.errorString()));
} else { } else {
QJsonObject missionFileObject; // top level json object QJsonObject missionFileObject; // top level json object
...@@ -1596,9 +1605,17 @@ bool MissionController::missionInProgress(void) const ...@@ -1596,9 +1605,17 @@ bool MissionController::missionInProgress(void) const
void MissionController::save(void) void MissionController::save(void)
{ {
// Save to file if the mission is named // Save to file if the mission is named
QString missionFullPath = _settingsItem->missionFullPath()->rawValue().toString();
if (!missionFullPath.isEmpty()) { QString missionDir = _settingsItem->loadedMissionDirectory();
saveToFile(missionFullPath); if (missionDir.isEmpty()) {
missionDir = _appSettings->missionSavePath();
}
bool savedToFile = false;
QString missionName = _settingsItem->missionName()->rawValue().toString();
if (!missionDir.isEmpty() && !missionName.isEmpty()) {
savedToFile = true;
saveToFile(missionDir + "/" + missionName);
} }
// Send to vehicle if we are connected // Send to vehicle if we are connected
...@@ -1606,11 +1623,22 @@ void MissionController::save(void) ...@@ -1606,11 +1623,22 @@ void MissionController::save(void)
sendToVehicle(); sendToVehicle();
} }
_settingsItem->setExistingMission(_visualItems->count() > 1 && !missionFullPath.isEmpty()); _settingsItem->setExistingMission(savedToFile);
} }
void MissionController::clearMission(void) void MissionController::clearMission(void)
{
// We need to save the mission information around removeAll all since it delete/recreates settings item
QString missionName = _settingsItem->missionName()->rawValue().toString();
QString loadedMissionDirectory = _settingsItem->loadedMissionDirectory();
bool existingMission = _settingsItem->existingMission();
removeAll();
_settingsItem->missionName()->setRawValue(missionName);
_settingsItem->setLoadedMissionDirectory(loadedMissionDirectory);
_settingsItem->setExistingMission(existingMission);
}
void MissionController::closeMission(void)
{ {
removeAll(); removeAll();
save();
} }
...@@ -23,6 +23,7 @@ class CoordinateVector; ...@@ -23,6 +23,7 @@ class CoordinateVector;
class VisualMissionItem; class VisualMissionItem;
class MissionItem; class MissionItem;
class MissionSettingsItem; class MissionSettingsItem;
class AppSettings;
Q_DECLARE_LOGGING_CATEGORY(MissionControllerLog) Q_DECLARE_LOGGING_CATEGORY(MissionControllerLog)
...@@ -88,9 +89,15 @@ public: ...@@ -88,9 +89,15 @@ public:
/// Sends the mission items to the specified vehicle /// Sends the mission items to the specified vehicle
static void sendItemsToVehicle(Vehicle* vehicle, QmlObjectListModel* visualMissionItems); static void sendItemsToVehicle(Vehicle* vehicle, QmlObjectListModel* visualMissionItems);
/// Saves the mission to file if any and sends to vehicle
Q_INVOKABLE void save(void); Q_INVOKABLE void save(void);
/// Removes all items from the mission saving and sending as needed
Q_INVOKABLE void clearMission(void); Q_INVOKABLE void clearMission(void);
/// Closes the mission, saving and sending as needed before closing
Q_INVOKABLE void closeMission(void);
// Overrides from PlanElementController // Overrides from PlanElementController
void start (bool editMode) final; void start (bool editMode) final;
void startStaticActiveVehicle (Vehicle* vehicle) final; void startStaticActiveVehicle (Vehicle* vehicle) final;
...@@ -193,6 +200,7 @@ private: ...@@ -193,6 +200,7 @@ private:
MissionFlightStatus_t _missionFlightStatus; MissionFlightStatus_t _missionFlightStatus;
QString _surveyMissionItemName; QString _surveyMissionItemName;
QString _fwLandingMissionItemName; QString _fwLandingMissionItemName;
AppSettings* _appSettings;
static const char* _settingsGroup; static const char* _settingsGroup;
......
...@@ -24,7 +24,6 @@ QGC_LOGGING_CATEGORY(MissionSettingsComplexItemLog, "MissionSettingsComplexItemL ...@@ -24,7 +24,6 @@ QGC_LOGGING_CATEGORY(MissionSettingsComplexItemLog, "MissionSettingsComplexItemL
const char* MissionSettingsItem::jsonComplexItemTypeValue = "MissionSettings"; const char* MissionSettingsItem::jsonComplexItemTypeValue = "MissionSettings";
const char* MissionSettingsItem::_missionNameName = "MissionName"; const char* MissionSettingsItem::_missionNameName = "MissionName";
const char* MissionSettingsItem::_missionFullPathName = "MissionFullPath";
const char* MissionSettingsItem::_plannedHomePositionAltitudeName = "PlannedHomePositionAltitude"; const char* MissionSettingsItem::_plannedHomePositionAltitudeName = "PlannedHomePositionAltitude";
const char* MissionSettingsItem::_missionFlightSpeedName = "FlightSpeed"; const char* MissionSettingsItem::_missionFlightSpeedName = "FlightSpeed";
const char* MissionSettingsItem::_missionEndActionName = "MissionEndAction"; const char* MissionSettingsItem::_missionEndActionName = "MissionEndAction";
...@@ -36,7 +35,6 @@ MissionSettingsItem::MissionSettingsItem(Vehicle* vehicle, QObject* parent) ...@@ -36,7 +35,6 @@ MissionSettingsItem::MissionSettingsItem(Vehicle* vehicle, QObject* parent)
, _existingMission(false) , _existingMission(false)
, _specifyMissionFlightSpeed(false) , _specifyMissionFlightSpeed(false)
, _missionNameFact (0, _missionNameName, FactMetaData::valueTypeString) , _missionNameFact (0, _missionNameName, FactMetaData::valueTypeString)
, _missionFullPathFact (0, _missionFullPathName, FactMetaData::valueTypeString)
, _plannedHomePositionAltitudeFact (0, _plannedHomePositionAltitudeName, FactMetaData::valueTypeDouble) , _plannedHomePositionAltitudeFact (0, _plannedHomePositionAltitudeName, FactMetaData::valueTypeDouble)
, _missionFlightSpeedFact (0, _missionFlightSpeedName, FactMetaData::valueTypeDouble) , _missionFlightSpeedFact (0, _missionFlightSpeedName, FactMetaData::valueTypeDouble)
, _missionEndActionFact (0, _missionEndActionName, FactMetaData::valueTypeUint32) , _missionEndActionFact (0, _missionEndActionName, FactMetaData::valueTypeUint32)
...@@ -65,8 +63,6 @@ MissionSettingsItem::MissionSettingsItem(Vehicle* vehicle, QObject* parent) ...@@ -65,8 +63,6 @@ MissionSettingsItem::MissionSettingsItem(Vehicle* vehicle, QObject* parent)
setHomePositionSpecialCase(true); setHomePositionSpecialCase(true);
connect(&_missionNameFact, &Fact::valueChanged, this, &MissionSettingsItem::_missionNameChanged);
connect(this, &MissionSettingsItem::specifyMissionFlightSpeedChanged, this, &MissionSettingsItem::_setDirtyAndUpdateLastSequenceNumber); connect(this, &MissionSettingsItem::specifyMissionFlightSpeedChanged, this, &MissionSettingsItem::_setDirtyAndUpdateLastSequenceNumber);
connect(&_cameraSection, &CameraSection::missionItemCountChanged, this, &MissionSettingsItem::_setDirtyAndUpdateLastSequenceNumber); connect(&_cameraSection, &CameraSection::missionItemCountChanged, this, &MissionSettingsItem::_setDirtyAndUpdateLastSequenceNumber);
...@@ -416,18 +412,6 @@ void MissionSettingsItem::_updateAltitudeInCoordinate(QVariant value) ...@@ -416,18 +412,6 @@ void MissionSettingsItem::_updateAltitudeInCoordinate(QVariant value)
} }
} }
void MissionSettingsItem::_missionNameChanged(QVariant value)
{
QString missionDir = qgcApp()->toolbox()->settingsManager()->appSettings()->missionSavePath();
QString missionName = value.toString();
if (missionName.isEmpty()) {
_missionFullPathFact.setRawValue(QString());
} else {
_missionFullPathFact.setRawValue(missionDir + "/" + missionName);
}
}
void MissionSettingsItem::setExistingMission(bool existingMission) void MissionSettingsItem::setExistingMission(bool existingMission)
{ {
if (existingMission != _existingMission) { if (existingMission != _existingMission) {
...@@ -435,3 +419,11 @@ void MissionSettingsItem::setExistingMission(bool existingMission) ...@@ -435,3 +419,11 @@ void MissionSettingsItem::setExistingMission(bool existingMission)
emit existingMissionChanged(existingMission ); emit existingMissionChanged(existingMission );
} }
} }
void MissionSettingsItem::setLoadedMissionDirectory(QString& loadedMissionDirectory)
{
if (_loadedMissionDirectory != loadedMissionDirectory) {
_loadedMissionDirectory = loadedMissionDirectory;
emit loadedMissionDirectoryChanged(loadedMissionDirectory);
}
}
...@@ -33,7 +33,7 @@ public: ...@@ -33,7 +33,7 @@ public:
Q_ENUMS(MissionEndAction) Q_ENUMS(MissionEndAction)
Q_PROPERTY(Fact* missionName READ missionName CONSTANT) Q_PROPERTY(Fact* missionName READ missionName CONSTANT)
Q_PROPERTY(Fact* missionFullPath READ missionFullPath CONSTANT) Q_PROPERTY(QString loadedMissionDirectory READ loadedMissionDirectory WRITE setLoadedMissionDirectory NOTIFY loadedMissionDirectoryChanged)
Q_PROPERTY(bool existingMission READ existingMission WRITE setExistingMission NOTIFY existingMissionChanged) Q_PROPERTY(bool existingMission READ existingMission WRITE setExistingMission NOTIFY existingMissionChanged)
Q_PROPERTY(bool specifyMissionFlightSpeed READ specifyMissionFlightSpeed WRITE setSpecifyMissionFlightSpeed NOTIFY specifyMissionFlightSpeedChanged) Q_PROPERTY(bool specifyMissionFlightSpeed READ specifyMissionFlightSpeed WRITE setSpecifyMissionFlightSpeed NOTIFY specifyMissionFlightSpeedChanged)
Q_PROPERTY(Fact* missionFlightSpeed READ missionFlightSpeed CONSTANT) Q_PROPERTY(Fact* missionFlightSpeed READ missionFlightSpeed CONSTANT)
...@@ -42,7 +42,6 @@ public: ...@@ -42,7 +42,6 @@ public:
Q_PROPERTY(QObject* cameraSection READ cameraSection CONSTANT) Q_PROPERTY(QObject* cameraSection READ cameraSection CONSTANT)
Fact* missionName (void) { return &_missionNameFact; } Fact* missionName (void) { return &_missionNameFact; }
Fact* missionFullPath (void) { return &_missionFullPathFact; }
Fact* plannedHomePositionAltitude (void) { return &_plannedHomePositionAltitudeFact; } Fact* plannedHomePositionAltitude (void) { return &_plannedHomePositionAltitudeFact; }
Fact* missionFlightSpeed (void) { return &_missionFlightSpeedFact; } Fact* missionFlightSpeed (void) { return &_missionFlightSpeedFact; }
Fact* missionEndAction (void) { return &_missionEndActionFact; } Fact* missionEndAction (void) { return &_missionEndActionFact; }
...@@ -63,6 +62,10 @@ public: ...@@ -63,6 +62,10 @@ public:
/// @return true: Mission end action was added /// @return true: Mission end action was added
bool addMissionEndAction(QList<MissionItem*>& items, int seqNum, QObject* missionItemParent); bool addMissionEndAction(QList<MissionItem*>& items, int seqNum, QObject* missionItemParent);
// Returns the directory the misiosn was loaded from. Empty string is laoded from normal savePath.
QString loadedMissionDirectory(void) const { return _loadedMissionDirectory; }
void setLoadedMissionDirectory(QString& loadedMissionDirectory);
// Overrides from ComplexMissionItem // Overrides from ComplexMissionItem
double complexDistance (void) const final; double complexDistance (void) const final;
...@@ -102,23 +105,23 @@ public: ...@@ -102,23 +105,23 @@ public:
signals: signals:
void specifyMissionFlightSpeedChanged(bool specifyMissionFlightSpeed); void specifyMissionFlightSpeedChanged(bool specifyMissionFlightSpeed);
void existingMissionChanged(bool existingMission); void existingMissionChanged(bool existingMission);
void loadedMissionDirectoryChanged(QString& loadedMissionDirectory);
private slots: private slots:
void _setDirtyAndUpdateLastSequenceNumber (void); void _setDirtyAndUpdateLastSequenceNumber (void);
void _setDirty (void); void _setDirty (void);
void _cameraSectionDirtyChanged (bool dirty); void _cameraSectionDirtyChanged (bool dirty);
void _updateAltitudeInCoordinate (QVariant value); void _updateAltitudeInCoordinate (QVariant value);
void _missionNameChanged (QVariant value);
private: private:
bool _existingMission; bool _existingMission;
bool _specifyMissionFlightSpeed; bool _specifyMissionFlightSpeed;
QGeoCoordinate _plannedHomePositionCoordinate; // Does not include altitde QGeoCoordinate _plannedHomePositionCoordinate; // Does not include altitde
Fact _missionNameFact; Fact _missionNameFact;
Fact _missionFullPathFact;
Fact _plannedHomePositionAltitudeFact; Fact _plannedHomePositionAltitudeFact;
Fact _missionFlightSpeedFact; Fact _missionFlightSpeedFact;
Fact _missionEndActionFact; Fact _missionEndActionFact;
QString _loadedMissionDirectory;
CameraSection _cameraSection; CameraSection _cameraSection;
int _sequenceNumber; int _sequenceNumber;
...@@ -127,7 +130,6 @@ private: ...@@ -127,7 +130,6 @@ private:
static QMap<QString, FactMetaData*> _metaDataMap; static QMap<QString, FactMetaData*> _metaDataMap;
static const char* _missionNameName; static const char* _missionNameName;
static const char* _missionFullPathName;
static const char* _plannedHomePositionAltitudeName; static const char* _plannedHomePositionAltitudeName;
static const char* _missionFlightSpeedName; static const char* _missionFlightSpeedName;
static const char* _missionEndActionName; static const char* _missionEndActionName;
......
...@@ -13,7 +13,6 @@ import QGroundControl.Palette 1.0 ...@@ -13,7 +13,6 @@ import QGroundControl.Palette 1.0
/// Mission item edit control /// Mission item edit control
Rectangle { Rectangle {
id: _root id: _root
height: editorLoader.y + editorLoader.height + (_margin * 2) height: editorLoader.y + editorLoader.height + (_margin * 2)
color: _currentItem ? qgcPal.primaryButton : qgcPal.windowShade color: _currentItem ? qgcPal.primaryButton : qgcPal.windowShade
radius: _radius radius: _radius
...@@ -21,6 +20,7 @@ Rectangle { ...@@ -21,6 +20,7 @@ Rectangle {
property var map ///< Map control property var map ///< Map control
property var missionItem ///< MissionItem associated with this editor property var missionItem ///< MissionItem associated with this editor
property bool readOnly ///< true: read only view, false: full editing view property bool readOnly ///< true: read only view, false: full editing view
property var rootQgcView
signal clicked signal clicked
signal remove signal remove
......
...@@ -35,6 +35,7 @@ Rectangle { ...@@ -35,6 +35,7 @@ Rectangle {
property bool _noMissionName: missionItem.missionName.valueString === "" property bool _noMissionName: missionItem.missionName.valueString === ""
property bool _showMissionList: _noMissionItemsAdded && (_noMissionName || _newMissionAlreadyExists) property bool _showMissionList: _noMissionItemsAdded && (_noMissionName || _newMissionAlreadyExists)
property bool _existingMissionLoaded: missionItem.existingMission property bool _existingMissionLoaded: missionItem.existingMission
property var _appSettings: QGroundControl.settingsManager.appSettings
readonly property string _firmwareLabel: qsTr("Firmware") readonly property string _firmwareLabel: qsTr("Firmware")
readonly property string _vehicleLabel: qsTr("Vehicle") readonly property string _vehicleLabel: qsTr("Vehicle")
...@@ -97,12 +98,38 @@ Rectangle { ...@@ -97,12 +98,38 @@ Rectangle {
visible: !_existingMissionLoaded && _newMissionAlreadyExists visible: !_existingMissionLoaded && _newMissionAlreadyExists
} }
FactCheckBox {
id: automaticUploadCheckbox
text: qsTr("Automatically upload on exit")
fact: _appSettings.automaticMissionUpload
}
RowLayout {
anchors.left: parent.left
anchors.right: parent.right
QGCButton { QGCButton {
text: qsTr("Clear mission") text: qsTr("Clear")
visible: !_noMissionItemsAdded visible: !_noMissionItemsAdded
Layout.fillWidth: true
onClicked: missionController.clearMission() onClicked: missionController.clearMission()
} }
QGCButton {
text: qsTr("Close")
visible: !_noMissionItemsAdded
Layout.fillWidth: true
onClicked: missionController.closeMission()
}
QGCButton {
text: qsTr("Upload")
visible: !_noMissionItemsAdded && !automaticUploadCheckbox.checked
Layout.fillWidth: true
onClicked: missionController.sendToVehicle()
}
}
Loader { Loader {
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
...@@ -132,14 +159,36 @@ Rectangle { ...@@ -132,14 +159,36 @@ Rectangle {
showSpacer: false showSpacer: false
} }
QGCButton { RowLayout {
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
text: qsTr("Load from Vehicle")
QGCButton {
text: qsTr("From Vehicle")
visible: !_offlineEditing visible: !_offlineEditing
Layout.fillWidth: true
onClicked: missionController.loadFromVehicle()
}
onClicked: { QGCButton {
missionController.loadFromVehicle() text: qsTr("Browse")
Layout.fillWidth: true
onClicked: fileDialog.openForLoad()
QGCFileDialog {
id: fileDialog
qgcView: rootQgcView
title: qsTr("Select mission file")
selectExisting: true
folder: _appSettings.missionSavePath
fileExtension: _appSettings.missionFileExtension
nameFilters: [ qsTr("Mission Files (*.%1)").arg(fileExtension) , qsTr("All Files (*.*)") ]
onAcceptedForLoad: {
missionController.loadFromFile(file)
fileDialog.close()
}
}
} }
} }
...@@ -337,5 +386,5 @@ Rectangle { ...@@ -337,5 +386,5 @@ Rectangle {
} }
} }
} // Column } // Column
} } // Deferred loader
} // Rectangle } // Rectangle
...@@ -80,7 +80,6 @@ Rectangle { ...@@ -80,7 +80,6 @@ Rectangle {
checked: false checked: false
onClicked: { onClicked: {
console.log("Leave plan clicked")
checked = false checked = false
missionController.saveOnSwitch() missionController.saveOnSwitch()
showFlyView() showFlyView()
......
This diff is collapsed.
...@@ -115,6 +115,13 @@ ...@@ -115,6 +115,13 @@
"type": "bool", "type": "bool",
"defaultValue": false "defaultValue": false
}, },
{
"name": "AutomaticMissionUpload",
"shortDescription": "Automatic mission upload",
"longDescription": "Automatically upload mission to vehicle after changes",
"type": "bool",
"defaultValue": true
},
{ {
"name": "SavePath", "name": "SavePath",
"shortDescription": "Application save directory", "shortDescription": "Application save directory",
......
...@@ -31,6 +31,7 @@ const char* AppSettings::indoorPaletteName = "StyleIs ...@@ -31,6 +31,7 @@ const char* AppSettings::indoorPaletteName = "StyleIs
const char* AppSettings::showLargeCompassName = "ShowLargeCompass"; const char* AppSettings::showLargeCompassName = "ShowLargeCompass";
const char* AppSettings::savePathName = "SavePath"; const char* AppSettings::savePathName = "SavePath";
const char* AppSettings::autoLoadMissionsName = "AutoLoadMissions"; const char* AppSettings::autoLoadMissionsName = "AutoLoadMissions";
const char* AppSettings::automaticMissionUploadName = "AutomaticMissionUpload";
const char* AppSettings::parameterFileExtension = "params"; const char* AppSettings::parameterFileExtension = "params";
const char* AppSettings::missionFileExtension = "mission"; const char* AppSettings::missionFileExtension = "mission";
...@@ -59,6 +60,7 @@ AppSettings::AppSettings(QObject* parent) ...@@ -59,6 +60,7 @@ AppSettings::AppSettings(QObject* parent)
, _showLargeCompassFact(NULL) , _showLargeCompassFact(NULL)
, _savePathFact(NULL) , _savePathFact(NULL)
, _autoLoadMissionsFact(NULL) , _autoLoadMissionsFact(NULL)
, _automaticMissionUpload(NULL)
{ {
QQmlEngine::setObjectOwnership(this, QQmlEngine::CppOwnership); QQmlEngine::setObjectOwnership(this, QQmlEngine::CppOwnership);
qmlRegisterUncreatableType<AppSettings>("QGroundControl.SettingsManager", 1, 0, "AppSettings", "Reference only"); qmlRegisterUncreatableType<AppSettings>("QGroundControl.SettingsManager", 1, 0, "AppSettings", "Reference only");
...@@ -276,3 +278,12 @@ Fact* AppSettings::autoLoadMissions(void) ...@@ -276,3 +278,12 @@ Fact* AppSettings::autoLoadMissions(void)
return _autoLoadMissionsFact; return _autoLoadMissionsFact;
} }
Fact* AppSettings::automaticMissionUpload(void)
{
if (!_automaticMissionUpload) {
_automaticMissionUpload = _createSettingsFact(automaticMissionUploadName);
}
return _automaticMissionUpload;
}
...@@ -34,6 +34,7 @@ public: ...@@ -34,6 +34,7 @@ public:
Q_PROPERTY(Fact* showLargeCompass READ showLargeCompass CONSTANT) Q_PROPERTY(Fact* showLargeCompass READ showLargeCompass CONSTANT)
Q_PROPERTY(Fact* savePath READ savePath CONSTANT) Q_PROPERTY(Fact* savePath READ savePath CONSTANT)
Q_PROPERTY(Fact* autoLoadMissions READ autoLoadMissions CONSTANT) Q_PROPERTY(Fact* autoLoadMissions READ autoLoadMissions CONSTANT)
Q_PROPERTY(Fact* automaticMissionUpload READ automaticMissionUpload CONSTANT)
Q_PROPERTY(QString missionSavePath READ missionSavePath NOTIFY savePathsChanged) Q_PROPERTY(QString missionSavePath READ missionSavePath NOTIFY savePathsChanged)
Q_PROPERTY(QString parameterSavePath READ parameterSavePath NOTIFY savePathsChanged) Q_PROPERTY(QString parameterSavePath READ parameterSavePath NOTIFY savePathsChanged)
...@@ -58,6 +59,7 @@ public: ...@@ -58,6 +59,7 @@ public:
Fact* showLargeCompass (void); Fact* showLargeCompass (void);
Fact* savePath (void); Fact* savePath (void);
Fact* autoLoadMissions (void); Fact* autoLoadMissions (void);
Fact* automaticMissionUpload (void);
QString missionSavePath (void); QString missionSavePath (void);
QString parameterSavePath (void); QString parameterSavePath (void);
...@@ -80,6 +82,7 @@ public: ...@@ -80,6 +82,7 @@ public:
static const char* showLargeCompassName; static const char* showLargeCompassName;
static const char* savePathName; static const char* savePathName;
static const char* autoLoadMissionsName; static const char* autoLoadMissionsName;
static const char* automaticMissionUploadName;
// Application wide file extensions // Application wide file extensions
static const char* parameterFileExtension; static const char* parameterFileExtension;
...@@ -116,6 +119,7 @@ private: ...@@ -116,6 +119,7 @@ private:
SettingsFact* _showLargeCompassFact; SettingsFact* _showLargeCompassFact;
SettingsFact* _savePathFact; SettingsFact* _savePathFact;
SettingsFact* _autoLoadMissionsFact; SettingsFact* _autoLoadMissionsFact;
SettingsFact* _automaticMissionUpload;
}; };
#endif #endif
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