From a8c013869b0fd47c577dbaad95970db63fe604ad Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Wed, 27 May 2015 11:14:26 -0700 Subject: Strip the default suffix if saving to git branch For some reason the file selection dialog box now always adds a default suffix to the file name we pick - which results in our test for git storage to fail. So if the filename looks like "[branch].ssrf" then remove the suffix that was added. Signed-off-by: Dirk Hohndel --- qt-ui/mainwindow.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'qt-ui') diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp index 00a6be60f..e94bce136 100644 --- a/qt-ui/mainwindow.cpp +++ b/qt-ui/mainwindow.cpp @@ -1277,6 +1277,7 @@ int MainWindow::file_save_as(void) tr("Subsurface XML files (*.ssrf *.xml *.XML)")); selection_dialog.setAcceptMode(QFileDialog::AcceptSave); selection_dialog.setFileMode(QFileDialog::AnyFile); + selection_dialog.setDefaultSuffix(""); /* if the exit/cancel button is pressed return */ if (!selection_dialog.exec()) @@ -1284,6 +1285,13 @@ int MainWindow::file_save_as(void) /* get the first selected file */ filename = selection_dialog.selectedFiles().at(0); + + /* now for reasons I don't understand we appear to add a .ssrf to + * git style filenames /directory[branch] + * so let's remove that */ + QRegExp r("\\[.*\\]\\.ssrf$", Qt::CaseInsensitive); + if (filename.contains(r)) + filename.remove(QRegExp("\\.ssrf$", Qt::CaseInsensitive)); if (filename.isNull() || filename.isEmpty()) return report_error("No filename to save into"); -- cgit v1.2.3-70-g09d2