From 3c79789056c42080dc645e906c1e3c906df8cfe9 Mon Sep 17 00:00:00 2001 From: Viktor Kopp Date: Sun, 13 Oct 2024 22:18:34 +0200 Subject: [PATCH] Add dlf file extension when saving filter Signed-off-by: Viktor Kopp --- src/mainwindow.cpp | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 83702fcf..4146d7f4 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -6795,16 +6795,24 @@ void MainWindow::filterAdd() void MainWindow::on_action_menuFilter_Save_As_triggered() { - QString fileName = QFileDialog::getSaveFileName(this, tr("Save DLT Filters"), workingDirectory.getDlfDirectory(), tr("DLT Filter File (*.dlf);;All files (*.*)")); - if(!fileName.isEmpty()) - { - workingDirectory.setDlfDirectory(QFileInfo(fileName).absolutePath()); - if(!project.SaveFilter(fileName)) - QMessageBox::critical(0, QString("DLT Viewer"),QString("Save DLT Filter file failed!")); + if(fileName.isEmpty()) + return; + + const QFileInfo fileInfo(fileName); + + workingDirectory.setDlfDirectory(fileInfo.absolutePath()); + + if (const auto extension = fileInfo.suffix(); extension.isEmpty()) { + fileName.append(".dlf"); + } + + if(project.SaveFilter(fileName)) { setCurrentFilters(fileName); + } else { + QMessageBox::critical(0, "DLT Viewer", "Save DLT Filter file failed!"); } }