Unverified Commit a7c5a57a authored by Don Gagne's avatar Don Gagne Committed by GitHub

Merge pull request #8445 from dakejahl/pr-survey_preset_default_support

Compiler switch for Survey Preset JSON generation
parents 988cd6a9 6b50da59
......@@ -20,6 +20,8 @@ const char* ComplexMissionItem::_presetSettingsKey = "_presets";
ComplexMissionItem::ComplexMissionItem(Vehicle* vehicle, bool flyView, QObject* parent)
: VisualMissionItem (vehicle, flyView, parent)
, _toolbox(qgcApp()->toolbox())
, _settingsManager(_toolbox->settingsManager())
{
}
......@@ -74,6 +76,26 @@ void ComplexMissionItem::_savePresetJson(const QString& name, QJsonObject& prese
settings.beginGroup(presetsSettingsGroup());
settings.beginGroup(_presetSettingsKey);
settings.setValue(name, QJsonDocument(presetObject).toBinaryData());
// Use this to save a survey preset as a JSON file to be included in the build
// as a built-in survey preset that cannot be deleted.
#if 0
QString savePath = _settingsManager->appSettings()->missionSavePath();
QDir saveDir(savePath);
QString fileName = saveDir.absoluteFilePath(name);
fileName.append(".json");
QFile jsonFile(fileName);
if (!jsonFile.open(QIODevice::WriteOnly)) {
qDebug() << "Couldn't open .json file.";
}
qDebug() << "Saving survey preset to JSON";
auto jsonDoc = QJsonDocument(jsonObj);
jsonFile.write(jsonDoc.toJson());
#endif
emit presetNamesChanged();
}
......
......@@ -15,6 +15,10 @@
#include <QSettings>
#include <QGCToolbox.h>
#include <SettingsManager.h>
class ComplexMissionItem : public VisualMissionItem
{
Q_OBJECT
......@@ -87,6 +91,9 @@ protected:
QMap<QString, FactMetaData*> _metaDataMap;
static const char* _presetSettingsKey;
QGCToolbox* _toolbox;
SettingsManager* _settingsManager;
};
#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