1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

Added a flag to FileBrowserComponent to allow it to keep the current name when the folder changes, and used this flag in the introjucer's new project wizard.

This commit is contained in:
jules 2015-06-23 12:44:51 +01:00
parent cd056a89cc
commit d3f76766db
3 changed files with 34 additions and 16 deletions

View file

@ -256,7 +256,8 @@ private:
class WizardComp : public Component,
private ButtonListener,
private ComboBoxListener,
private TextEditorListener
private TextEditorListener,
private FileBrowserListener
{
public:
WizardComp()
@ -264,7 +265,9 @@ public:
projectName (TRANS("Project name")),
nameLabel (String::empty, TRANS("Project Name") + ":"),
typeLabel (String::empty, TRANS("Project Type") + ":"),
fileBrowser (FileBrowserComponent::saveMode | FileBrowserComponent::canSelectDirectories,
fileBrowser (FileBrowserComponent::saveMode
| FileBrowserComponent::canSelectDirectories
| FileBrowserComponent::doNotClearFileNameOnRootChange,
NewProjectWizardClasses::getLastWizardFolder(), nullptr, nullptr),
fileOutline (String::empty, TRANS("Project Folder") + ":"),
targetsOutline (String::empty, TRANS("Target Platforms") + ":"),
@ -303,6 +306,8 @@ public:
addChildAndSetID (&fileBrowser, "fileBrowser");
fileBrowser.setBounds ("fileOutline.left + 10, fileOutline.top + 20, fileOutline.right - 10, fileOutline.bottom - 32");
fileBrowser.setFilenameBoxLabel ("Folder:");
fileBrowser.setFileName (File::createLegalFileName (projectName.getText()));
fileBrowser.addListener (this);
addChildAndSetID (&createButton, "createButton");
createButton.setBounds ("right - 130, bottom - 34, parent.width - 30, parent.height - 30");
@ -409,6 +414,16 @@ public:
fileBrowser.setFileName (File::createLegalFileName (projectName.getText()));
}
void selectionChanged() override {}
void fileClicked (const File&, const MouseEvent&) override {}
void fileDoubleClicked (const File&) override {}
void browserRootChanged (const File&) override
{
fileBrowser.setFileName (File::createLegalFileName (projectName.getText()));
}
ComboBox projectType;
PlatformTargetsComp platformTargets;

View file

@ -387,7 +387,7 @@ void FileBrowserComponent::fileDoubleClicked (const File& f)
{
setRoot (f);
if ((flags & canSelectDirectories) != 0)
if ((flags & canSelectDirectories) != 0 && (flags & doNotClearFileNameOnRootChange) == 0)
filenameBox.setText (String::empty);
}
else
@ -432,7 +432,9 @@ void FileBrowserComponent::textEditorReturnKeyPressed (TextEditor&)
{
setRoot (f);
chosenFiles.clear();
filenameBox.setText (String::empty);
if ((flags & doNotClearFileNameOnRootChange) == 0)
filenameBox.setText (String());
}
else
{

View file

@ -51,18 +51,19 @@ public:
*/
enum FileChooserFlags
{
openMode = 1, /**< specifies that the component should allow the user to
choose an existing file with the intention of opening it. */
saveMode = 2, /**< specifies that the component should allow the user to specify
the name of a file that will be used to save something. */
canSelectFiles = 4, /**< specifies that the user can select files (can be used in
conjunction with canSelectDirectories). */
canSelectDirectories = 8, /**< specifies that the user can select directories (can be used in
conjuction with canSelectFiles). */
canSelectMultipleItems = 16, /**< specifies that the user can select multiple items. */
useTreeView = 32, /**< specifies that a tree-view should be shown instead of a file list. */
filenameBoxIsReadOnly = 64, /**< specifies that the user can't type directly into the filename box. */
warnAboutOverwriting = 128 /**< specifies that the dialog should warn about overwriting existing files (if possible). */
openMode = 1, /**< specifies that the component should allow the user to
choose an existing file with the intention of opening it. */
saveMode = 2, /**< specifies that the component should allow the user to specify
the name of a file that will be used to save something. */
canSelectFiles = 4, /**< specifies that the user can select files (can be used in
conjunction with canSelectDirectories). */
canSelectDirectories = 8, /**< specifies that the user can select directories (can be used in
conjuction with canSelectFiles). */
canSelectMultipleItems = 16, /**< specifies that the user can select multiple items. */
useTreeView = 32, /**< specifies that a tree-view should be shown instead of a file list. */
filenameBoxIsReadOnly = 64, /**< specifies that the user can't type directly into the filename box. */
warnAboutOverwriting = 128, /**< specifies that the dialog should warn about overwriting existing files (if possible). */
doNotClearFileNameOnRootChange = 256 /**< specifies that the file name should not be cleared upon root change. */
};
//==============================================================================