1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-22 01:34:21 +00:00

Projucer: Removed some unused code from the FilePathPropertyComponent

This commit is contained in:
ed 2019-11-14 09:03:20 +00:00
parent 966f5f09ec
commit ecf97e2a08
2 changed files with 23 additions and 37 deletions

View file

@ -39,25 +39,23 @@ class FilePathPropertyComponent : public PropertyComponent,
{
public:
FilePathPropertyComponent (Value valueToControl, const String& propertyName, bool isDir, bool thisOS = true,
const String& wildcardsToUse = "*", const File& relativeRoot = File(), bool multiPath = false)
const String& wildcardsToUse = "*", const File& relativeRoot = File())
: PropertyComponent (propertyName),
text (valueToControl, propertyName, 1024, false),
isDirectory (isDir), isThisOS (thisOS), supportsMultiplePaths (multiPath), wildcards (wildcardsToUse), root (relativeRoot)
isDirectory (isDir), isThisOS (thisOS), wildcards (wildcardsToUse), root (relativeRoot)
{
textValue.referTo (valueToControl);
init();
}
/** Displays a default value when no value is specified by the user. */
FilePathPropertyComponent (ValueWithDefault& valueToControl, const String& propertyName, bool isDir, bool thisOS = true,
const String& wildcardsToUse = "*", const File& relativeRoot = File(), bool multiPath = false)
const String& wildcardsToUse = "*", const File& relativeRoot = File())
: PropertyComponent (propertyName),
text (valueToControl, propertyName, 1024, false),
isDirectory (isDir), isThisOS (thisOS), supportsMultiplePaths (multiPath), wildcards (wildcardsToUse), root (relativeRoot)
isDirectory (isDir), isThisOS (thisOS), wildcards (wildcardsToUse), root (relativeRoot)
{
textValue = valueToControl.getPropertyAsValue();
init();
}
@ -89,15 +87,8 @@ public:
void filesDropped (const StringArray& selectedFiles, int, int) override
{
if (supportsMultiplePaths)
{
for (auto& f : selectedFiles)
setTo (f);
}
else
{
setTo (selectedFiles[0]);
}
setTo (selectedFiles[0]);
highlightForDragAndDrop = false;
repaint();
@ -126,11 +117,6 @@ private:
auto pathName = (root == File()) ? f.getFullPathName()
: f.getRelativePathFrom (root);
auto currentPath = text.getText();
if (supportsMultiplePaths && currentPath.isNotEmpty())
pathName = currentPath.trimCharactersAtEnd (" ;") + "; " + pathName;
text.setText (pathName);
updateEditorColour();
}
@ -160,24 +146,24 @@ private:
void updateEditorColour()
{
if (supportsMultiplePaths || ! isThisOS)
return;
text.setColour (TextPropertyComponent::textColourId, findColour (widgetTextColourId));
auto pathToCheck = text.getText();
if (pathToCheck.isNotEmpty())
if (isThisOS)
{
pathToCheck.replace ("${user.home}", "~");
text.setColour (TextPropertyComponent::textColourId, findColour (widgetTextColourId));
#if JUCE_WINDOWS
if (pathToCheck.startsWith ("~"))
pathToCheck = pathToCheck.replace ("~", File::getSpecialLocation (File::userHomeDirectory).getFullPathName());
#endif
auto pathToCheck = text.getText();
if (! root.getChildFile (pathToCheck).exists())
text.setColour (TextPropertyComponent::textColourId, Colours::red);
if (pathToCheck.isNotEmpty())
{
pathToCheck.replace ("${user.home}", "~");
#if JUCE_WINDOWS
if (pathToCheck.startsWith ("~"))
pathToCheck = pathToCheck.replace ("~", File::getSpecialLocation (File::userHomeDirectory).getFullPathName());
#endif
if (! root.getChildFile (pathToCheck).exists())
text.setColour (TextPropertyComponent::textColourId, Colours::red);
}
}
}
@ -200,7 +186,7 @@ private:
TextPropertyComponent text;
TextButton browseButton { "..." };
bool isDirectory, isThisOS, supportsMultiplePaths, highlightForDragAndDrop = false;
bool isDirectory, isThisOS, highlightForDragAndDrop = false;
String wildcards;
File root;