|
|
|
@ -505,35 +505,32 @@ void QGCApplication::criticalMessageBoxOnMainThread(const QString& title, const
@@ -505,35 +505,32 @@ void QGCApplication::criticalMessageBoxOnMainThread(const QString& title, const
|
|
|
|
|
|
|
|
|
|
void QGCApplication::saveTelemetryLogOnMainThread(QString tempLogfile) |
|
|
|
|
{ |
|
|
|
|
// Are we supposed to log?
|
|
|
|
|
if(toolbox()->settingsManager()->appSettings()->telemetrySave()->rawValue().toBool()) { |
|
|
|
|
// The vehicle is gone now and we are shutting down so we need to use a message box for errors to hold shutdown and show the error
|
|
|
|
|
if (_checkTelemetrySavePath(true /* useMessageBox */)) { |
|
|
|
|
|
|
|
|
|
QString saveDirPath = _toolbox->settingsManager()->appSettings()->telemetrySavePath(); |
|
|
|
|
QDir saveDir(saveDirPath); |
|
|
|
|
|
|
|
|
|
QString nameFormat("%1%2.%3"); |
|
|
|
|
QString dtFormat("yyyy-MM-dd hh-mm-ss"); |
|
|
|
|
|
|
|
|
|
int tryIndex = 1; |
|
|
|
|
QString saveFileName = nameFormat.arg( |
|
|
|
|
QDateTime::currentDateTime().toString(dtFormat)).arg("").arg(toolbox()->settingsManager()->appSettings()->telemetryFileExtension); |
|
|
|
|
while (saveDir.exists(saveFileName)) { |
|
|
|
|
saveFileName = nameFormat.arg( |
|
|
|
|
QDateTime::currentDateTime().toString(dtFormat)).arg(QStringLiteral(".%1").arg(tryIndex++)).arg(toolbox()->settingsManager()->appSettings()->telemetryFileExtension); |
|
|
|
|
} |
|
|
|
|
QString saveFilePath = saveDir.absoluteFilePath(saveFileName); |
|
|
|
|
// The vehicle is gone now and we are shutting down so we need to use a message box for errors to hold shutdown and show the error
|
|
|
|
|
if (_checkTelemetrySavePath(true /* useMessageBox */)) { |
|
|
|
|
|
|
|
|
|
QString saveDirPath = _toolbox->settingsManager()->appSettings()->telemetrySavePath(); |
|
|
|
|
QDir saveDir(saveDirPath); |
|
|
|
|
|
|
|
|
|
QFile tempFile(tempLogfile); |
|
|
|
|
if (!tempFile.copy(saveFilePath)) { |
|
|
|
|
QString error = tr("Unable to save telemetry log. Error copying telemetry to '%1': '%2'.").arg(saveFilePath).arg(tempFile.errorString()); |
|
|
|
|
QString nameFormat("%1%2.%3"); |
|
|
|
|
QString dtFormat("yyyy-MM-dd hh-mm-ss"); |
|
|
|
|
|
|
|
|
|
int tryIndex = 1; |
|
|
|
|
QString saveFileName = nameFormat.arg( |
|
|
|
|
QDateTime::currentDateTime().toString(dtFormat)).arg("").arg(toolbox()->settingsManager()->appSettings()->telemetryFileExtension); |
|
|
|
|
while (saveDir.exists(saveFileName)) { |
|
|
|
|
saveFileName = nameFormat.arg( |
|
|
|
|
QDateTime::currentDateTime().toString(dtFormat)).arg(QStringLiteral(".%1").arg(tryIndex++)).arg(toolbox()->settingsManager()->appSettings()->telemetryFileExtension); |
|
|
|
|
} |
|
|
|
|
QString saveFilePath = saveDir.absoluteFilePath(saveFileName); |
|
|
|
|
|
|
|
|
|
QFile tempFile(tempLogfile); |
|
|
|
|
if (!tempFile.copy(saveFilePath)) { |
|
|
|
|
QString error = tr("Unable to save telemetry log. Error copying telemetry to '%1': '%2'.").arg(saveFilePath).arg(tempFile.errorString()); |
|
|
|
|
#ifndef __mobile__ |
|
|
|
|
QGCMessageBox::warning(tr("Telemetry Save Error"), error); |
|
|
|
|
QGCMessageBox::warning(tr("Telemetry Save Error"), error); |
|
|
|
|
#else |
|
|
|
|
showMessage(error); |
|
|
|
|
showMessage(error); |
|
|
|
|
#endif |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
QFile::remove(tempLogfile); |
|
|
|
|