Merge pull request #6752 from nextcloud/bugfix/locally-available-folders-open-in-browser-tray-header

Fix opening of locally available groupfolders in web browser from tray drop-down
This commit is contained in:
Matthieu Gallien 2024-10-18 10:59:32 +02:00 коммит произвёл GitHub
Родитель e60bbf97d8 985d2d9a7a
Коммит d228d85972
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
2 изменённых файлов: 14 добавлений и 9 удалений

Просмотреть файл

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

Просмотреть файл

@ -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;