mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
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>
This commit is contained in:
parent
25db28b905
commit
5ffca686c2
1 changed files with 16 additions and 1 deletions
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue