Audacity 3.2.0
ProjectFileManager.h
Go to the documentation of this file.
1/**********************************************************************
2
3Audacity: A Digital Audio Editor
4
5ProjectFileManager.h
6
7Paul Licameli split from AudacityProject.h
8
9**********************************************************************/
10
11#ifndef __AUDACITY_PROJECT_FILE_MANAGER__
12#define __AUDACITY_PROJECT_FILE_MANAGER__
13
14#include <functional>
15#include <memory>
16#include <vector>
17
18#include "ClientData.h" // to inherit
19#include "FileNames.h" // for FileType
20
21class wxString;
22class wxFileName;
23class AudacityProject;
24class Track;
25class TrackList;
26class WaveTrack;
27class XMLTagHandler;
28
29using TrackHolders = std::vector<std::shared_ptr<TrackList>>;
30
31class AUDACITY_DLL_API ProjectFileManager final
32 : public ClientData::Base
33{
34public:
36 static const ProjectFileManager &Get( const AudacityProject &project );
37
38 // Open and close a file, invisibly, removing its Autosave blob
39 static void DiscardAutosave(const FilePath &filename);
40
45
46 bool OpenProject();
47 void CloseProject();
48 bool OpenNewProject();
49
50 void CompactProjectOnClose();
51
52 bool Save();
53 bool SaveAs(bool allowOverwrite = false);
54 bool SaveAs(const FilePath &newFileName, bool addToHistory = true);
55 // strProjectPathName is full path for aup except extension
56 bool SaveFromTimerRecording( wxFileName fnFile );
57 bool SaveCopy(const FilePath &fileName = wxT(""));
58
79 static wxArrayString ShowOpenDialog(FileNames::Operation op,
80 const FileNames::FileType &extraType = {});
81
82 static bool IsAlreadyOpen(const FilePath &projPathName);
83
85 using ProjectChooserFn = std::function<AudacityProject&(bool)>;
86
94 static AudacityProject *OpenFile( const ProjectChooserFn &chooser,
95 const FilePath &fileName, bool addtohistory = true);
96
97 bool Import(const FilePath &fileName,
98 bool addToHistory = true);
99
100 void Compact();
101
102 void AddImportedTracks(const FilePath &fileName,
103 TrackHolders &&newTracks);
104
105 bool GetMenuClose() const { return mMenuClose; }
106 void SetMenuClose(bool value) { mMenuClose = value; }
107
114 static void FixTracks(TrackList& tracks,
115 const std::function<void(const TranslatableString&/*errorMessage*/)>& onError,
116 const std::function<void(const TranslatableString&/*unlinkReason*/)>& onUnlink);
117
118private:
124 AudacityProject *OpenProjectFile(
125 const FilePath &fileName, bool addtohistory);
126
128 {
132 wxString helpUrl;
133 };
134 ReadProjectResults ReadProjectFile(
135 const FilePath &fileName, bool discardAutosave = false );
136
137 bool DoSave(const FilePath & fileName, bool fromSaveAs);
138
140
141 std::shared_ptr<TrackList> mLastSavedTracks;
142
143 // Are we currently closing as the result of a menu command?
144 bool mMenuClose{ false };
145};
146
147class wxTopLevelWindow;
148
152public:
153 TitleRestorer( wxTopLevelWindow &window, AudacityProject &project );
155 wxString sProjNumber;
156 wxString sProjName;
158};
159
160#endif
wxT("CloseDown"))
Utility ClientData::Site to register hooks into a host class that attach client data.
std::vector< std::shared_ptr< TrackList > > TrackHolders
Definition: ImportRaw.h:24
wxString FilePath
Definition: Project.h:21
const auto tracks
const auto project
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:90
std::shared_ptr< TrackList > mLastSavedTracks
AudacityProject & mProject
ProjectFileManager(const ProjectFileManager &)=delete
ProjectFileManager & operator=(const ProjectFileManager &)=delete
std::function< AudacityProject &(bool)> ProjectChooserFn
A function that returns a project to use for opening a file; argument is true if opening a project fi...
void SetMenuClose(bool value)
TitleRestorer(wxTopLevelWindow &window, AudacityProject &project)
Abstract base class for an object holding data associated with points on a time axis.
Definition: Track.h:122
A flat linked list of tracks supporting Add, Remove, Clear, and Contains, serialization of the list o...
Definition: Track.h:975
Holds a msgid for the translation catalog; may also bind format arguments.
A Track that contains audio waveform data.
Definition: WaveTrack.h:222
This class is an interface which should be implemented by classes which wish to be able to load and s...
Definition: XMLTagHandler.h:42
Services * Get()
Fetch the global instance, or nullptr if none is yet installed.
Definition: BasicUI.cpp:196
A convenient default parameter for class template Site.
Definition: ClientData.h:28