Skip to content

Commit

Permalink
Fix "Open in Finder" on mac (#12041)
Browse files Browse the repository at this point in the history
  • Loading branch information
erikjv authored Jan 27, 2025
1 parent 98c80be commit 2c796b4
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions src/gui/accountsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include "gui/spaces/spaceimageprovider.h"
#include "guiutility.h"
#include "libsync/graphapi/spacesmanager.h"
#include "openfilemanager.h"
#include "quotainfo.h"
#include "scheduling/syncscheduler.h"
#include "settingsdialog.h"
Expand Down Expand Up @@ -147,18 +148,15 @@ void AccountSettings::slotCustomContextMenuRequested(Folder *folder)
return;
}
// Add an action to open the folder in the system's file browser:
const QUrl folderUrl = QUrl::fromLocalFile(folder->path());
if (!folderUrl.isEmpty()) {
QAction *ac = menu->addAction(CommonStrings::showInFileBrowser(), [folderUrl]() {
qCInfo(lcAccountSettings) << "Opening local folder" << folderUrl;
if (!QDesktopServices::openUrl(folderUrl)) {
qCWarning(lcAccountSettings) << "QDesktopServices::openUrl failed for" << folderUrl;
}
});

if (!QFile::exists(folderUrl.toLocalFile())) {
ac->setEnabled(false);
QAction *showInFileManagerAction = menu->addAction(CommonStrings::showInFileBrowser(), [folder]() {
qCInfo(lcAccountSettings) << "Opening local folder" << folder->path();
if (QFileInfo::exists(folder->path())) {
showInFileManager(folder->path());
}
});

if (!QFile::exists(folder->path())) {
showInFileManagerAction->setEnabled(false);
}

// Add an action to open the folder on the server in a webbrowser:
Expand Down

0 comments on commit 2c796b4

Please sign in to comment.