Small and painless integration


#1

i wonder if it is possible to integrate tight the FilenameComponent and RecentlyUsedFileList. One takes last used files as StringArray, the other have only restore/to String methods. Could be good to have this:

const StringArray RecentlyOpenedFilesList::getFilenamesArray () const { return files; }
so we can do:

simple and clean :slight_smile:
(or maybe there are other ways to do this cleanly ?)

eventually i find useful to have a getter for max items

int RecentlyOpenedFilesList::getMaxNumberOfItems () const { return maxNumberOfItems; }
so we could save it in a config file.

other thing i would like to see is this:

void FilenameComponent::setDefaultStartDirectory (File newDefaultStartDirectory)
{
    if (newDefaultStartDirectory.existsAsFile ())
        defaultStartDirectory = newDefaultStartDirectory.getParentDirectory ();
    else
        defaultStartDirectory = newDefaultStartDirectory;
}

void FilenameComponent::buttonClicked (Button*)
{
    FileChooser fc (TRANS("Choose a new file"),
                    (getCurrentFile() != File::nonexistent) ? getCurrentFile()
                                                            : defaultStartDirectory,
                    wildcard);

    if (isDir ? fc.browseForDirectory()
              : (isSaving ? fc.browseForFileToSave (false)
                          : fc.browseForFileToOpen()))
    {
        setCurrentFile (fc.getResult(), true);
    }
}

that let you set a default start directory when no files are selected in the component.

reasonable ideas ?


#2

Thanks kraken, those are all good suggestions, which I’ll add.

Cheers!


#3

nice one !
they’re simpler things but let you save an extra typing when dealing with this sort of stuff… especially when u save a couple of for loops and array allocations when you need only to save/restore something to/from a configuration file…

regards


#4