Auto complete file extension in save dialog
When specifying one file extension in filechoser, if the user just write a file name without extension, auto complete name with extension. Useful for system overwrite warning .
juce_win32_FileChooser.cpp
of.hwndOwner = (HWND) parentWindow.getWindowHandle();
of.lpstrFilter = filters.getData();
of.nFilterIndex = 1;
of.lpstrFile = files;
of.nMaxFile = (DWORD) charsAvailableForResult;
of.lpstrInitialDir = localPath.toWideCharPointer();
of.lpstrTitle = title.toWideCharPointer();
of.Flags = flags;
of.lCustData = (LPARAM) &info;
//-----------------------------------------------------------------------------------
+ if (isSaveDialogue)
+ {
+ StringArray tokens;
+ tokens.addTokens (filter, ";,", "\"'");
+ tokens.trim();
+ tokens.removeEmptyStrings();
+
+ if (tokens.size() == 1 && tokens[0] != "*.*" && tokens[0] != "*")
+ {
+ of.lpstrDefExt = tokens[0].fromFirstOccurrenceOf(".",false,false).toUTF16();
+ }
+ }
//-----------------------------------------------------------------------------------
if (extraInfoComponent != nullptr)
of.lpfnHook = &openCallback;
juce_mac_FileChooser.mm
if (currentFileOrDirectory.isDirectory())
{
directory = currentFileOrDirectory.getFullPathName();
}
else
{
directory = currentFileOrDirectory.getParentDirectory().getFullPathName();
filename = currentFileOrDirectory.getFileName();
}
//---------------------------------------------------------------------------------------------------
+ if (isSaveDialogue)
+ {
+ if (filters->size() && filters->getReference(0) != "*.*" && filters->getReference(0) != "*")
+ {
+ [panel setRequiredFileType:juceStringToNS(filters->getReference(0).fromFirstOccurrenceOf(".",false,false))];
+ }
+ }
//---------------------------------------------------------------------------------------------------
#if defined (MAC_OS_X_VERSION_10_6) && (MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6)
[panel setDirectoryURL: [NSURL fileURLWithPath: juceStringToNS (directory)]];
[panel setNameFieldStringValue: juceStringToNS (filename)];
Support for x86 application directory on windows 64bits system.
juce_win32_Files.cpp
[code] case userApplicationDataDirectory: csidlType = CSIDL_APPDATA; break;
case commonApplicationDataDirectory: csidlType = CSIDL_COMMON_APPDATA; break;
case globalApplicationsDirectory: csidlType = CSIDL_PROGRAM_FILES; break;
-
case globalApplicationsDirectoryx86: csidlType = CSIDL_PROGRAM_FILESX86; break; case userMusicDirectory: csidlType = 0x0d /*CSIDL_MYMUSIC*/; break; case userMoviesDirectory: csidlType = 0x0e /*CSIDL_MYVIDEO*/; break;[/code]
juce_mac_Files.mm
[code] case userMoviesDirectory: resultPath = “~/Movies”; break;
case userApplicationDataDirectory: resultPath = “~/Library”; break;
case commonApplicationDataDirectory: resultPath = “/Library”; break;
-
case globalApplicationsDirectory: resultPath = "/Applications"; break;
-
case globalApplicationsDirectory:
-
case globalApplicationsDirectoryx86: resultPath = "/Applications"; break; case invokedExecutableFile: if (juce_Argv0 != 0) [/code]
juce_File.h
[code] Mac “/Applications”, or “/usr” on linux.
*/
globalApplicationsDirectory,
-
globalApplicationsDirectoryx86, /** The most likely place where a user might store their music files. */ userMusicDirectory,[/code]