Audacity 3.2.0
ProjectManager.h
Go to the documentation of this file.
1/**********************************************************************
2
3Audacity: A Digital Audio Editor
4
5ProjectManager.h
6
7Paul Licameli split from AudacityProject.h
8
9**********************************************************************/
10
11#ifndef __AUDACITY_PROJECT_MANAGER__
12#define __AUDACITY_PROJECT_MANAGER__
13
14#include <memory>
15
16#include <wx/event.h> // to inherit
17#include "ClientData.h" // to inherit
18#include "Identifier.h"
19#include "Observer.h"
20
21class wxTimer;
22class wxTimerEvent;
23
24class AudacityProject;
26
27struct ProjectStatusEvent;
28
29enum StatusBarField : int;
30
34class AUDACITY_DLL_API ProjectManager final
35 : public wxEvtHandler
36 , public ClientData::Base
37{
38public:
39 static ProjectManager &Get( AudacityProject &project );
40 static const ProjectManager &Get( const AudacityProject &project );
41
42 explicit ProjectManager( AudacityProject &project );
43 ProjectManager( const ProjectManager & ) PROHIBITED;
44 ProjectManager &operator=( const ProjectManager & ) PROHIBITED;
45 ~ProjectManager() override;
46
47 // This is the factory for projects:
48 static AudacityProject *New();
49
50 // The function that imports files can act as a factory too, and for that
51 // reason remains in this class, not in ProjectFileManager
52 static void OpenFiles(AudacityProject *proj);
53
55 static bool SafeToOpenProjectInto(AudacityProject &proj);
56
58
67 public:
73 ProjectChooser( AudacityProject *pProject, bool reuseNonemptyProject )
74 : mpGivenProject{ pProject }
75 , mReuseNonemptyProject{ reuseNonemptyProject }
76 {}
78 ProjectChooser( const ProjectChooser& ) PROHIBITED;
82 AudacityProject &operator() ( bool openingProjectFile );
84 void Commit();
85
86 private:
88 AudacityProject *mpUsedProject = nullptr;
90 };
91
93
101 static AudacityProject *OpenProject(
102 AudacityProject *pGivenProject,
103 const FilePath &fileNameArg, bool addtohistory, bool reuseNonemptyProject);
104
105 void ResetProjectToEmpty();
106
107 static void SaveWindowSize();
108
109 // Routine to estimate how many minutes of recording time are left on disk
110 int GetEstimatedRecordingMinsLeftOnDisk(long lCaptureChannels = 0);
111 // Converts number of minutes to human readable format
112 TranslatableString GetHoursMinsString(int iMinutes);
113
114 void SetStatusText( const TranslatableString &text, int number );
115 void SetSkipSavePrompt(bool bSkip) { sbSkipPromptingForSave = bSkip; };
116
117 static void SetClosingAll(bool closing);
118
119private:
120 void OnReconnectionFailure(wxCommandEvent & event);
121 void OnCloseWindow(wxCloseEvent & event);
122 void OnTimer(wxTimerEvent & event);
123 void OnOpenAudioFile(wxCommandEvent & event);
124 void OnStatusChange(StatusBarField field);
125
126 void RestartTimer();
127
128 // non-static data members
130
131 std::unique_ptr<wxTimer> mTimer;
132
134
135 DECLARE_EVENT_TABLE()
136
137 static bool sbWindowRectAlreadySaved;
138 static bool sbSkipPromptingForSave;
139};
140
141#endif
Utility ClientData::Site to register hooks into a host class that attach client data.
#define field(n, t)
Definition: ImportAUP.cpp:167
wxString FilePath
Definition: Project.h:20
StatusBarField
Definition: ProjectStatus.h:24
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:89
A move-only handle representing a connection to a Publisher.
Definition: Observer.h:70
Callable object that supplies the chooser argument of ProjectFileManager::OpenFile.
AudacityProject * mpGivenProject
ProjectChooser(AudacityProject *pProject, bool reuseNonemptyProject)
ProjectChooser(const ProjectChooser &) PROHIBITED
Don't copy. Use std::ref to pass it to ProjectFileManager.
Object associated with a project for high-level management of the project's lifetime,...
Observer::Subscription mSubscription
std::unique_ptr< wxTimer > mTimer
ProjectManager(const ProjectManager &) PROHIBITED
ProjectManager & operator=(const ProjectManager &) PROHIBITED
~ProjectManager() override
AudacityProject & mProject
void SetSkipSavePrompt(bool bSkip)
Holds a msgid for the translation catalog; may also bind format arguments.
Services * Get()
Fetch the global instance, or nullptr if none is yet installed.
Definition: BasicUI.cpp:26
void OnCloseWindow(wxCloseEvent &e)
struct holding stream options, including a pointer to the time warp info and AudioIOListener and whet...
Definition: AudioIOBase.h:44
A convenient default parameter for class template Site.
Definition: ClientData.h:28