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

Reveal in Finder for Patches #6499

Merged
merged 1 commit into from
Aug 9, 2022
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
25 changes: 25 additions & 0 deletions src/surge-xt/gui/SurgeJUCEHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#include "juce_gui_basics/juce_gui_basics.h"
#include "SurgeGUICallbackInterfaces.h"
#include <filesystem/import.h>

namespace Surge
{
Expand Down Expand Up @@ -121,6 +122,30 @@ inline void addMenuWithShortcut(juce::PopupMenu &m, const std::string &lab,
addMenuWithShortcut(m, lab, shortcut, true, false, action);
}

inline void addRevealInFinder(juce::PopupMenu &m, const fs::path &p)
{
#if LINUX
return;
#else
try
{
if (fs::exists(p) && fs::is_regular_file(p))
{
auto f = juce::File(p.u8string());
#if MAC
std::string s = "Reveal in Finder...";
#else
std::string s = "Open In Explorer...";
#endif
m.addItem(s, [f]() { f.revealToUser(); });
}
}
catch (fs::filesystem_error &)
{
}
#endif
}

} // namespace GUI
} // namespace Surge

Expand Down
5 changes: 5 additions & 0 deletions src/surge-xt/gui/widgets/PatchSelector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,11 @@ void PatchSelector::showClassicMenu(bool single_category)

contextMenu.addSeparator();

if (current_patch >= 0 && current_patch < storage->patch_list.size())
{
Surge::GUI::addRevealInFinder(contextMenu, storage->patch_list[current_patch].path);
}

contextMenu.addItem(Surge::GUI::toOSCase("Open User Patches Folder..."),
[this]() { Surge::GUI::openFileOrFolder(this->storage->userPatchesPath); });

Expand Down