diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2021-04-10 17:40:30 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2021-04-19 12:51:01 -0700 |
commit | c5eb806adb345e24b13ac4bf106cceb1dc9d3431 (patch) | |
tree | a071c9dede0640e23dd8032e6b1d0863d85b983e /desktop-widgets/mainwindow.cpp | |
parent | da6395a4a8b68978caf47f98b48a82fabbe1dd20 (diff) | |
download | subsurface-c5eb806adb345e24b13ac4bf106cceb1dc9d3431.tar.gz |
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 <dirk@hohndel.org>
Diffstat (limited to 'desktop-widgets/mainwindow.cpp')
-rw-r--r-- | desktop-widgets/mainwindow.cpp | 13 |
1 files changed, 6 insertions, 7 deletions
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) : |