diff --git a/src/ui/QGCDataPlot2D.cc b/src/ui/QGCDataPlot2D.cc index f443eef7dcb606c7b1fa170b1518d360579370b2..a676f11919dfb6f7667c23a0240b46e28131cbbf 100644 --- a/src/ui/QGCDataPlot2D.cc +++ b/src/ui/QGCDataPlot2D.cc @@ -157,6 +157,7 @@ void QGCDataPlot2D::savePlot() } else if (fileName.endsWith(".svg")) { exportSVG(fileName); } + // TODO Tell the user the name (type) was invalid (neither pdf nor svg) and nothing is being done. } @@ -272,7 +273,7 @@ void QGCDataPlot2D::selectFile() } else { - fileName = QGCFileDialog::getOpenFileName(this, tr("Load Log File"), QString(), "Log files (*.csv *.txt *.log)"); + fileName = QGCFileDialog::getOpenFileName(this, tr("Load Log File"), QString(), "Log files (*.csv);;All Files (*)"); } // Check if the user hit cancel, which results in an empty string. @@ -698,11 +699,13 @@ void QGCDataPlot2D::saveCsvLog() { QString fileName = QGCFileDialog::getSaveFileName( this, "Save CSV Log File", QStandardPaths::writableLocation(QStandardPaths::DesktopLocation), - "CSV file (*.csv);;Text file (*.txt)", - "csv"); + "CSV file (*.csv)", + "csv", + true); - if (fileName.isEmpty()) + if (fileName.isEmpty()) { return; //User cancelled + } bool success = logFile->copy(fileName); diff --git a/src/ui/linechart/LinechartWidget.cc b/src/ui/linechart/LinechartWidget.cc index 372e284b539d0611590115cdb07ad33c365f0ed7..d87d049a9559c3a8e2fbc926f1e2e734469cbc8c 100644 --- a/src/ui/linechart/LinechartWidget.cc +++ b/src/ui/linechart/LinechartWidget.cc @@ -431,49 +431,29 @@ void LinechartWidget::refresh() setUpdatesEnabled(true); } -QString LinechartWidget::getLogSaveFilename() -{ - QString fileName = QGCFileDialog::getSaveFileName(this, - tr("Save Log File"), - QStandardPaths::writableLocation(QStandardPaths::DesktopLocation), - tr("Log file (*.log)"), - "log", - true); - return fileName; -} - void LinechartWidget::startLogging() { - // Store reference to file - bool abort = false; - // Check if any curve is enabled if (!activePlot->anyCurveVisible()) { - QGCMessageBox::critical(tr("No curves selected for logging."), tr("Please check all curves you want to log. Currently no data would be logged, aborting the logging.")); + QGCMessageBox::critical( + tr("No curves selected for logging."), + tr("Please check all curves you want to log. Currently no data would be logged. Aborting the logging.")); return; } // Let user select the log file name // QDate date(QDate::currentDate()); // QString("./pixhawk-log-" + date.toString("yyyy-MM-dd") + "-" + QString::number(logindex) + ".log") - QString fileName = getLogSaveFilename(); - - while (!(fileName.endsWith(".log")) && !abort && fileName != "") { - QMessageBox::StandardButton button = QGCMessageBox::critical(tr("Unsuitable file extension for logfile"), - tr("Please choose .log as file extension. Click OK to change the file extension, cancel to not start logging."), - QMessageBox::Ok | QMessageBox::Cancel, - QMessageBox::Ok); - if (button != QMessageBox::Ok) { - abort = true; - break; - } - fileName = getLogSaveFilename(); - } + QString fileName = QGCFileDialog::getSaveFileName(this, + tr("Save Log File"), + QStandardPaths::writableLocation(QStandardPaths::DesktopLocation), + tr("Log file (*.log)"), + "log", // Default type + true); // Enforce default type qDebug() << "SAVE FILE " << fileName; - // Check if the user did not abort the file save dialog - if (!abort && fileName != "") { + if (!fileName.isEmpty()) { logFile = new QFile(fileName); if (logFile->open(QIODevice::Truncate | QIODevice::WriteOnly | QIODevice::Text)) { logging = true; @@ -498,10 +478,11 @@ void LinechartWidget::stopLogging() compressor = new LogCompressor(logFile->fileName(), logFile->fileName()); connect(compressor, SIGNAL(finishedFile(QString)), this, SIGNAL(logfileWritten(QString))); - QMessageBox::StandardButton button = QGCMessageBox::question(tr("Starting Log Compression"), - tr("Should empty fields (e.g. due to packet drops) be filled with the previous value of the same variable (zero order hold)?"), - QMessageBox::Yes | QMessageBox::No, - QMessageBox::No); + QMessageBox::StandardButton button = QGCMessageBox::question( + tr("Starting Log Compression"), + tr("Should empty fields (e.g. due to packet drops) be filled with the previous value of the same variable (zero order hold)?"), + QMessageBox::Yes | QMessageBox::No, + QMessageBox::No); bool fill; if (button == QMessageBox::Yes) { diff --git a/src/ui/linechart/LinechartWidget.h b/src/ui/linechart/LinechartWidget.h index 081b31fe75478719d931de01580ecf91cd83ffba..4c9fb20b625418425ca2c58359a75d868fddf20c 100644 --- a/src/ui/linechart/LinechartWidget.h +++ b/src/ui/linechart/LinechartWidget.h @@ -123,7 +123,6 @@ protected: QToolButton* createButton(QWidget* parent); void createCurveItem(QString curve); void createLayout(); - QString getLogSaveFilename(); /** @brief Get the name for a curve key */ QString getCurveName(const QString& key, bool shortEnabled);