diff --git a/src/gui/tray/usermodel.cpp b/src/gui/tray/usermodel.cpp index 9c9f3cf819e93..98393f4ca9406 100644 --- a/src/gui/tray/usermodel.cpp +++ b/src/gui/tray/usermodel.cpp @@ -339,15 +339,22 @@ void User::parseNewGroupFolderPath(const QString &mountPoint) if (mountPoint.isEmpty()) { return; } - auto mountPointSplit = mountPoint.split(QLatin1Char('/'), Qt::SkipEmptyParts); + + auto sanitisedMountPoint = mountPoint; + sanitisedMountPoint.replace("//", "/"); + auto mountPointSplit = sanitisedMountPoint.split('/', Qt::SkipEmptyParts); if (mountPointSplit.isEmpty()) { return; } const auto groupFolderName = mountPointSplit.takeLast(); - const auto parentPath = mountPointSplit.join(QLatin1Char('/')); - _trayFolderInfos.push_back(QVariant::fromValue(TrayFolderInfo{groupFolderName, parentPath, mountPoint, TrayFolderInfo::GroupFolder})); + const auto parentPath = mountPointSplit.join('/'); + const auto folderInfo = TrayFolderInfo( + groupFolderName, parentPath, sanitisedMountPoint, TrayFolderInfo::GroupFolder + ); + const auto folderInfoVariant = QVariant::fromValue(folderInfo); + _trayFolderInfos.push_back(folderInfoVariant); } void User::prePendGroupFoldersWithLocalFolder() @@ -906,7 +913,7 @@ void User::setCurrentUser(const bool &isCurrent) Folder *User::getFolder() const { - foreach (Folder *folder, FolderMan::instance()->map()) { + for (const auto &folder : FolderMan::instance()->map()) { if (folder->accountState() == _account.data()) { return folder; } @@ -925,11 +932,9 @@ UnifiedSearchResultsListModel *User::getUnifiedSearchResultsListModel() const return _unifiedSearchResultsModel; } -void User::openLocalFolder() +void User::openLocalFolder() const { - const auto folder = getFolder(); - - if (folder) { + if (const auto folder = getFolder()) { QDesktopServices::openUrl(QUrl::fromLocalFile(folder->path())); } } diff --git a/src/gui/tray/usermodel.h b/src/gui/tray/usermodel.h index 33c3ae455a5bb..466cd6ab81976 100644 --- a/src/gui/tray/usermodel.h +++ b/src/gui/tray/usermodel.h @@ -76,7 +76,7 @@ class User : public QObject [[nodiscard]] Folder *getFolder() const; ActivityListModel *getActivityModel(); [[nodiscard]] UnifiedSearchResultsListModel *getUnifiedSearchResultsListModel() const; - void openLocalFolder(); + void openLocalFolder() const; void openFolderLocallyOrInBrowser(const QString &fullRemotePath); [[nodiscard]] QString name() const; [[nodiscard]] QString server(bool shortened = true) const;