67 text =
TRANS (
"Deactivated after failing to initialise correctly");
75 case nameCol: text = desc.name;
break;
76 case typeCol: text = desc.pluginFormatName;
break;
77 case categoryCol: text = desc.category.
isNotEmpty() ? desc.category :
"-";
break;
78 case manufacturerCol: text = desc.manufacturerName;
break;
79 case descCol: text = getPluginDescription (desc);
break;
113 case nameCol: list.
sort (KnownPluginList::sortAlphabetically,
isForwards);
break;
114 case typeCol: list.
sort (KnownPluginList::sortByFormat,
isForwards);
break;
115 case categoryCol: list.
sort (KnownPluginList::sortByCategory,
isForwards);
break;
116 case manufacturerCol: list.
sort (KnownPluginList::sortByManufacturer,
isForwards);
break;
150 formatToScan (format),
152 propertiesToUse (properties),
155 numThreads (threads),
164 jassert (! allowAsync || (numThreads > 0));
171 if (propertiesToUse !=
nullptr)
184 &pathChooserWindow,
this),
197 pool->removeAllJobs (
true, 60000);
210 String pluginBeingScanned;
212 const int numThreads;
213 bool allowAsync, timerReentrancyCheck =
false;
221 if (
alert !=
nullptr && scanner !=
nullptr)
224 scanner->warnUserAboutStupidPaths();
226 scanner->finishedScan();
231 void warnUserAboutStupidPaths()
233 for (
int i = 0; i < pathList.
getPath().getNumPaths(); ++i)
240 TRANS (
"Plugin Scanning"),
241 TRANS (
"If you choose to scan folders that contain non-plugin files, "
242 "then scanning may take a long time, and can cause crashes when "
243 "attempting to load unsuitable files.")
245 +
TRANS (
"Are you sure you want to scan the folder \"XYZ\"?")
263 static bool isStupidPath (
const File& f)
268 if (
roots.contains (f))
297 true, owner.deadMansPedalFile, allowAsync));
299 if (! filesOrIdentifiersToScan.
isEmpty())
301 scanner->setFilesOrIdentifiersToScan (filesOrIdentifiersToScan);
303 else if (propertiesToUse !=
nullptr)
317 for (
int i = numThreads; --i >= 0;)
318 pool->addJob (
new ScanJob (*
this),
true);
331 initiallyBlacklistedFiles.
begin(), initiallyBlacklistedFiles.
end(),
334 owner.scanFinished (scanner !=
nullptr ? scanner->getFailedFiles() :
StringArray(),
338 void timerCallback()
override
340 if (timerReentrancyCheck)
343 progress = scanner->getProgress();
359 progressWindow.
setMessage (
TRANS (
"Testing") +
":\n\n" + pluginBeingScanned);
364 if (scanner->scanNextFile (
true, pluginBeingScanned))
377 while (scanner.doNextScan() && !
shouldExit())
398 currentScanner.reset (
new Scanner (*
this, format, filesOrIdentifiersToScan, propertiesToUse, allowAsync, numThreads,
399 dialogTitle.
isNotEmpty() ? dialogTitle :
TRANS (
"Scanning for plug-ins..."),
400 dialogText.
isNotEmpty() ? dialogText :
TRANS (
"Searching for all possible plug-in files...")));
405 return currentScanner !=
nullptr;
408void PluginListComponent::scanFinished (
const StringArray& failedFiles,
415 if (range.size() == 0)
420 for (
auto& f : range)
421 names.add (
File::createFileWithoutCheckingPath (f).getFileName());
427 addWarningText (failedFiles,
TRANS (
"The following files appeared to be plugin files, but failed to load correctly"));
429 currentScanner.reset();
434 TRANS (
"Scan complete"),
444 : formatManager (manager),
447 optionsButton (
"Options..."),
448 propertiesToUse (props),
450 numThreads (allowAsync ? 1 : 0)
458 header.
addColumn (
TRANS (
"Category"), TableModel::categoryCol, 100, 100, 200);
459 header.
addColumn (
TRANS (
"Manufacturer"), TableModel::manufacturerCol, 200, 100, 300);
472 .withDeletionCheck (*
this)
473 .withTargetComponent (optionsButton));
501 dialogText = content;
515 optionsButton.
setBounds (r.removeFromBottom (24));
517 r.removeFromBottom (3);
529void PluginListComponent::updateList()
540 if (selected.contains (i))
541 removePluginItem (i);
547 tableModel.reset (model);
560static void showFolderForPlugin (KnownPluginList& list,
int index)
562 if (canShowFolderForPlugin (list, index))
563 File (list.getTypes()[index].fileOrIdentifier).revealToUser();
566void PluginListComponent::removeMissingPlugins()
568 auto types = list.getTypes();
570 for (
int i = types.size(); --i >= 0;)
572 auto type = types.getUnchecked (i);
575 list.removeType (type);
579void PluginListComponent::removePluginItem (
int index)
581 if (index < list.getNumTypes())
582 list.removeType (list.getTypes()[index]);
584 list.removeFromBlacklist (list.getBlacklistedFiles() [index - list.getNumTypes()]);
591 .setAction ([
this] { list.clear(); }));
595 for (
auto format : formatManager.
getFormats())
596 if (format->canScanForPlugins())
598 .
setEnabled (! list.getTypesForFormat (*format).isEmpty())
601 for (
auto&
pd : list.getTypesForFormat (*format))
602 list.removeType (
pd);
612 .setAction ([
this] { removeMissingPlugins(); }));
624 for (
auto format : formatManager.
getFormats())
625 if (format->canScanForPlugins())
626 menu.addItem (
PopupMenu::Item (
"Scan for new or updated " + format->getName() +
" plug-ins")
649bool PluginListComponent::isInterestedInFileDrag (
const StringArray& )
654void PluginListComponent::filesDropped (
const StringArray& files,
int,
int)
657 list.scanAndAddDragAndDroppedFiles (formatManager, files,
typesFound);
662 auto key =
"lastPluginScanPath_" + format.getName();
673 auto key =
"lastPluginScanPath_" + format.getName();
675 if (
newPath.getNumPaths() == 0)
T back_inserter(T... args)
A window that displays a message and has buttons for the user to react to it.
void addButton(const String &name, int returnValue, const KeyPress &shortcutKey1=KeyPress(), const KeyPress &shortcutKey2=KeyPress())
Adds a button to the window.
void setMessage(const String &message)
Changes the dialog box's message.
static ScopedMessageBox showScopedAsync(const MessageBoxOptions &options, std::function< void(int)> callback)
Shows an alert window using the specified options.
void addProgressBarComponent(double &progressValue, std::optional< ProgressBar::Style > style=std::nullopt)
Adds a progress-bar to the window.
void addCustomComponent(Component *component)
Adds a user-defined component to the dialog box.
Holds a resizable array of primitive or copy-by-value objects.
Holds a list of ChangeListeners, and sends messages to them when instructed.
void addChangeListener(ChangeListener *listener)
Registers a listener to receive change callbacks from this broadcaster.
void removeChangeListener(ChangeListener *listener)
Unregisters a listener from the list.
bool isVisible() const noexcept
Tests whether the component is visible or not.
void addAndMakeVisible(Component *child, int zOrder=-1)
Adds a child component to this one, and also makes the child visible if it isn't already.
void setEnabled(bool shouldBeEnabled)
Enables or disables this component.
void repaint()
Marks the whole component as needing to be redrawn.
void setBounds(int x, int y, int width, int height)
Changes the component's position and size.
void setSize(int newWidth, int newHeight)
Changes the size of the component.
void enterModalState(bool takeKeyboardFocus=true, ModalComponentManager::Callback *callback=nullptr, bool deleteWhenDismissed=false)
Puts the component into a modal state.
Colour findColour(int colourID, bool inheritFromParent=false) const
Looks for a colour that has been registered with the given colour ID number.
Rectangle< int > getLocalBounds() const noexcept
Returns the component's bounds, relative to its own origin.
bool isCurrentlyModal(bool onlyConsiderForemostModalComponent=true) const noexcept
Returns true if this component is the modal one.
virtual void setVisible(bool shouldBeVisible)
Makes the component visible or invisible.
Shows a set of file paths in a list, allowing them to be added, removed or re-ordered.
const FileSearchPath & getPath() const noexcept
Returns the path as it is currently shown.
void setPath(const FileSearchPath &newPath)
Changes the current path.
Represents a set of folders that make up a search path.
int getNumPaths() const
Returns the number of folders in this search path.
String getRawString(int index) const
Returns the unaltered text of the folder at the specified index.
Represents a local file or directory.
static bool isAbsolutePath(StringRef path)
Returns true if the string seems to be a fully-specified absolute path.
SpecialLocationType
A set of types of location that can be passed to the getSpecialLocation() method.
@ userMoviesDirectory
The most likely place where a user might store their movie files.
@ userMusicDirectory
The most likely place where a user might store their music files.
@ tempDirectory
The folder that should be used for temporary files.
@ globalApplicationsDirectory
The directory in which applications normally get installed.
@ userDocumentsDirectory
The user's default documents folder.
@ userPicturesDirectory
The most likely place where a user might store their picture files.
@ userDesktopDirectory
The folder that contains the user's desktop objects.
@ userHomeDirectory
The user's home folder.
static void findFileSystemRoots(Array< File > &results)
Creates a set of files to represent each file root.
static File JUCE_CALLTYPE getSpecialLocation(const SpecialLocationType type)
Finds the location of a special type of file or directory, such as a home folder or documents folder.
bool deleteFile() const
Deletes a file.
bool isAChildOf(const File &potentialParentDirectory) const
Checks whether a file is somewhere inside a directory.
static File createFileWithoutCheckingPath(const String &absolutePath) noexcept
Creates a file that simply contains this string, without doing the sanity-checking that the normal co...
bool exists() const
Checks whether the file actually exists.
Represents a particular font, including its size, style, etc.
A graphics context, used for drawing a component or image.
void drawFittedText(const String &text, int x, int y, int width, int height, Justification justificationFlags, int maximumNumberOfLines, float minimumHorizontalScale=0.0f) const
Tries to draw a text string inside a given space.
void setFont(const Font &newFont)
Changes the font to use for subsequent text-drawing functions.
void setColour(Colour newColour)
Changes the current drawing colour.
void fillAll() const
Fills the context's entire clip region with the current colour or brush.
@ centredLeft
Indicates that the item should be centred vertically but placed on the left hand side.
Represents a key press, including any modifier keys that are needed.
static const int escapeKey
key-code for the escape key
static const int returnKey
key-code for the return key
Manages a list of plugin types.
void sort(SortMethod method, bool forwards)
Sorts the list.
int getNumTypes() const noexcept
Returns the number of types currently in the list.
const StringArray & getBlacklistedFiles() const
Returns the list of blacklisted files.
Array< PluginDescription > getTypes() const
Returns a copy of the current list.
void setMultipleSelectionEnabled(bool shouldBeEnabled) noexcept
Turns on multiple-selection of rows.
void setRowHeight(int newHeight)
Sets the height of each row in the list.
int getSelectedRow(int index=0) const
Returns the row number of a selected row.
@ textColourId
The preferred colour to use for drawing text in the listbox.
@ backgroundColourId
The background colour to fill the list with.
void updateContent()
Causes the list to refresh its content.
int getNumSelectedRows() const
Returns the number of rows that are currently selected.
SparseSet< int > getSelectedRows() const
Returns a sparse set indicating the rows that are currently selected.
static MessageBoxOptions makeOptionsOkCancel(MessageBoxIconType iconType, const String &title, const String &message, const String &button1Text=String(), const String &button2Text=String(), Component *associatedComponent=nullptr)
Creates options suitable for a message box with two buttons.
static MessageBoxOptions makeOptionsOk(MessageBoxIconType iconType, const String &title, const String &message, const String &buttonText=String(), Component *associatedComponent=nullptr)
Creates options suitable for a message box with a single button.
static ModalComponentManager::Callback * forComponent(void(*functionToCall)(int, ComponentType *), ComponentType *component)
This is a utility function to create a ModalComponentManager::Callback that will call a static functi...
bool isPopupMenu() const noexcept
Checks whether the user is trying to launch a pop-up menu.
Contains position and status information about a mouse event.
const ModifierKeys mods
The key modifiers associated with the event.
A small class to represent some facts about a particular type of plug-in.
String version
The version.
String name
The name of the plug-in.
String descriptiveName
A more descriptive name for the plug-in.
Scans a directory for plugins, and adds them to a KnownPluginList.
static void applyBlacklistingsFromDeadMansPedal(KnownPluginList &listToApplyTo, const File &deadMansPedalFile)
Reads the given dead-mans-pedal file and applies its contents to the list.
int getNumRows() override
This must return the number of rows currently in the table.
void cellClicked(int rowNumber, int columnId, const juce::MouseEvent &e) override
This callback is made when the user clicks on one of the cells in the table.
void deleteKeyPressed(int) override
Override this to be informed when the delete key is pressed.
void sortOrderChanged(int newSortColumnId, bool isForwards) override
This callback is made when the table's sort order is changed.
void paintCell(Graphics &g, int row, int columnId, int width, int height, bool) override
This must draw one of the cells.
void paintRowBackground(Graphics &g, int, int, int, bool rowIsSelected) override
This must draw the background behind one of the rows in the table.
A component displaying a list of plugins, with options to scan for them, add, remove and sort them.
static FileSearchPath getLastSearchPath(PropertiesFile &, AudioPluginFormat &)
Returns the last search path stored in a given properties file for the specified format.
void setTableModel(TableListBoxModel *)
Sets a custom table model to be used.
~PluginListComponent() override
Destructor.
bool isScanning() const noexcept
Returns true if there's currently a scan in progress.
PopupMenu createOptionsMenu()
Returns a pop-up menu that contains all the options for scanning and updating the list.
void resized() override
Called when this component's size has been changed.
void removeSelectedPlugins()
Removes the plugins currently selected in the table.
PopupMenu createMenuForRow(int rowNumber)
Returns a menu that can be shown if a row is right-clicked, containing actions like "remove plugin" o...
void setNumberOfThreadsForScanning(int numThreads)
Sets how many threads to simultaneously scan for plugins.
static void setLastSearchPath(PropertiesFile &, AudioPluginFormat &, const FileSearchPath &)
Stores a search path in a properties file for the given format.
void setOptionsButtonText(const String &newText)
Changes the text in the panel's options button.
PluginListComponent(AudioPluginFormatManager &formatManager, KnownPluginList &listToRepresent, const File &deadMansPedalFile, PropertiesFile *propertiesToUse, bool allowPluginsWhichRequireAsynchronousInstantiation=false)
Creates the list component.
void scanFor(AudioPluginFormat &)
Triggers an asynchronous scan for the given format.
void setScanDialogText(const String &textForProgressWindowTitle, const String &textForProgressWindowDescription)
Changes the text in the progress dialog box that is shown when scanning.
Wrapper on a file that stores a list of key/value data pairs.
bool saveIfNeeded()
This will flush all the values to disk if they've changed since the last time they were saved.
String getValue(StringRef keyName, const String &defaultReturnValue=String()) const noexcept
Returns one of the properties as a string.
void setValue(StringRef keyName, const var &value)
Sets a named property.
bool containsKey(StringRef keyName) const noexcept
Returns true if the properties include the given key.
void removeValue(StringRef keyName)
Deletes a property.
Rectangle reduced(ValueType deltaX, ValueType deltaY) const noexcept
Returns a rectangle that is smaller than this one by a given amount.
Objects of this type can be used to programmatically close message boxes.
Helper class providing an RAII-based mechanism for temporarily setting and then re-setting a value.
A special array for holding a list of strings.
String joinIntoString(StringRef separatorString, int startIndex=0, int numberOfElements=-1) const
Joins the strings in the array together into one string.
void removeEmptyStrings(bool removeWhitespaceStrings=true)
Removes empty strings from the array.
int size() const noexcept
Returns the number of strings in the array.
void add(String stringToAdd)
Appends a string at the end of the array.
bool isEmpty() const noexcept
Returns true if the array is empty, false otherwise.
String trim() const
Returns a copy of this string with any whitespace characters removed from the start and end.
bool isEmpty() const noexcept
Returns true if the string contains no characters.
bool isNotEmpty() const noexcept
Returns true if the string contains at least one character.
One of these is used by a TableListBox as the data model for the table's contents.
virtual void cellClicked(int rowNumber, int columnId, const MouseEvent &)
This callback is made when the user clicks on one of the cells in the table.
void setModel(TableListBoxModel *newModel)
Changes the TableListBoxModel that is being used for this table.
void setHeaderHeight(int newHeight)
Changes the height of the table header component.
int getNumRows() override
This has to return the number of items in the list.
TableHeaderComponent & getHeader() const noexcept
Returns the header component being used in this table.
void changeWidthToFitText()
Changes this button's width to fit neatly around its current text, without changing its height.
A task that is executed by a ThreadPool object.
JobStatus
These are the values that can be returned by the runJob() method.
@ jobHasFinished
indicates that the job has finished and can be removed from the pool.
bool shouldExit() const noexcept
Returns true if something is trying to interrupt this job and make it stop.
A set of threads that will run a list of jobs.
Makes repeated callbacks to a virtual method at a specified time interval.
void startTimer(int intervalInMilliseconds) noexcept
Starts the timer and sets the length of interval required.
#define TRANS(stringLiteral)
Uses the LocalisedStrings class to translate the given string literal.
NewLine newLine
A predefined object representing a new-line, which can be written to a string or stream.
@ WarningIcon
An exclamation mark to indicate that the dialog is a warning about something and shouldn't be ignored...
@ NoIcon
No icon will be shown on the dialog box.
@ InfoIcon
An icon that indicates that the dialog box is just giving the user some information,...
Type unalignedPointerCast(void *ptr) noexcept
Casts a pointer to another type via void*, which suppresses the cast-align warning which sometimes ar...
T set_difference(T... args)
A set of threads that will run a list of jobs.
ThreadPoolOptions withNumberOfThreads(int newNumberOfThreads) const
The number of threads to run.