Update FAT filesystem messages

This commit is contained in:
Leland Lucius 2021-01-05 13:28:04 -06:00
parent bd4cab5e93
commit 6a5d4fdbc0
4 changed files with 23 additions and 17 deletions

View File

@ -868,14 +868,16 @@ bool FileNames::IsOnFATFileSystem(const FilePath &path)
} }
#endif #endif
bool FileNames::FATFilesystemDenied( const FilePath &path, wxWindow *window /* = nullptr */ ) bool FileNames::FATFilesystemDenied( const FilePath &path,
const TranslatableString &msg,
wxWindow *window /* = nullptr */ )
{ {
if (FileNames::IsOnFATFileSystem(path)) if (FileNames::IsOnFATFileSystem(path))
{ {
ShowErrorDialog( ShowErrorDialog(
window, window,
XO("Unsuitable"), XO("Unsuitable"),
XO("FAT formatted filesystems are unsuitable."), XO("%s\n\nFor tips on suitable drives, click the help button.").Format(msg),
"Error:_Unsuitable_drive" "Error:_Unsuitable_drive"
); );

View File

@ -213,7 +213,9 @@ namespace FileNames
AUDACITY_DLL_API AUDACITY_DLL_API
bool IsOnFATFileSystem(const FilePath &path); bool IsOnFATFileSystem(const FilePath &path);
bool FATFilesystemDenied(const FilePath &path, wxWindow *window = nullptr); bool FATFilesystemDenied(const FilePath &path,
const TranslatableString &msg,
wxWindow *window = nullptr);
AUDACITY_DLL_API AUDACITY_DLL_API
//! Give enough of the path to identify the device. (On Windows, drive letter plus ':') //! Give enough of the path to identify the device. (On Windows, drive letter plus ':')

View File

@ -269,7 +269,7 @@ bool ProjectFileManager::DoSave(const FilePath & fileName, const bool fromSaveAs
// Some confirmation dialogs // Some confirmation dialogs
{ {
if (FileNames::FATFilesystemDenied(fileName)) if (FileNames::FATFilesystemDenied(fileName, XO("Projects cannot be saved to FAT drives.")))
{ {
return false; return false;
} }
@ -587,7 +587,7 @@ bool ProjectFileManager::SaveCopy(const FilePath &fileName /* = wxT("") */)
filename.SetExt(wxT("aup3")); filename.SetExt(wxT("aup3"));
if (FileNames::FATFilesystemDenied(filename.GetFullPath())) if (FileNames::FATFilesystemDenied(filename.GetFullPath(), XO("Projects cannot be saved to FAT drives.")))
{ {
if (project.mBatchMode) if (project.mBatchMode)
{ {

View File

@ -42,14 +42,15 @@ using namespace FileNames;
class FilesystemValidator : public wxValidator class FilesystemValidator : public wxValidator
{ {
public: public:
FilesystemValidator() FilesystemValidator(const TranslatableString &message)
: wxValidator() : wxValidator()
{ {
mMessage = message;
} }
virtual wxObject* Clone() const wxOVERRIDE virtual wxObject* Clone() const wxOVERRIDE
{ {
return safenew FilesystemValidator(*this); return safenew FilesystemValidator(mMessage);
} }
virtual bool Validate(wxWindow* WXUNUSED(parent)) wxOVERRIDE virtual bool Validate(wxWindow* WXUNUSED(parent)) wxOVERRIDE
@ -59,7 +60,7 @@ public:
return true; return true;
} }
if (FATFilesystemDenied(tc->GetValue())) { if (FATFilesystemDenied(tc->GetValue(), mMessage)) {
return false; return false;
} }
@ -83,12 +84,14 @@ public:
wxString path = tc->GetValue(); wxString path = tc->GetValue();
path.insert(tc->GetInsertionPoint(), keycode); path.insert(tc->GetInsertionPoint(), keycode);
if (FileNames::FATFilesystemDenied(path)) { if (FileNames::FATFilesystemDenied(path, mMessage)) {
evt.Skip(false); evt.Skip(false);
return; return;
} }
} }
TranslatableString mMessage;
wxDECLARE_EVENT_TABLE(); wxDECLARE_EVENT_TABLE();
}; };
@ -167,8 +170,6 @@ void DirectoriesPrefs::Populate()
void DirectoriesPrefs::PopulateOrExchange(ShuttleGui &S) void DirectoriesPrefs::PopulateOrExchange(ShuttleGui &S)
{ {
FilesystemValidator validator;
S.SetBorder(2); S.SetBorder(2);
S.StartScroller(); S.StartScroller();
@ -195,7 +196,7 @@ void DirectoriesPrefs::PopulateOrExchange(ShuttleGui &S)
{PreferenceKey(Operation::Save, PathType::User), {PreferenceKey(Operation::Save, PathType::User),
wxT("")}, wxT("")},
30); 30);
mSaveText->SetValidator(validator); mSaveText->SetValidator(FilesystemValidator(XO("Projects cannot be saved to FAT drives.")));
S.Id(SaveButtonID).AddButton(XXO("B&rowse...")); S.Id(SaveButtonID).AddButton(XXO("B&rowse..."));
S.Id(ImportTextID); S.Id(ImportTextID);
@ -210,7 +211,6 @@ void DirectoriesPrefs::PopulateOrExchange(ShuttleGui &S)
{PreferenceKey(Operation::Export, PathType::User), {PreferenceKey(Operation::Export, PathType::User),
wxT("")}, wxT("")},
30); 30);
mExportText->SetValidator(validator);
S.Id(ExportButtonID).AddButton(XXO("Bro&wse...")); S.Id(ExportButtonID).AddButton(XXO("Bro&wse..."));
} }
S.EndMultiColumn(); S.EndMultiColumn();
@ -228,7 +228,7 @@ void DirectoriesPrefs::PopulateOrExchange(ShuttleGui &S)
{PreferenceKey(Operation::Temp, PathType::_None), {PreferenceKey(Operation::Temp, PathType::_None),
wxT("")}, wxT("")},
30); 30);
mTempText->SetValidator(validator); mTempText->SetValidator(FilesystemValidator(XO("Temporary files directory cannot be on a FAT drive.")));
S.Id(TempButtonID).AddButton(XXO("Brow&se...")); S.Id(TempButtonID).AddButton(XXO("Brow&se..."));
S.AddPrompt(XXO("&Free Space:")); S.AddPrompt(XXO("&Free Space:"));
@ -265,7 +265,8 @@ void DirectoriesPrefs::OnTempBrowse(wxCommandEvent &evt)
wxFileName tmpDirPath; wxFileName tmpDirPath;
tmpDirPath.AssignDir(dlog.GetPath()); tmpDirPath.AssignDir(dlog.GetPath());
if (FATFilesystemDenied(tmpDirPath.GetFullPath())) { if (FATFilesystemDenied(tmpDirPath.GetFullPath(),
XO("Temporary files directory cannot be on a FAT drive."))) {
return; return;
} }
@ -336,9 +337,10 @@ void DirectoriesPrefs::OnBrowse(wxCommandEvent &evt)
return; return;
} }
if (evt.GetId() == SaveButtonID || evt.GetId() == ExportButtonID) if (evt.GetId() == SaveButtonID)
{ {
if (FATFilesystemDenied(dlog.GetPath())) if (FATFilesystemDenied(dlog.GetPath(),
XO("Projects cannot be saved to FAT drives.")))
{ {
return; return;
} }