From f5de319f400d998062f708bfadf53de83cff61bd Mon Sep 17 00:00:00 2001 From: Max Paperno Date: Mon, 1 Jan 2018 22:50:52 -0500 Subject: [PATCH] [Companion] Remember last used log folder in Telemetry Simulator (fixes #5583). --- companion/src/simulation/telemetrysimu.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/companion/src/simulation/telemetrysimu.cpp b/companion/src/simulation/telemetrysimu.cpp index d48772b6f..cfb2fd9ac 100644 --- a/companion/src/simulation/telemetrysimu.cpp +++ b/companion/src/simulation/telemetrysimu.cpp @@ -18,12 +18,14 @@ * GNU General Public License for more details. */ -#include #include "telemetrysimu.h" #include "ui_telemetrysimu.h" +#include "appdata.h" #include "simulatorinterface.h" #include "radio/src/telemetry/frsky.h" + #include +#include TelemetrySimulator::TelemetrySimulator(QWidget * parent, SimulatorInterface * simulator): QWidget(parent), @@ -744,6 +746,12 @@ bool TelemetrySimulator::LogPlaybackController::isReady() void TelemetrySimulator::LogPlaybackController::loadLogFile() { + QString logFileNameAndPath = QFileDialog::getOpenFileName(NULL, tr("Log File"), g.logDir(), tr("LOG Files (*.csv)")); + if (logFileNameAndPath.isEmpty()) + return; + + g.logDir(logFileNameAndPath); + // reset the playback ui ui->play->setEnabled(false); ui->rewind->setEnabled(false); @@ -757,8 +765,6 @@ void TelemetrySimulator::LogPlaybackController::loadLogFile() // clear existing data csvRecords.clear(); - QString logFileNameAndPath = QFileDialog::getOpenFileName(NULL, tr("Log File"), ".", tr("LOG Files (*.csv)")); - QFileInfo fileInfo(logFileNameAndPath); QFile file(logFileNameAndPath); if (!file.open(QIODevice::ReadOnly)) { ui->logFileLabel->setText(tr("ERROR - invalid file")); @@ -768,6 +774,7 @@ void TelemetrySimulator::LogPlaybackController::loadLogFile() QByteArray line = file.readLine(); csvRecords.append(line.simplified()); } + file.close(); if (csvRecords.count() > 1) { columnNames.clear(); QStringList keys = csvRecords[0].split(',');