summaryrefslogtreecommitdiffstats
path: root/qt-ui/mainwindow.cpp
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2015-09-20 08:39:15 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-09-20 10:15:34 -0700
commit06d6ca94f3b0a70242ea4b22fbb0668351896804 (patch)
tree609df5fe1ada42bcc4e635a3aacbdd0e9a51bff3 /qt-ui/mainwindow.cpp
parent899427079e16aebf5961cfe3bffda044f10207f1 (diff)
downloadsubsurface-06d6ca94f3b0a70242ea4b22fbb0668351896804.tar.gz
When calling save-as with cloud storage as default, pick sane filename
Passing the cloud URL to the file select box leaves "git syntax" in the filename which makes us look for a directory with a git repository in it and give non-sensical error messages to the user. With this we simply use the users email address as local filename with a .ssrf suffix. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/mainwindow.cpp')
-rw-r--r--qt-ui/mainwindow.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp
index 43bc4d3fb..1678cd6d4 100644
--- a/qt-ui/mainwindow.cpp
+++ b/qt-ui/mainwindow.cpp
@@ -1414,6 +1414,15 @@ int MainWindow::file_save_as(void)
QString filename;
const char *default_filename = existing_filename;
+ // if the default is to save to cloud storage, pick something that will work as local file:
+ // simply extract the branch name which should be the users email address
+ if (default_filename && strstr(default_filename, prefs.cloud_git_url)) {
+ QString filename(default_filename);
+ filename.remove(prefs.cloud_git_url);
+ filename.remove(0, filename.indexOf("[") + 1);
+ filename.replace("]", ".ssrf");
+ default_filename = strdup(qPrintable(filename));
+ }
// create a file dialog that allows us to save to a new file
QFileDialog selection_dialog(this, tr("Save file as"), default_filename,
tr("Subsurface XML files (*.ssrf *.xml *.XML)"));