Skip to content

Commit

Permalink
Merge pull request #6752 from nextcloud/bugfix/locally-available-fold…
Browse files Browse the repository at this point in the history
…ers-open-in-browser-tray-header

Fix opening of locally available groupfolders in web browser from tray drop-down
  • Loading branch information
mgallien authored Oct 18, 2024
2 parents e60bbf9 + 985d2d9 commit d228d85
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
21 changes: 13 additions & 8 deletions src/gui/tray/usermodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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;
}
Expand All @@ -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()));
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/gui/tray/usermodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit d228d85

Please sign in to comment.