mirror of
https://github.com/cookiengineer/audacity
synced 2025-08-01 08:29:27 +02:00
Prompt before overwriting another project
This commit is contained in:
parent
a06e845b2f
commit
87439b5761
@ -4518,17 +4518,55 @@ For an audio file that will open in other apps, use 'Export'.\n"),
|
|||||||
fName = filename.GetFullPath();
|
fName = filename.GetFullPath();
|
||||||
|
|
||||||
bool bOwnsNewAupName = mbLoadedFromAup && (mFileName==fName);
|
bool bOwnsNewAupName = mbLoadedFromAup && (mFileName==fName);
|
||||||
//check to see if the NEW project file already exists.
|
// Check to see if the project file already exists, and if it does
|
||||||
//We should only overwrite it if this project already has the same name, where the user
|
// check that the project file 'belongs' to this project.
|
||||||
//simply chose to use the save as command although the save command would have the effect.
|
// otherwise, prompt the user before overwriting.
|
||||||
if (!bOwnsNewAupName && filename.FileExists()) {
|
if (!bOwnsNewAupName && filename.FileExists()) {
|
||||||
AudacityMessageDialog m(
|
// Ensure that project of same name is not open in another window.
|
||||||
NULL,
|
// fName is the destination file.
|
||||||
_("The project was not saved because the file name provided would overwrite another project.\nPlease try again and select an original name."),
|
// mFileName is this project.
|
||||||
_("Error Saving Project"),
|
// It is possible for mFileName == fName even when this project is not
|
||||||
wxOK|wxICON_ERROR);
|
// saved to disk, and we then need to check the destination file is not
|
||||||
m.ShowModal();
|
// open in another window.
|
||||||
return false;
|
int mayOverwrite = (mFileName == fName)? 2 : 1;
|
||||||
|
for (auto p : gAudacityProjects) {
|
||||||
|
const wxFileName openProjectName(p->mFileName);
|
||||||
|
if (openProjectName.SameAs(fName)) {
|
||||||
|
mayOverwrite -= 1;
|
||||||
|
if (mayOverwrite == 0)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mayOverwrite > 0) {
|
||||||
|
/* i18n-hint: In each case, %s is the name
|
||||||
|
of the file being overwritten.*/
|
||||||
|
wxString Message = wxString::Format(_("\
|
||||||
|
Do you want to overwrite the project:\n\"%s\"?\n\n\
|
||||||
|
If you select \"Yes\" the project\n\"%s\"\n\
|
||||||
|
will be irreversibly overwritten."), fName, fName);
|
||||||
|
|
||||||
|
// For safety, there should NOT be an option to hide this warning.
|
||||||
|
int result = AudacityMessageBox(Message,
|
||||||
|
/* i18n-hint: Heading: A warning that a project is about to be overwritten.*/
|
||||||
|
_("Overwrite Project Warning"),
|
||||||
|
wxYES_NO | wxNO_DEFAULT | wxICON_WARNING,
|
||||||
|
this);
|
||||||
|
if (result != wxYES) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Overwrite disalowed. The destination project is open in another window.
|
||||||
|
AudacityMessageDialog m(
|
||||||
|
NULL,
|
||||||
|
_("The project will not saved because the selected project is open in another window.\nPlease try again and select an original name."),
|
||||||
|
_("Error Saving Project"),
|
||||||
|
wxOK|wxICON_ERROR);
|
||||||
|
m.ShowModal();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString oldFileName = mFileName;
|
wxString oldFileName = mFileName;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user