Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix opening of locally available groupfolders in web browser from tray drop-down #6752

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions src/gui/tray/usermodel.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "notificationhandler.h"

Check notice on line 1 in src/gui/tray/usermodel.cpp

View workflow job for this annotation

GitHub Actions / build

Run clang-format on src/gui/tray/usermodel.cpp

File src/gui/tray/usermodel.cpp does not conform to Custom style guidelines. (lines 353, 354)
#include "usermodel.h"
#include "common/filesystembase.h"

Expand Down Expand Up @@ -339,15 +339,22 @@
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 @@

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 @@
return _unifiedSearchResultsModel;
}

void User::openLocalFolder()
void User::openLocalFolder() const

Check warning on line 935 in src/gui/tray/usermodel.cpp

View workflow job for this annotation

GitHub Actions / build

src/gui/tray/usermodel.cpp:935:12 [readability-convert-member-functions-to-static]

method 'openLocalFolder' can be made static
{
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
@@ -1,7 +1,7 @@
#ifndef USERMODEL_H
#define USERMODEL_H

#include <QAbstractListModel>

Check failure on line 4 in src/gui/tray/usermodel.h

View workflow job for this annotation

GitHub Actions / build

src/gui/tray/usermodel.h:4:10 [clang-diagnostic-error]

'QAbstractListModel' file not found
#include <QImage>
#include <QDateTime>
#include <QStringList>
Expand Down Expand Up @@ -76,7 +76,7 @@
[[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
Loading