summaryrefslogtreecommitdiffstats
path: root/desktop-widgets/mainwindow.cpp
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2019-08-12 10:00:48 -0700
committerGravatar Lubomir I. Ivanov <neolit123@gmail.com>2019-08-18 23:37:17 +0300
commit5ffca686c21bbe4cf6e2cf370e1bf2c7c50de1ef (patch)
treef19f8b03e1e71f7d6dea1cab42c2a63e5bdd6238 /desktop-widgets/mainwindow.cpp
parent25db28b905c96378d6e046eea6e57079b3d401d8 (diff)
downloadsubsurface-5ffca686c21bbe4cf6e2cf370e1bf2c7c50de1ef.tar.gz
Desktop: show local git repos in recent files
But don't show our cloud storage entry (as that is already in the File menu, anyway). This is extremely useful because while you can manually enter a file name to save to (and therefore can use the 'magic' git repo syntax), on most OSs there is no way to enter that non-existing 'file name' (which is the git branch in square brackets) in the file open dialog. Fixes: #2236 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'desktop-widgets/mainwindow.cpp')
-rw-r--r--desktop-widgets/mainwindow.cpp17
1 files changed, 16 insertions, 1 deletions
diff --git a/desktop-widgets/mainwindow.cpp b/desktop-widgets/mainwindow.cpp
index d25ffe3af..b19062612 100644
--- a/desktop-widgets/mainwindow.cpp
+++ b/desktop-widgets/mainwindow.cpp
@@ -1457,8 +1457,20 @@ void MainWindow::loadRecentFiles()
if (!key.startsWith("File_"))
continue;
QString file = s.value(key).toString();
- if (QFile::exists(file))
+
+ // never add our cloud URL to the recent files
+ if (!same_string(prefs.cloud_git_url, "") && file.startsWith(prefs.cloud_git_url))
+ continue;
+ // but allow local git repos
+ QRegularExpression gitrepo("(.*)\\[[^]]+]");
+ QRegularExpressionMatch match = gitrepo.match(file);
+ if (match.hasMatch()) {
+ const QFileInfo gitDirectory(match.captured(1) + "/.git");
+ if ((gitDirectory.exists()) && (gitDirectory.isDir()))
+ recentFiles.append(file);
+ } else if (QFile::exists(file)) {
recentFiles.append(file);
+ }
if (recentFiles.count() > NUM_RECENT_FILES)
break;
}
@@ -1484,6 +1496,9 @@ void MainWindow::updateRecentFilesMenu()
void MainWindow::addRecentFile(const QString &file, bool update)
{
+ // never add Subsurface cloud file to the recent files - it has its own menu entry
+ if (!same_string(prefs.cloud_git_url, "") && file.startsWith(prefs.cloud_git_url))
+ return;
QString localFile = QDir::toNativeSeparators(file);
int index = recentFiles.indexOf(localFile);
if (index >= 0)