Skip to content

Commit

Permalink
Basic support for .plugdata plugin installers
Browse files Browse the repository at this point in the history
  • Loading branch information
timothyschoen committed Nov 26, 2024
1 parent c71d693 commit f7c1a8b
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 6 deletions.
22 changes: 21 additions & 1 deletion Source/Components/WelcomePanel.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@

class WelcomePanel : public Component
, public NVGComponent
, public AsyncUpdater {
, public AsyncUpdater
{


class ContentComponent : public Component
Expand Down Expand Up @@ -797,5 +798,24 @@ class WelcomePanel : public Component

String searchQuery;
Tab currentTab = Home;

// To make the library panel update automatically
class LibraryFSListener : public FileSystemWatcher::Listener
{
FileSystemWatcher libraryFsWatcher;
WelcomePanel& panel;

public:
LibraryFSListener(WelcomePanel& panel) : panel(panel) {
libraryFsWatcher.addFolder(ProjectInfo::appDataDir.getChildFile("Patches"));
libraryFsWatcher.addListener(this);
};

void filesystemChanged() override
{
panel.triggerAsyncUpdate();
}
};

LibraryFSListener libraryFsListener = LibraryFSListener(*this);
};
28 changes: 23 additions & 5 deletions Source/Standalone/PlugDataApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,30 @@ class PlugDataApp : public JUCEApplication {
auto tokens = StringArray::fromTokens(commandLine, " ", "\"");
auto file = File(tokens[0].unquoted());
if (file.existsAsFile()) {
auto* pd = dynamic_cast<PluginProcessor*>(pluginHolder->processor.get());
auto* editor = dynamic_cast<PluginEditor*>(mainWindow->mainComponent->getEditor());
if (pd && editor && file.existsAsFile()) {
if(file.hasFileExtension("pd")) {
auto* pd = dynamic_cast<PluginProcessor*>(pluginHolder->processor.get());
auto* editor = dynamic_cast<PluginEditor*>(mainWindow->mainComponent->getEditor());
editor->getTabComponent().openPatch(URL(file));
SettingsFile::getInstance()->addToRecentlyOpened(file);
if (pd && editor && file.existsAsFile()) {
auto* editor = dynamic_cast<PluginEditor*>(mainWindow->mainComponent->getEditor());
editor->getTabComponent().openPatch(URL(file));
SettingsFile::getInstance()->addToRecentlyOpened(file);
}
}
else if(file.hasFileExtension("plugdata")) {
auto zip = ZipFile(file);
auto result = zip.uncompressTo(ProjectInfo::appDataDir.getChildFile("Patches"), false);
if(result.wasOk())
{
auto macOSTrash = ProjectInfo::appDataDir.getChildFile("Patches").getChildFile("__MACOSX");
if(macOSTrash.isDirectory())
{
macOSTrash.deleteRecursively();
}
// TODO: show success dialog
}
else {
// TODO: show error dialog
}
}
}
}
Expand Down

0 comments on commit f7c1a8b

Please sign in to comment.