From c5eb806adb345e24b13ac4bf106cceb1dc9d3431 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Sat, 10 Apr 2021 17:40:30 -0700 Subject: cloudstorage: some cleanup of cloud url handling We know the preference is never empty, so stop testing for this. But don't maintain two different preferences with basically the same content. Instead add the '/git' suffix where needed and keep this all in one place. Simplify the extraction of the branch name from the cloud URL. Also a typo fix and a new comment. Signed-off-by: Dirk Hohndel --- desktop-widgets/mainwindow.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'desktop-widgets') diff --git a/desktop-widgets/mainwindow.cpp b/desktop-widgets/mainwindow.cpp index 197c54bdd..9a2b9665d 100644 --- a/desktop-widgets/mainwindow.cpp +++ b/desktop-widgets/mainwindow.cpp @@ -628,8 +628,8 @@ void MainWindow::closeCurrentFile() void MainWindow::updateCloudOnlineStatus() { - bool is_cloud = existing_filename && prefs.cloud_git_url && prefs.cloud_verification_status == qPrefCloudStorage::CS_VERIFIED && - strstr(existing_filename, prefs.cloud_git_url); + bool is_cloud = existing_filename && prefs.cloud_verification_status == qPrefCloudStorage::CS_VERIFIED && + strstr(existing_filename, prefs.cloud_base_url); ui.actionCloudOnline->setEnabled(is_cloud); ui.actionCloudOnline->setChecked(is_cloud && !git_local_only); } @@ -1174,7 +1174,7 @@ void MainWindow::loadRecentFiles() QString file = s.value(key).toString(); // never add our cloud URL to the recent files - if (!same_string(prefs.cloud_git_url, "") && file.startsWith(prefs.cloud_git_url)) + if (file.startsWith(prefs.cloud_base_url)) continue; // but allow local git repos QRegularExpression gitrepo("(.*)\\[[^]]+]"); @@ -1212,7 +1212,7 @@ 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)) + if (file.startsWith(prefs.cloud_base_url)) return; QString localFile = QDir::toNativeSeparators(file); int index = recentFiles.indexOf(localFile); @@ -1262,9 +1262,8 @@ int MainWindow::file_save_as(void) // 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)) { + if (default_filename && strstr(default_filename, prefs.cloud_base_url)) { QString filename(default_filename); - filename.remove(prefs.cloud_git_url); filename.remove(0, filename.indexOf("[") + 1); filename.replace("]", ".ssrf"); default_filename = copy_qstring(filename); @@ -1355,7 +1354,7 @@ QString MainWindow::displayedFilename(QString fullFilename) QFileInfo fileInfo(f); QString fileName(fileInfo.fileName()); - if (fullFilename.contains(prefs.cloud_git_url)) { + if (fullFilename.contains(prefs.cloud_base_url)) { QString email = fileName.left(fileName.indexOf('[')); return git_local_only ? tr("[local cache for] %1").arg(email) : -- cgit v1.2.3-70-g09d2