Skip to content

Commit

Permalink
Edited file i/o as per elecpower suggestion
Browse files Browse the repository at this point in the history
Signed-off-by: dale wheeler <dale@wheeler.net>
  • Loading branch information
dwheeld authored and raphaelcoeffic committed Jun 12, 2022
1 parent 1be68e3 commit eb72b43
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions companion/src/simulation/telemetrysimu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1094,13 +1094,17 @@ void TelemetrySimulator::LogPlaybackController::setUiDataValues()

void TelemetrySimulator::on_saveTelemetryvalues_clicked()
{
QString idFileNameAndPath = QFileDialog::getSaveFileName(NULL, tr(".txt File"), g.eepromDir(), tr(".txt Files (*.txt)"));
QString fldr = g.backupDir().trimmed();
if (fldr.isEmpty())
fldr = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation);

QString idFileNameAndPath = QFileDialog::getSaveFileName(this, tr("Save Telemetry"), fldr % "/telemetry.txt", tr(".txt Files (*.txt)"));
if (idFileNameAndPath.isEmpty())
return;

QFile file(idFileNameAndPath);
if (!file.open(QIODevice::WriteOnly)){
QMessageBox::information(0,"info",file.errorString());
QMessageBox::critical(this, CPN_STR_APP_NAME, tr("Unable to open file for writing.\n%1").arg(file.errorString()));
return;
}
QTextStream out(&file);
Expand Down Expand Up @@ -1176,14 +1180,18 @@ void TelemetrySimulator::on_saveTelemetryvalues_clicked()

void TelemetrySimulator::on_loadTelemetryvalues_clicked()
{
QString idFileNameAndPath = QFileDialog::getOpenFileName(NULL, tr(".txt File"), g.eepromDir(), tr(".txt Files (*.txt)"));
QString fldr = g.backupDir().trimmed();
if (fldr.isEmpty())
fldr = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation);

QString idFileNameAndPath = QFileDialog::getOpenFileName(this, tr("Open Telemetry File"), fldr % "/telemetry.txt", tr(".txt Files (*.txt)"));
if (idFileNameAndPath.isEmpty())
return;

QFile file(idFileNameAndPath);

if (!file.open(QIODevice::ReadOnly)){
QMessageBox::information(0,"info",file.errorString());
QMessageBox::critical(this, CPN_STR_APP_NAME, tr("Unable to open file for reading.\n%1").arg(file.errorString()));
return;
}

Expand Down

0 comments on commit eb72b43

Please sign in to comment.