Re #4224: Enable reading and writing Models and Settings from/to Horu… (#4254)

* Re #4224: Enable reading and writing Models and Settings from/to Horus radio (SD card)

* Fix for findMassstoragePath() on Windows (which got there in previous commit)
This commit is contained in:
Damjan Adamic
2017-01-19 21:26:18 +01:00
committed by Bertrand Songis
parent 3c62cbf200
commit e59a51e25f
5 changed files with 46 additions and 15 deletions
+27 -7
View File
@@ -31,6 +31,7 @@
#include "wizarddialog.h"
#include "flashfirmwaredialog.h"
#include "storage.h"
#include "radiointerface.h"
#if defined _MSC_VER || !defined __GNUC__
#include <windows.h>
@@ -41,6 +42,7 @@
MdiChild::MdiChild(MainWindow * parent):
QWidget(),
parent(parent),
ui(new Ui::MdiChild),
modelsListModel(NULL),
firmware(getCurrentFirmware()),
@@ -599,14 +601,32 @@ void MdiChild::setCurrentFile(const QString &fileName)
void MdiChild::writeEeprom() // write to Tx
{
QString tempFile = generateProcessUniqueTempFileName("temp.bin");
saveFile(tempFile, false);
if (!QFileInfo(tempFile).exists()) {
QMessageBox::critical(this, tr("Error"), tr("Cannot write temporary file!"));
return;
BoardEnum board = getCurrentBoard();
if (board == BOARD_HORUS) {
QString radioPath = findMassstoragePath("RADIO", true);
qDebug() << "Searching for SD card, found" << radioPath;
if (radioPath.isEmpty()) {
qDebug() << "MdiChild::writeEeprom(): Horus radio not found";
QMessageBox::critical(this, tr("Error"), tr("Unable to find Horus radio SD card!"));
return;
}
if (saveFile(radioPath, false)) {
parent->statusBar()->showMessage(tr("Models and Settings written"), 2000);
}
else {
qDebug() << "MdiChild::writeEeprom(): saveFile error";
}
}
else {
QString tempFile = generateProcessUniqueTempFileName("temp.bin");
saveFile(tempFile, false);
if (!QFileInfo(tempFile).exists()) {
QMessageBox::critical(this, tr("Error"), tr("Cannot write temporary file!"));
return;
}
FlashEEpromDialog * cd = new FlashEEpromDialog(this, tempFile);
cd->exec();
}
FlashEEpromDialog * cd = new FlashEEpromDialog(this, tempFile);
cd->exec();
}
void MdiChild::on_radioSettings_clicked()