From 6a5d4fdbc018445be6f40320efa74c65c6c74a51 Mon Sep 17 00:00:00 2001 From: Leland Lucius Date: Tue, 5 Jan 2021 13:28:04 -0600 Subject: [PATCH] Update FAT filesystem messages --- src/FileNames.cpp | 6 ++++-- src/FileNames.h | 4 +++- src/ProjectFileManager.cpp | 4 ++-- src/prefs/DirectoriesPrefs.cpp | 26 ++++++++++++++------------ 4 files changed, 23 insertions(+), 17 deletions(-) diff --git a/src/FileNames.cpp b/src/FileNames.cpp index 3827f1fae..675f3af3e 100644 --- a/src/FileNames.cpp +++ b/src/FileNames.cpp @@ -868,14 +868,16 @@ bool FileNames::IsOnFATFileSystem(const FilePath &path) } #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)) { ShowErrorDialog( window, 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" ); diff --git a/src/FileNames.h b/src/FileNames.h index e7e2a46e2..030264e1d 100644 --- a/src/FileNames.h +++ b/src/FileNames.h @@ -213,7 +213,9 @@ namespace FileNames AUDACITY_DLL_API 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 //! Give enough of the path to identify the device. (On Windows, drive letter plus ':') diff --git a/src/ProjectFileManager.cpp b/src/ProjectFileManager.cpp index fdb869b4b..a73ad678d 100644 --- a/src/ProjectFileManager.cpp +++ b/src/ProjectFileManager.cpp @@ -269,7 +269,7 @@ bool ProjectFileManager::DoSave(const FilePath & fileName, const bool fromSaveAs // Some confirmation dialogs { - if (FileNames::FATFilesystemDenied(fileName)) + if (FileNames::FATFilesystemDenied(fileName, XO("Projects cannot be saved to FAT drives."))) { return false; } @@ -587,7 +587,7 @@ bool ProjectFileManager::SaveCopy(const FilePath &fileName /* = wxT("") */) 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) { diff --git a/src/prefs/DirectoriesPrefs.cpp b/src/prefs/DirectoriesPrefs.cpp index ffd45ad6d..cfec97cc7 100644 --- a/src/prefs/DirectoriesPrefs.cpp +++ b/src/prefs/DirectoriesPrefs.cpp @@ -42,14 +42,15 @@ using namespace FileNames; class FilesystemValidator : public wxValidator { public: - FilesystemValidator() + FilesystemValidator(const TranslatableString &message) : wxValidator() { + mMessage = message; } virtual wxObject* Clone() const wxOVERRIDE { - return safenew FilesystemValidator(*this); + return safenew FilesystemValidator(mMessage); } virtual bool Validate(wxWindow* WXUNUSED(parent)) wxOVERRIDE @@ -59,7 +60,7 @@ public: return true; } - if (FATFilesystemDenied(tc->GetValue())) { + if (FATFilesystemDenied(tc->GetValue(), mMessage)) { return false; } @@ -83,12 +84,14 @@ public: wxString path = tc->GetValue(); path.insert(tc->GetInsertionPoint(), keycode); - if (FileNames::FATFilesystemDenied(path)) { + if (FileNames::FATFilesystemDenied(path, mMessage)) { evt.Skip(false); return; } } + TranslatableString mMessage; + wxDECLARE_EVENT_TABLE(); }; @@ -167,8 +170,6 @@ void DirectoriesPrefs::Populate() void DirectoriesPrefs::PopulateOrExchange(ShuttleGui &S) { - FilesystemValidator validator; - S.SetBorder(2); S.StartScroller(); @@ -195,7 +196,7 @@ void DirectoriesPrefs::PopulateOrExchange(ShuttleGui &S) {PreferenceKey(Operation::Save, PathType::User), wxT("")}, 30); - mSaveText->SetValidator(validator); + mSaveText->SetValidator(FilesystemValidator(XO("Projects cannot be saved to FAT drives."))); S.Id(SaveButtonID).AddButton(XXO("B&rowse...")); S.Id(ImportTextID); @@ -210,7 +211,6 @@ void DirectoriesPrefs::PopulateOrExchange(ShuttleGui &S) {PreferenceKey(Operation::Export, PathType::User), wxT("")}, 30); - mExportText->SetValidator(validator); S.Id(ExportButtonID).AddButton(XXO("Bro&wse...")); } S.EndMultiColumn(); @@ -228,7 +228,7 @@ void DirectoriesPrefs::PopulateOrExchange(ShuttleGui &S) {PreferenceKey(Operation::Temp, PathType::_None), wxT("")}, 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.AddPrompt(XXO("&Free Space:")); @@ -265,7 +265,8 @@ void DirectoriesPrefs::OnTempBrowse(wxCommandEvent &evt) wxFileName tmpDirPath; tmpDirPath.AssignDir(dlog.GetPath()); - if (FATFilesystemDenied(tmpDirPath.GetFullPath())) { + if (FATFilesystemDenied(tmpDirPath.GetFullPath(), + XO("Temporary files directory cannot be on a FAT drive."))) { return; } @@ -336,9 +337,10 @@ void DirectoriesPrefs::OnBrowse(wxCommandEvent &evt) 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; }