Unverified Commit 048ff809 authored by Don Gagne's avatar Don Gagne Committed by GitHub

Merge pull request #6743 from DonLakeFlyer/ParameterFileSave

Set parameter file extension if needed
parents 8935598f 7bf50ed9
...@@ -33,6 +33,7 @@ QGCView { ...@@ -33,6 +33,7 @@ QGCView {
property var _searchResults ///< List of parameter names from search results property var _searchResults ///< List of parameter names from search results
property bool _showRCToParam: !ScreenTools.isMobile && QGroundControl.multiVehicleManager.activeVehicle.px4Firmware property bool _showRCToParam: !ScreenTools.isMobile && QGroundControl.multiVehicleManager.activeVehicle.px4Firmware
property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle
property var _appSettings: QGroundControl.settingsManager.appSettings
ParameterEditorController { ParameterEditorController {
id: controller; id: controller;
...@@ -112,28 +113,18 @@ QGCView { ...@@ -112,28 +113,18 @@ QGCView {
MenuItem { MenuItem {
text: qsTr("Load from file...") text: qsTr("Load from file...")
onTriggered: { onTriggered: {
var appSettings = QGroundControl.settingsManager.appSettings
fileDialog.qgcView = qgcView fileDialog.qgcView = qgcView
fileDialog.title = qsTr("Select Parameter File") fileDialog.title = qsTr("Load Parameters")
fileDialog.selectExisting = true fileDialog.selectExisting = true
fileDialog.folder = appSettings.parameterSavePath
fileDialog.fileExtension = appSettings.parameterFileExtension
fileDialog.nameFilters = [ qsTr("Parameter Files (*.%1)").arg(appSettings.parameterFileExtension) , qsTr("All Files (*.*)") ]
fileDialog.openForLoad() fileDialog.openForLoad()
} }
} }
MenuItem { MenuItem {
text: qsTr("Save to file...") text: qsTr("Save to file...")
onTriggered: { onTriggered: {
var appSettings = QGroundControl.settingsManager.appSettings
fileDialog.qgcView = qgcView fileDialog.qgcView = qgcView
fileDialog.title = qsTr("Save Parameters") fileDialog.title = qsTr("Save Parameters")
fileDialog.selectExisting = false fileDialog.selectExisting = false
fileDialog.folder = appSettings.parameterSavePath
fileDialog.fileExtension = appSettings.parameterFileExtension
fileDialog.nameFilters = [ qsTr("Parameter Files (*.%1)").arg(appSettings.parameterFileExtension) , qsTr("All Files (*.*)") ]
fileDialog.openForSave() fileDialog.openForSave()
} }
} }
...@@ -293,6 +284,9 @@ QGCView { ...@@ -293,6 +284,9 @@ QGCView {
QGCFileDialog { QGCFileDialog {
id: fileDialog id: fileDialog
folder: _appSettings.parameterSavePath
fileExtension: _appSettings.parameterFileExtension
nameFilters: [ qsTr("Parameter Files (*.%1)").arg(_appSettings.parameterFileExtension) , qsTr("All Files (*.*)") ]
onAcceptedForSave: { onAcceptedForSave: {
controller.saveToFile(file) controller.saveToFile(file)
......
...@@ -98,10 +98,15 @@ void ParameterEditorController::clearRCToParam(void) ...@@ -98,10 +98,15 @@ void ParameterEditorController::clearRCToParam(void)
void ParameterEditorController::saveToFile(const QString& filename) void ParameterEditorController::saveToFile(const QString& filename)
{ {
if (!filename.isEmpty()) { if (!filename.isEmpty()) {
QFile file(filename); QString parameterFilename = filename;
if (!QFileInfo(filename).fileName().contains(".")) {
parameterFilename += QString(".%1").arg(AppSettings::parameterFileExtension);
}
QFile file(parameterFilename);
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) { if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
qgcApp()->showMessage(tr("Unable to create file: %1").arg(filename)); qgcApp()->showMessage(tr("Unable to create file: %1").arg(parameterFilename));
return; return;
} }
......
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