Merge pull request #7363 from nextcloud/backport/6752/stable-3.14

[stable-3.14] Fix opening of locally available groupfolders in web browser from tray drop-down
This commit is contained in:
Matthieu Gallien 2024-10-18 11:04:39 +02:00 committed by GitHub
commit 6f88a8aaec
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 14 additions and 9 deletions

View file

@ -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()));
}
}

View file

@ -76,7 +76,7 @@ public:
[[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;