Audacity 3.2.0
|
#include <ProjectFileManager.h>
Classes | |
struct | ReadProjectResults |
Public Types | |
using | ProjectChooserFn = std::function< AudacityProject &(bool)> |
A function that returns a project to use for opening a file; argument is true if opening a project file. More... | |
Public Member Functions | |
ProjectFileManager (AudacityProject &project) | |
ProjectFileManager (const ProjectFileManager &)=delete | |
ProjectFileManager & | operator= (const ProjectFileManager &)=delete |
~ProjectFileManager () | |
bool | OpenProject () |
void | CloseProject () |
bool | OpenNewProject () |
void | CompactProjectOnClose () |
bool | Save () |
bool | SaveAs (bool allowOverwrite=false) |
bool | SaveAs (const FilePath &newFileName, bool addToHistory=true) |
bool | SaveFromTimerRecording (wxFileName fnFile) |
bool | SaveCopy (const FilePath &fileName=wxT("")) |
bool | Import (const FilePath &fileName, bool addToHistory=true) |
bool | Import (wxArrayString fileNames, bool addToHistory=true) |
void | Compact () |
void | AddImportedTracks (const FilePath &fileName, TrackHolders &&newTracks) |
bool | GetMenuClose () const |
void | SetMenuClose (bool value) |
Public Member Functions inherited from ClientData::Base | |
virtual | ~Base () |
Static Public Member Functions | |
static ProjectFileManager & | Get (AudacityProject &project) |
static const ProjectFileManager & | Get (const AudacityProject &project) |
static void | DiscardAutosave (const FilePath &filename) |
static wxArrayString | ShowOpenDialog (FileNames::Operation op, const FileNames::FileType &extraType={}) |
Show an open dialogue for opening audio files, and possibly other sorts of files. More... | |
static bool | IsAlreadyOpen (const FilePath &projPathName) |
static AudacityProject * | OpenFile (const ProjectChooserFn &chooser, const FilePath &fileName, bool addtohistory=true) |
static void | FixTracks (TrackList &tracks, const std::function< void(const TranslatableString &)> &onError, const std::function< void(const TranslatableString &)> &onUnlink) |
Attempts to find and fix problems in tracks. More... | |
Private Member Functions | |
bool | ImportAndRunTempoDetection (const std::vector< FilePath > &fileNames, bool addToHistory) |
bool | DoImport (const FilePath &fileName, bool addToHistory, std::shared_ptr< ClipMirAudioReader > &resultingReader) |
AudacityProject * | OpenProjectFile (const FilePath &fileName, bool addtohistory) |
ReadProjectResults | ReadProjectFile (const FilePath &fileName, bool discardAutosave=false) |
bool | DoSave (const FilePath &fileName, bool fromSaveAs) |
Private Attributes | |
AudacityProject & | mProject |
std::shared_ptr< TrackList > | mLastSavedTracks |
bool | mMenuClose { false } |
Definition at line 32 of file ProjectFileManager.h.
using ProjectFileManager::ProjectChooserFn = std::function<AudacityProject&(bool)> |
A function that returns a project to use for opening a file; argument is true if opening a project file.
Definition at line 86 of file ProjectFileManager.h.
|
explicit |
Definition at line 110 of file ProjectFileManager.cpp.
|
delete |
|
default |
void ProjectFileManager::AddImportedTracks | ( | const FilePath & | fileName, |
TrackHolders && | newTracks | ||
) |
Definition at line 1176 of file ProjectFileManager.cpp.
References fn, ProjectFileIO::Get(), ProjectHistory::Get(), TrackList::Get(), Track::GetName(), WaveTrack::GetRate(), PlayableTrack::GetSolo(), WaveTrack::Intervals(), mProject, project, SelectUtilities::SelectNone(), tracks, XC, and XO().
Referenced by anonymous_namespace{FileMenus.cpp}::DoImport().
void ProjectFileManager::CloseProject | ( | ) |
Definition at line 842 of file ProjectFileManager.cpp.
References ProjectFileIO::Get(), mLastSavedTracks, mProject, and project.
Referenced by ApplyMacroDialog::OnApplyToFiles().
void ProjectFileManager::Compact | ( | ) |
Definition at line 1640 of file ProjectFileManager.cpp.
References AudacityMessageBox(), UndoTracks::Find(), fn, Internat::FormatSize(), Clipboard::Get(), ProjectFileIO::Get(), UndoManager::Get(), mProject, project, and XO().
Referenced by anonymous_namespace{FileMenus.cpp}::OnCompact().
void ProjectFileManager::CompactProjectOnClose | ( | ) |
Definition at line 787 of file ProjectFileManager.cpp.
References WaveTrackUtilities::CloseLock(), ProjectFileIO::Get(), UndoManager::Get(), mLastSavedTracks, mProject, project, and UndoManager::UnsavedChanges().
|
static |
Definition at line 92 of file ProjectFileManager.cpp.
References WaveTrackUtilities::CloseLock(), Get(), InvisibleTemporaryProject::Project(), and project.
Referenced by DiscardAllProjects().
|
private |
Definition at line 1451 of file ProjectFileManager.cpp.
References FileHistory::Append(), DoProjectTempoChange(), TranslatableString::empty(), TrackList::empty(), fn, Importer::Get(), ProjectTimeSignature::Get(), ProjectFileIO::Get(), ProjectHistory::Get(), Tags::Get(), TrackList::Get(), WaveTrackFactory::Get(), ProjectTimeSignature::GetTempo(), FileHistory::Global(), Importer::Import(), anonymous_namespace{ProjectFileManager.cpp}::ImportProject(), mProject, project, ProjectFramePlacement(), Tags::Set(), BasicUI::ShowErrorDialog(), wxT(), and XO().
|
private |
Definition at line 342 of file ProjectFileManager.cpp.
References FileNames::AbbreviatePath(), Track::DuplicateOptions::Backup(), TrackList::Create(), TempDirectory::FATFilesystemDenied(), ProjectFileIO::Get(), UndoManager::Get(), ProjectStatus::Get(), TrackList::Get(), ProjectSettings::Get(), GetProjectFrame(), FileNames::IsOnFATFileSystem(), mLastSavedTracks, mProject, ProjectFramePlacement(), ProjectStatus::Set(), settings(), BasicUI::ShowErrorDialog(), UndoManager::StateSaved(), tracks, FileException::WriteFailureMessage(), and XO().
Referenced by Save(), SaveAs(), and SaveFromTimerRecording().
|
static |
Attempts to find and fix problems in tracks.
tracks | A list of tracks to be fixed |
onError | Called each time unrepairable error has been found. |
onUnlink | Called when tracks unlinked due to link inconsistency. |
Definition at line 1035 of file ProjectFileManager.cpp.
References RealtimeEffectList::Clear(), RealtimeEffectList::Get(), ChannelGroup::None, tracks, wxT(), and XO().
Referenced by AUPImportFileHandle::Import().
|
static |
Definition at line 82 of file ProjectFileManager.cpp.
References project, and sFileManagerKey.
Referenced by ImportCommand::Apply(), SaveProjectCommand::Apply(), SaveCopyCommand::Apply(), DiscardAutosave(), anonymous_namespace{FileMenus.cpp}::DoImport(), TimerRecordDialog::ExecutePostRecordActions(), Get(), AUPImportFileHandle::HandleImport(), AUPImportFileHandle::HandleProject(), Import(), ProjectManager::New(), ApplyMacroDialog::OnApplyToFiles(), anonymous_namespace{FileMenus.cpp}::OnClose(), ProjectManager::OnCloseWindow(), anonymous_namespace{FileMenus.cpp}::OnCompact(), anonymous_namespace{EditMenus.cpp}::OnPaste(), anonymous_namespace{FileMenus.cpp}::OnSave(), anonymous_namespace{FileMenus.cpp}::OnSaveAs(), anonymous_namespace{FileMenus.cpp}::OnSaveCopy(), OpenFile(), audacity::cloud::audiocom::sync::ResaveLocally(), ProjectManager::ResetProjectToEmpty(), and audacity::cloud::audiocom::sync::SaveToCloud().
|
static |
Definition at line 87 of file ProjectFileManager.cpp.
References Get(), and project.
|
inline |
Definition at line 106 of file ProjectFileManager.h.
bool ProjectFileManager::Import | ( | const FilePath & | fileName, |
bool | addToHistory = true |
||
) |
Definition at line 1346 of file ProjectFileManager.cpp.
References Import().
Referenced by ImportCommand::Apply(), anonymous_namespace{FileMenus.cpp}::DoImport(), AUPImportFileHandle::HandleImport(), Import(), ApplyMacroDialog::OnApplyToFiles(), anonymous_namespace{EditMenus.cpp}::OnPaste(), and OpenFile().
bool ProjectFileManager::Import | ( | wxArrayString | fileNames, |
bool | addToHistory = true |
||
) |
Definition at line 1353 of file ProjectFileManager.cpp.
References TrackList::Any(), BasicUI::CallAfter(), FileNames::CompareNoCase(), TrackList::Get(), Get(), ImportAndRunTempoDetection(), and mProject.
|
private |
Definition at line 1420 of file ProjectFileManager.cpp.
References TrackList::Any(), BasicUI::CallAfter(), TrackList::Get(), mProject, anonymous_namespace{ProjectFileManager.cpp}::RunTempoDetection(), and MIR::SynchronizeProject().
Referenced by Import().
|
static |
Definition at line 901 of file ProjectFileManager.cpp.
References AudacityMessageBox(), AllProjects::begin(), AllProjects::end(), ProjectFileIO::Get(), ProjectFileIO::GetFileName(), and XO().
Referenced by EVT_MENU_RANGE(), AudacityApp::OnMRUFile(), OpenFile(), and ProjectManager::OpenFiles().
|
static |
Opens files of many kinds. In case of import (sound, MIDI, or .aup), the undo history is pushed.
chooser | told whether opening a project file; decides which project to open into |
fileName | the name and contents are examined to decide a type and open appropriately |
addtohistory | whether to add .aup3 files to the MRU list (but always done for imports) |
Definition at line 923 of file ProjectFileManager.cpp.
References AudacityMessageBox(), TempDirectory::FATFilesystemDenied(), PluginManager::Get(), Viewport::Get(), Get(), PlatformCompatibility::GetLongFileName(), Import(), IsAlreadyOpen(), OpenProjectFile(), project, MenuCreator::RebuildAllMenuBars(), wxT(), XO(), and Viewport::ZoomFitHorizontallyAndShowTrack().
Referenced by OpenProjectCommand::Apply(), and ProjectManager::OpenProject().
bool ProjectFileManager::OpenNewProject | ( | ) |
Definition at line 826 of file ProjectFileManager.cpp.
References ProjectFileIO::Get(), mProject, OpenProject(), project, and TempDirectory::UnsavedProjectFileName().
bool ProjectFileManager::OpenProject | ( | ) |
Definition at line 818 of file ProjectFileManager.cpp.
References ProjectFileIO::Get(), mProject, and project.
Referenced by ApplyMacroDialog::OnApplyToFiles(), and OpenNewProject().
|
private |
fileName | a path assumed to exist and contain an .aup3 project |
addtohistory | whether to add the file to the MRU list |
Definition at line 1102 of file ProjectFileManager.cpp.
References FileHistory::Append(), Cancel, WaveTrackUtilities::CloseLock(), TrackFocus::Get(), ProjectFileIO::Get(), ProjectHistory::Get(), TrackList::Get(), Viewport::Get(), TrackPanel::Get(), FileHistory::Global(), ProjectHistory::InitialState(), mProject, ProjectFileIOExtensionRegistry::OnOpen(), project, ProjectFramePlacement(), ReadProjectFile(), Viewport::ReinitScrollbars(), audacity::ToUTF8(), tracks, wxT(), and XO().
Referenced by OpenFile().
|
delete |
|
private |
Parse project file
Definition at line 165 of file ProjectFileManager.cpp.
References AudacityMessageBox(), Track::DuplicateOptions::Backup(), TrackList::Channels(), TrackList::Create(), Track::Duplicate(), ProjectFileIO::Get(), TrackList::Get(), GetProjectFrame(), ChannelGroup::None, ProjectFileIOExtensionRegistry::OnLoad(), project, BasicUI::ShowMessageBox(), tracks, XO(), and WaveTrack::ZipClips().
Referenced by OpenProjectFile().
bool ProjectFileManager::Save | ( | ) |
Definition at line 291 of file ProjectFileManager.cpp.
References Continue, DoSave(), ProjectFileIO::Get(), Handled, mProject, ProjectFileIOExtensionRegistry::OnSave(), SaveAs(), and audacity::ToWXString().
Referenced by audacity::cloud::audiocom::sync::SaveToCloud().
bool ProjectFileManager::SaveAs | ( | bool | allowOverwrite = false | ) |
Definition at line 471 of file ProjectFileManager.cpp.
References FileHistory::Append(), AudacityMessageBox(), FileNames::AudacityProjects, DoSave(), FileNames::FindDefaultPath(), ProjectFileIO::Get(), ProjectFileIO::GetFileName(), GetProjectFrame(), FileHistory::Global(), FileNames::IsPathAvailable(), anonymous_namespace{TrackSelectHandle.cpp}::Message(), mProject, ProjectFileIOExtensionRegistry::OnClose(), project, SelectFile(), TitleRestorer::sProjName, TitleRestorer::sProjNumber, title, Veto, wxT(), and XO().
Referenced by audacity::cloud::audiocom::sync::ResaveLocally(), and Save().
bool ProjectFileManager::SaveAs | ( | const FilePath & | newFileName, |
bool | addToHistory = true |
||
) |
Definition at line 442 of file ProjectFileManager.cpp.
References FileHistory::Append(), DoSave(), ProjectFileIO::Get(), FileHistory::Global(), mProject, project, and XO().
Definition at line 610 of file ProjectFileManager.cpp.
References FileNames::AbbreviatePath(), FileNames::AudacityProjects, TempDirectory::FATFilesystemDenied(), FileNames::FindDefaultPath(), ProjectFileIO::Get(), GetProjectFrame(), FileNames::IsOnFATFileSystem(), FileNames::IsPathAvailable(), mProject, project, ProjectFramePlacement(), SelectFile(), BasicUI::ShowErrorDialog(), TitleRestorer::sProjName, TitleRestorer::sProjNumber, title, FileException::WriteFailureMessage(), wxT(), and XO().
bool ProjectFileManager::SaveFromTimerRecording | ( | wxFileName | fnFile | ) |
Definition at line 754 of file ProjectFileManager.cpp.
References FileHistory::Append(), DoSave(), ProjectFileIO::Get(), FileHistory::Global(), mProject, and project.
|
inline |
Definition at line 107 of file ProjectFileManager.h.
Referenced by anonymous_namespace{FileMenus.cpp}::OnClose().
|
static |
Show an open dialogue for opening audio files, and possibly other sorts of files.
The file type filter will automatically contain:
extraType | Specify an additional format to allow opening in this dialogue. |
Definition at line 859 of file ProjectFileManager.cpp.
References FileNames::FindDefaultPath(), Importer::Get(), Importer::GetFileTypes(), FileDialog::GetFilterIndex(), FileDialog::GetPath(), FileDialog::GetPaths(), Importer::SelectDefaultOpenType(), Importer::SetDefaultOpenType(), FileDialog::SetFilterIndex(), Importer::SetLastOpenType(), FileDialog::ShowModal(), FileNames::UpdateDefaultPath(), wxT(), and XO().
Referenced by anonymous_namespace{FileMenus.cpp}::DoImport(), and ProjectManager::OpenFiles().
|
private |
Definition at line 149 of file ProjectFileManager.h.
Referenced by CloseProject(), CompactProjectOnClose(), and DoSave().
|
private |
Definition at line 152 of file ProjectFileManager.h.
|
private |
Definition at line 147 of file ProjectFileManager.h.
Referenced by AddImportedTracks(), CloseProject(), Compact(), CompactProjectOnClose(), DoImport(), DoSave(), Import(), ImportAndRunTempoDetection(), OpenNewProject(), OpenProject(), OpenProjectFile(), Save(), SaveAs(), SaveCopy(), and SaveFromTimerRecording().