From 799252e8f2a97474fa1b007fe2a505b7b03f14f9 Mon Sep 17 00:00:00 2001 From: Vesa Pikki Date: Fri, 12 Jun 2009 21:22:45 +0300 Subject: [PATCH] Force extension to the file and check save type by filter and not by filename. --- gui/mainwindow.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index 58a4300fd..7bfc77e3a 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -454,8 +454,22 @@ void MainWindow::Save() if (list.size() > 0) { - bool xml = (dialog.selectedNameFilter() == filters[0] && list[0].endsWith(".xml", Qt::CaseInsensitive)); - mResults.Save(list[0], xml); + QString filename = list[0]; + + //Check if xml file type was selected + bool xml = (dialog.selectedNameFilter() == filters[0]); + + //Force xml extension to the file + if (xml && !filename.endsWith(".xml", Qt::CaseInsensitive)) { + filename+=".xml"; + } + + //Force .txt extension + if (!xml && !filename.endsWith(".txt", Qt::CaseInsensitive)) { + filename+=".txt"; + } + + mResults.Save(filename, xml); } } }