mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
FileChooser: In Linux FileChoosers, prefer to open files rather than directories if both are requested
Zenity and Kdialog only support opening either files or directories during a single invocation.
This commit is contained in:
parent
0feda541e7
commit
7504fa065b
2 changed files with 11 additions and 5 deletions
|
|
@ -183,7 +183,6 @@ void FileChooser::launchAsync (int flags, std::function<void (const FileChooser&
|
|||
pimpl->launch();
|
||||
}
|
||||
|
||||
|
||||
std::shared_ptr<FileChooser::Pimpl> FileChooser::createPimpl (int flags, FilePreviewComponent* previewComp)
|
||||
{
|
||||
results.clear();
|
||||
|
|
|
|||
|
|
@ -39,16 +39,23 @@ static bool exeIsAvailable (String executable)
|
|||
return false;
|
||||
}
|
||||
|
||||
static bool isSet (int flags, int toCheck)
|
||||
{
|
||||
return (flags & toCheck) != 0;
|
||||
}
|
||||
|
||||
class FileChooser::Native : public FileChooser::Pimpl,
|
||||
private Timer
|
||||
{
|
||||
public:
|
||||
Native (FileChooser& fileChooser, int flags)
|
||||
: owner (fileChooser),
|
||||
isDirectory ((flags & FileBrowserComponent::canSelectDirectories) != 0),
|
||||
isSave ((flags & FileBrowserComponent::saveMode) != 0),
|
||||
selectMultipleFiles ((flags & FileBrowserComponent::canSelectMultipleItems) != 0),
|
||||
warnAboutOverwrite ((flags & FileBrowserComponent::warnAboutOverwriting) != 0)
|
||||
// kdialog/zenity only support opening either files or directories.
|
||||
// Files should take precedence, if requested.
|
||||
isDirectory (isSet (flags, FileBrowserComponent::canSelectDirectories) && ! isSet (flags, FileBrowserComponent::canSelectFiles)),
|
||||
isSave (isSet (flags, FileBrowserComponent::saveMode)),
|
||||
selectMultipleFiles (isSet (flags, FileBrowserComponent::canSelectMultipleItems)),
|
||||
warnAboutOverwrite (isSet (flags, FileBrowserComponent::warnAboutOverwriting))
|
||||
{
|
||||
const File previousWorkingDirectory (File::getCurrentWorkingDirectory());
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue