![]() |
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) |
void | Compact () |
void | AddImportedTracks (const FilePath &fileName, TrackHolders &&newTracks) |
bool | GetMenuClose () const |
void | SetMenuClose (bool value) |
![]() | |
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) |
Private Member Functions | |
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 31 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 85 of file ProjectFileManager.h.
|
explicit |
Definition at line 100 of file ProjectFileManager.cpp.
|
delete |
|
default |
void ProjectFileManager::AddImportedTracks | ( | const FilePath & | fileName, |
TrackHolders && | newTracks | ||
) |
Definition at line 1113 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(), and Import().
void ProjectFileManager::CloseProject | ( | ) |
Definition at line 831 of file ProjectFileManager.cpp.
References ProjectFileIO::Get(), mLastSavedTracks, mProject, and project.
Referenced by ApplyMacroDialog::OnApplyToFiles().
void ProjectFileManager::Compact | ( | ) |
Definition at line 1466 of file ProjectFileManager.cpp.
References AudacityMessageBox(), TrackList::FindUndoTracks(), 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 778 of file ProjectFileManager.cpp.
References ProjectFileIO::Get(), UndoManager::Get(), mLastSavedTracks, mProject, project, and UndoManager::UnsavedChanges().
|
static |
Definition at line 82 of file ProjectFileManager.cpp.
References Get(), InvisibleTemporaryProject::Project(), and project.
Referenced by DiscardAllProjects().
|
private |
Definition at line 316 of file ProjectFileManager.cpp.
References FileNames::AbbreviatePath(), AudacityMessageBox(), 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 |
Definition at line 72 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(), ProjectManager::New(), ApplyMacroDialog::OnApplyToFiles(), anonymous_namespace{FileMenus.cpp}::OnClose(), ProjectManager::OnCloseWindow(), anonymous_namespace{FileMenus.cpp}::OnCompact(), anonymous_namespace{FileMenus.cpp}::OnSave(), anonymous_namespace{FileMenus.cpp}::OnSaveAs(), anonymous_namespace{FileMenus.cpp}::OnSaveCopy(), OpenFile(), and ProjectManager::ResetProjectToEmpty().
|
static |
Definition at line 77 of file ProjectFileManager.cpp.
References Get(), and project.
|
inline |
Definition at line 105 of file ProjectFileManager.h.
bool ProjectFileManager::Import | ( | const FilePath & | fileName, |
bool | addToHistory = true |
||
) |
Definition at line 1291 of file ProjectFileManager.cpp.
References AddImportedTracks(), FileHistory::Append(), TranslatableString::empty(), TrackList::empty(), fn, Importer::Get(), ProjectFileIO::Get(), ProjectHistory::Get(), Tags::Get(), TrackList::Get(), WaveTrackFactory::Get(), FileHistory::Global(), Importer::Import(), anonymous_namespace{ProjectFileManager.cpp}::ImportProject(), mProject, project, ProjectFramePlacement(), Tags::Set(), BasicUI::ShowErrorDialog(), wxT(), and XO().
Referenced by ImportCommand::Apply(), anonymous_namespace{FileMenus.cpp}::DoImport(), AUPImportFileHandle::HandleImport(), ApplyMacroDialog::OnApplyToFiles(), and OpenFile().
|
static |
Definition at line 890 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 912 of file ProjectFileManager.cpp.
References AudacityMessageBox(), DoImportMIDI(), TempDirectory::FATFilesystemDenied(), PluginManager::Get(), Get(), ProjectWindow::Get(), PlatformCompatibility::GetLongFileName(), Import(), IsAlreadyOpen(), FileNames::IsMidi(), OpenProjectFile(), project, MenuCreator::RebuildAllMenuBars(), wxT(), XO(), and ProjectWindow::ZoomAfterImport().
Referenced by OpenProjectCommand::Apply(), and ProjectManager::OpenProject().
bool ProjectFileManager::OpenNewProject | ( | ) |
Definition at line 815 of file ProjectFileManager.cpp.
References ProjectFileIO::Get(), mProject, OpenProject(), project, and TempDirectory::UnsavedProjectFileName().
bool ProjectFileManager::OpenProject | ( | ) |
Definition at line 807 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 1033 of file ProjectFileManager.cpp.
References FileHistory::Append(), TrackFocus::Get(), ProjectNumericFormats::Get(), ProjectFileIO::Get(), ProjectHistory::Get(), TrackList::Get(), ProjectSelectionManager::Get(), ProjectSettings::Get(), ProjectWindow::Get(), TrackPanel::Get(), FileHistory::Global(), ProjectHistory::InitialState(), mProject, project, ProjectFramePlacement(), ReadProjectFile(), settings(), tracks, wxT(), and XO().
Referenced by OpenFile().
|
delete |
|
private |
Parse project file
Definition at line 155 of file ProjectFileManager.cpp.
References AudacityMessageBox(), RealtimeEffectList::Clear(), TrackList::Create(), anonymous_namespace{ProjectFileManager.cpp}::FindHelpUrl(), ProjectFileIO::Get(), RealtimeEffectList::Get(), TrackList::Get(), GetProjectFrame(), ChannelGroup::None, project, BasicUI::ShowMessageBox(), tracks, wxT(), and XO().
Referenced by OpenProjectFile().
bool ProjectFileManager::Save | ( | ) |
Definition at line 271 of file ProjectFileManager.cpp.
References DoSave(), ProjectFileIO::Get(), mProject, and SaveAs().
bool ProjectFileManager::SaveAs | ( | bool | allowOverwrite = false | ) |
Definition at line 464 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, project, SelectFile(), ShowWarningDialog(), TitleRestorer::sProjName, TitleRestorer::sProjNumber, title, wxT(), and XO().
Referenced by Save().
bool ProjectFileManager::SaveAs | ( | const FilePath & | newFileName, |
bool | addToHistory = true |
||
) |
Definition at line 435 of file ProjectFileManager.cpp.
References FileHistory::Append(), DoSave(), ProjectFileIO::Get(), FileHistory::Global(), mProject, project, and XO().
Definition at line 601 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 745 of file ProjectFileManager.cpp.
References FileHistory::Append(), DoSave(), ProjectFileIO::Get(), FileHistory::Global(), mProject, and project.
|
inline |
Definition at line 106 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 848 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 131 of file ProjectFileManager.h.
Referenced by CloseProject(), CompactProjectOnClose(), and DoSave().
|
private |
Definition at line 134 of file ProjectFileManager.h.
|
private |
Definition at line 129 of file ProjectFileManager.h.
Referenced by AddImportedTracks(), CloseProject(), Compact(), CompactProjectOnClose(), DoSave(), Import(), OpenNewProject(), OpenProject(), OpenProjectFile(), Save(), SaveAs(), SaveCopy(), and SaveFromTimerRecording().