AUP3: Rename empty project after importing AU* projects

This commit is contained in:
Leland Lucius 2020-07-17 20:46:08 -05:00
parent df4f3bd4e2
commit 17268edf4b
1 changed files with 17 additions and 1 deletions

View File

@ -1156,16 +1156,25 @@ bool ProjectFileManager::Import(
const FilePath &fileName, WaveTrackArray* pTrackArray /*= NULL*/)
{
auto &project = mProject;
auto &projectFileIO = ProjectFileIO::Get(project);
auto oldTags = Tags::Get( project ).shared_from_this();
bool initiallyEmpty = TrackList::Get(project).empty();
TrackHolders newTracks;
TranslatableString errorMessage;
// Handle AUP3 ("project") files directly
if (fileName.AfterLast('.').IsSameAs(wxT("aup3"), false)) {
auto &projectFileIO = ProjectFileIO::Get(project);
if (projectFileIO.ImportProject(fileName)) {
auto &history = ProjectHistory::Get(project);
// If the project was clean and temporary (not permanently saved), then set
// the filename to the just imported path.
if (initiallyEmpty && projectFileIO.IsTemporary()) {
project.SetProjectName(wxFileName(fileName).GetName());
projectFileIO.SetProjectTitle();
}
history.PushState(XO("Imported '%s'").Format(fileName), XO("Import"));
FileHistory::Global().Append(fileName);
@ -1218,6 +1227,13 @@ bool ProjectFileManager::Import(
// Handle AUP ("legacy project") files directly
if (fileName.AfterLast('.').IsSameAs(wxT("aup"), false)) {
// If the project was clean and temporary (not permanently saved), then set
// the filename to the just imported path.
if (initiallyEmpty && projectFileIO.IsTemporary()) {
project.SetProjectName(wxFileName(fileName).GetName());
projectFileIO.SetProjectTitle();
}
auto &history = ProjectHistory::Get( project );
history.PushState(XO("Imported '%s'").Format( fileName ), XO("Import"));