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
28enum class ProjectFileIOMessage : int;
29
33class AUDACITY_DLL_API ProjectManager final
34 : public wxEvtHandler
35 , public ClientData::Base
36{
37public:
39 static const ProjectManager &Get( const AudacityProject &project );
40
42 ProjectManager( const ProjectManager & ) = delete;
44 ~ProjectManager() override;
45
46 // This is the factory for projects:
47 static AudacityProject *New();
48
49 // The function that imports files can act as a factory too, and for that
50 // reason remains in this class, not in ProjectFileManager
51 static void OpenFiles(AudacityProject *proj);
52
54 static bool SafeToOpenProjectInto(AudacityProject &proj);
55
57
66 public:
72 ProjectChooser( AudacityProject *pProject, bool reuseNonemptyProject )
73 : mpGivenProject{ pProject }
74 , mReuseNonemptyProject{ reuseNonemptyProject }
75 {}
77 ProjectChooser( const ProjectChooser& ) = delete;
81 AudacityProject &operator() ( bool openingProjectFile );
83 void Commit();
84
85 private:
87 AudacityProject *mpUsedProject = nullptr;
89 };
90
92
100 static AudacityProject *OpenProject(
101 AudacityProject *pGivenProject,
102 const FilePath &fileNameArg, bool addtohistory, bool reuseNonemptyProject);
103
104 void ResetProjectToEmpty();
105
106 static void SaveWindowSize();
107
108 // Routine to estimate how many minutes of recording time are left on disk
109 int GetEstimatedRecordingMinsLeftOnDisk(long lCaptureChannels = 0);
110 // Converts number of minutes to human readable format
111 TranslatableString GetHoursMinsString(int iMinutes);
112
113 void SetStatusText(const TranslatableString& text, const StatusBarField& field);
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(ProjectFileIOMessage);
121 void OnCloseWindow(wxCloseEvent & event);
122 void OnTimer(wxTimerEvent & event);
123 void OnStatusChange(StatusBarField field);
124
125 void RestartTimer();
126
127 // non-static data members
129
130 std::unique_ptr<wxTimer> mTimer;
131
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:165
wxString FilePath
Definition: Project.h:21
ProjectFileIOMessage
Subscribe to ProjectFileIO to receive messages; always in idle time.
Definition: ProjectFileIO.h:50
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
An explicitly nonlocalized string, not meant for the user to see.
Definition: Identifier.h:22
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 &)=delete
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,...
std::unique_ptr< wxTimer > mTimer
ProjectManager & operator=(const ProjectManager &)=delete
Observer::Subscription mProjectFileIOSubscription
~ProjectManager() override
AudacityProject & mProject
Observer::Subscription mProjectStatusSubscription
ProjectManager(const ProjectManager &)=delete
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:202
void OnCloseWindow(wxCloseEvent &e)
struct holding stream options, including a pointer to the time warp info and AudioIOListener and whet...
Definition: AudioIOBase.h:46
A convenient default parameter for class template Site.
Definition: ClientData.h:29