Commit 1b8cec27 authored by Lorenz Meier's avatar Lorenz Meier

Merge pull request #74 from Susurrus/issue_62

Canceling out of file selection in the logfile plotter no longer triggers a warning.
parents cba25557 15cbbe2c
...@@ -246,21 +246,27 @@ void QGCDataPlot2D::exportSVG(QString fileName) ...@@ -246,21 +246,27 @@ void QGCDataPlot2D::exportSVG(QString fileName)
*/ */
void QGCDataPlot2D::selectFile() void QGCDataPlot2D::selectFile()
{ {
// Let user select the log file name // Open a file dialog prompting the user for the file to load.
//QDate date(QDate::currentDate()); // Note the special case for the Pixhawk.
// QString("./pixhawk-log-" + date.toString("yyyy-MM-dd") + "-" + QString::number(logindex) + ".log")
if (ui->inputFileType->currentText().contains("pxIMU") || ui->inputFileType->currentText().contains("RAW")) { if (ui->inputFileType->currentText().contains("pxIMU") || ui->inputFileType->currentText().contains("RAW")) {
fileName = QFileDialog::getOpenFileName(this, tr("Specify log file name"), QString(), "Logfile (*.imu *.raw)"); fileName = QFileDialog::getOpenFileName(this, tr("Specify log file name"), QString(), "Logfile (*.imu *.raw)");
} else { }
else
{
fileName = QFileDialog::getOpenFileName(this, tr("Specify log file name"), QString(), "Logfile (*.csv *.txt *.log)"); fileName = QFileDialog::getOpenFileName(this, tr("Specify log file name"), QString(), "Logfile (*.csv *.txt *.log)");
} }
// Store reference to file // Check if the user hit cancel, which results in a Null string.
// If this is the case, we just stop.
if (fileName.isNull())
{
return;
}
// Now attempt to open the file
QFileInfo fileInfo(fileName); QFileInfo fileInfo(fileName);
if (!fileInfo.isReadable())
if (!fileInfo.isReadable()) { {
QMessageBox msgBox; QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Critical); msgBox.setIcon(QMessageBox::Critical);
msgBox.setText("Could not open file"); msgBox.setText("Could not open file");
...@@ -269,7 +275,9 @@ void QGCDataPlot2D::selectFile() ...@@ -269,7 +275,9 @@ void QGCDataPlot2D::selectFile()
msgBox.setDefaultButton(QMessageBox::Ok); msgBox.setDefaultButton(QMessageBox::Ok);
msgBox.exec(); msgBox.exec();
ui->filenameLabel->setText(tr("Could not open %1").arg(fileInfo.baseName()+"."+fileInfo.completeSuffix())); ui->filenameLabel->setText(tr("Could not open %1").arg(fileInfo.baseName()+"."+fileInfo.completeSuffix()));
} else { }
else
{
ui->filenameLabel->setText(tr("Opened %1").arg(fileInfo.completeBaseName()+"."+fileInfo.completeSuffix())); ui->filenameLabel->setText(tr("Opened %1").arg(fileInfo.completeBaseName()+"."+fileInfo.completeSuffix()));
// Open and import the file // Open and import the file
loadFile(); loadFile();
......
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