Audacity 3.2.0
Functions | Variables
anonymous_namespace{FileMenus.cpp} Namespace Reference

Functions

void DoExport (AudacityProject &project, const FileExtension &format)
 
void DoImport (const CommandContext &context, bool isRaw)
 
void OnNew (const CommandContext &)
 
void OnOpen (const CommandContext &context)
 
void OnProjectReset (const CommandContext &context)
 
void OnClose (const CommandContext &context)
 
void OnCompact (const CommandContext &context)
 
void OnSave (const CommandContext &context)
 
void OnSaveAs (const CommandContext &context)
 
void OnSaveCopy (const CommandContext &context)
 
void OnExportMp3 (const CommandContext &context)
 
void OnExportWav (const CommandContext &context)
 
void OnExportOgg (const CommandContext &context)
 
void OnExportAudio (const CommandContext &context)
 
void OnExportLabels (const CommandContext &context)
 
void OnImport (const CommandContext &context)
 
void OnImportLabels (const CommandContext &context)
 
void OnImportRaw (const CommandContext &context)
 
void OnExit (const CommandContext &WXUNUSED(context))
 
void OnExportFLAC (const CommandContext &context)
 
auto FileMenu ()
 
auto ExtraExportMenu ()
 

Variables

AttachedItem sAttachment1 { Indirect(FileMenu()) }
 
AttachedItem sAttachment3
 

Function Documentation

◆ DoExport()

void anonymous_namespace{FileMenus.cpp}::DoExport ( AudacityProject project,
const FileExtension format 
)

Definition at line 43 of file FileMenus.cpp.

44{
45 auto &tracks = TrackList::Get( project );
46
47 wxString projectName = project.GetProjectName();
48
49 // Prompt for file name and/or extension?
50 bool bPromptingRequired = !project.mBatchMode ||
51 projectName.empty() ||
52 format.empty();
53
54 if (bPromptingRequired) {
56 {
58 XO("All audio is muted."), //":576"
59 XO("Warning"),
60 false);
61 return;
62 }
63
65 }
66 else {
67 // We either use a configured output path,
68 // or we use the default documents folder - just as for exports.
69 FilePath pathName = FileNames::FindDefaultPath(FileNames::Operation::MacrosOut);
70
71 if (!FileNames::WritableLocationCheck(pathName, XO("Cannot proceed to export.")))
72 {
73 return;
74 }
75/*
76 // If we've gotten to this point, we are in batch mode, have a file format,
77 // and the project has either been saved or a file has been imported. So, we
78 // want to use the project's path if it has been saved, otherwise use the
79 // initial import path.
80 FilePath pathName = !projectFileIO.IsTemporary() ?
81 wxPathOnly(projectFileIO.GetFileName()) :
82 project.GetInitialImportPath();
83*/
84 wxFileName fileName(pathName, projectName, format.Lower());
85
86 // Append the "macro-output" directory to the path
87 const wxString macroDir( "macro-output" );
88 if (fileName.GetDirs().empty() || fileName.GetDirs().back() != macroDir) {
89 fileName.AppendDir(macroDir);
90 }
91
92 wxString justName = fileName.GetName();
93 wxString extension = fileName.GetExt();
94 FilePath fullPath = fileName.GetFullPath();
95
96 if (wxFileName::FileExists(fileName.GetPath())) {
98 XO("Cannot create directory '%s'. \n"
99 "File already exists that is not a directory"),
100 Verbatim(fullPath));
101 return;
102 }
103 fileName.Mkdir(0777, wxPATH_MKDIR_FULL); // make sure it exists
104
105 int nChannels = tracks.Any().max(&Track::NChannels);
106 auto [plugin, formatIndex] = ExportPluginRegistry::Get().FindFormat(format);
107 if(plugin != nullptr)
108 {
109 auto editor = plugin->CreateOptionsEditor(formatIndex, nullptr);
110 editor->Load(*gPrefs);
111
112 auto builder = ExportTaskBuilder {}
115 .SetPlugin(plugin)
116 .SetFileName(fullPath)
117 .SetNumChannels(nChannels)
118 .SetRange(0.0, tracks.GetEndTime(), false);
119
120 bool success = false;
122 {
123 // We're in batch mode, the file does not exist already.
124 // We really can proceed without prompting.
125 const auto result = ExportProgressUI::Show(builder.Build(project));
126 success = result == ExportResult::Success || result == ExportResult::Stopped;
127 });
128
129 if (success && !project.mBatchMode) {
130 FileHistory::Global().Append(fullPath);
131 }
132 }
133 }
134}
int AudacityMessageBox(const TranslatableString &message, const TranslatableString &caption, long style, wxWindow *parent, int x, int y)
void ShowExportErrorDialog(const TranslatableString &message, const TranslatableString &caption, bool allowReporting)
Definition: Export.cpp:144
XO("Cut/Copy/Paste")
audacity::BasicSettings * gPrefs
Definition: Prefs.cpp:68
wxString FilePath
Definition: Project.h:21
const auto tracks
const auto project
TranslatableString Verbatim(wxString str)
Require calls to the one-argument constructor to go through this distinct global function name.
virtual size_t NChannels() const =0
Report the number of channels.
std::tuple< ExportPlugin *, int > FindFormat(const wxString &format, bool compareWithCase=false) const
Returns first pair of [exportPlugin, formatIndex], such that: exportPlugin->GetFormatInfo(formatIndex...
static ExportPluginRegistry & Get()
ExportTaskBuilder & SetPlugin(const ExportPlugin *plugin, int format=0) noexcept
Definition: Export.cpp:59
ExportTaskBuilder & SetParameters(ExportProcessor::Parameters parameters) noexcept
Definition: Export.cpp:47
ExportTaskBuilder & SetNumChannels(unsigned numChannels) noexcept
Definition: Export.cpp:53
ExportTaskBuilder & SetSampleRate(double sampleRate) noexcept
Definition: Export.cpp:72
ExportTaskBuilder & SetFileName(const wxFileName &filename)
Definition: Export.cpp:33
ExportTaskBuilder & SetRange(double t0, double t1, bool selectedOnly=false) noexcept
Definition: Export.cpp:39
static TrackIterRange< const WaveTrack > FindExportWaveTracks(const TrackList &tracks, bool selectedOnly)
Definition: ExportUtils.cpp:22
static void PerformInteractiveExport(AudacityProject &project, const FileExtension &format)
Definition: ExportUtils.cpp:71
static ExportProcessor::Parameters ParametersFromEditor(const ExportOptionsEditor &editor)
Definition: ExportUtils.cpp:32
void Append(const FilePath &file)
Definition: FileHistory.h:46
static FileHistory & Global()
Definition: FileHistory.cpp:39
static ProjectRate & Get(AudacityProject &project)
Definition: ProjectRate.cpp:28
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:314
IMPORT_EXPORT_API ExportResult Show(ExportTask exportTask)
void ExceptionWrappedCall(Callable callable)
FILES_API bool WritableLocationCheck(const FilePath &path, const TranslatableString &message)
Check location on writable access and return true if checked successfully.
FILES_API FilePath FindDefaultPath(Operation op)
double GetRate(const Track &track)
Definition: TimeTrack.cpp:182

References FileHistory::Append(), AudacityMessageBox(), ExportProgressUI::ExceptionWrappedCall(), anonymous_namespace{CloudProjectFileIOExtensions.cpp}::extension, FileNames::FindDefaultPath(), ExportUtils::FindExportWaveTracks(), ExportPluginRegistry::FindFormat(), anonymous_namespace{ExportPCM.cpp}::format, ExportPluginRegistry::Get(), ProjectRate::Get(), TrackList::Get(), anonymous_namespace{TimeTrack.cpp}::GetRate(), FileHistory::Global(), gPrefs, ChannelGroup::NChannels(), ExportUtils::ParametersFromEditor(), ExportUtils::PerformInteractiveExport(), project, ExportTaskBuilder::SetFileName(), ExportTaskBuilder::SetNumChannels(), ExportTaskBuilder::SetParameters(), ExportTaskBuilder::SetPlugin(), ExportTaskBuilder::SetRange(), ExportTaskBuilder::SetSampleRate(), ExportProgressUI::Show(), ShowExportErrorDialog(), Stopped, Success, tracks, Verbatim(), FileNames::WritableLocationCheck(), and XO().

Referenced by OnExportAudio(), OnExportFLAC(), OnExportMp3(), OnExportOgg(), and OnExportWav().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DoImport()

void anonymous_namespace{FileMenus.cpp}::DoImport ( const CommandContext context,
bool  isRaw 
)

Definition at line 136 of file FileMenus.cpp.

137{
138 auto &project = context.project;
139 auto &trackFactory = WaveTrackFactory::Get( project );
140 auto &viewport = Viewport::Get(project);
141 auto &window = GetProjectFrame(project);
142
143 auto selectedFiles = ProjectFileManager::ShowOpenDialog(FileNames::Operation::Import);
144 if (selectedFiles.size() == 0) {
146 return;
147 }
148
149 // PRL: This affects FFmpegImportPlugin::Open which resets the preference
150 // to false. Should it also be set to true on other paths that reach
151 // AudacityProject::Import ?
153
154 selectedFiles.Sort(FileNames::CompareNoCase);
155
156 auto cleanup = finally( [&] {
157
159 viewport.ZoomFitHorizontallyAndShowTrack(nullptr);
160 viewport.HandleResize(); // Adjust scrollers for NEW track sizes.
161 } );
162
163 std::vector<FilePath> filesToImport;
164 for (size_t ff = 0; ff < selectedFiles.size(); ff++) {
165 wxString fileName = selectedFiles[ff];
166
167 FileNames::UpdateDefaultPath(FileNames::Operation::Import, ::wxPathOnly(fileName));
168
169 if (isRaw) {
170 TrackHolders newTracks;
171
172 ::ImportRaw(project, &window, fileName, &trackFactory, newTracks);
173
174 if (newTracks.size() > 0) {
176 .AddImportedTracks(fileName, std::move(newTracks));
177 }
178 }
179 else
180 filesToImport.push_back(fileName);
181 }
182 if (!isRaw)
183 ProjectFileManager::Get(project).Import(filesToImport);
184}
BoolSetting NewImportingSession
Definition: Import.cpp:837
void ImportRaw(const AudacityProject &project, wxWindow *parent, const wxString &fileName, WaveTrackFactory *trackFactory, TrackHolders &outTracks)
Definition: ImportRaw.cpp:106
std::vector< std::shared_ptr< Track > > TrackHolders
Definition: ImportRaw.h:24
AUDACITY_DLL_API wxFrame & GetProjectFrame(AudacityProject &project)
Get the top-level window associated with the project (as a wxFrame only, when you do not need to use ...
AudacityProject & project
static void SetLastOpenType(const FileNames::FileType &type)
Definition: Import.cpp:253
bool Import(const std::vector< FilePath > &fileNames, bool addToHistory=true)
void AddImportedTracks(const FilePath &fileName, TrackHolders &&newTracks)
static wxArrayString ShowOpenDialog(FileNames::Operation op, const FileNames::FileType &extraType={})
Show an open dialogue for opening audio files, and possibly other sorts of files.
static ProjectFileManager & Get(AudacityProject &project)
bool Write(const T &value)
Write value to config and return true if successful.
Definition: Prefs.h:259
static Viewport & Get(AudacityProject &project)
Definition: Viewport.cpp:33
static WaveTrackFactory & Get(AudacityProject &project)
Definition: WaveTrack.cpp:3349
FILES_API void UpdateDefaultPath(Operation op, const FilePath &path)
FILES_API int CompareNoCase(const wxString &first, const wxString &second)

References ProjectFileManager::AddImportedTracks(), FileNames::CompareNoCase(), Viewport::Get(), WaveTrackFactory::Get(), ProjectFileManager::Get(), GetProjectFrame(), ProjectFileManager::Import(), ImportRaw(), NewImportingSession, CommandContext::project, project, Importer::SetLastOpenType(), ProjectFileManager::ShowOpenDialog(), FileNames::UpdateDefaultPath(), and Setting< T >::Write().

Referenced by OnImport(), and OnImportRaw().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ExtraExportMenu()

auto anonymous_namespace{FileMenus.cpp}::ExtraExportMenu ( )

Definition at line 547 of file FileMenus.cpp.

548{
549 static auto menu = std::shared_ptr{
550 Section( "Import-Export",
551 Menu( wxT("Export"), XXO("&Export"),
552 // Enable Export audio commands only when there are audio tracks.
553 Command( wxT("ExportMp3"), XXO("Export as MP&3"), OnExportMp3,
555 Command( wxT("ExportWav"), XXO("Export as &WAV"), OnExportWav,
557 Command( wxT("ExportOgg"), XXO("Export as &OGG"), OnExportOgg,
559 Command( wxT("ExportFLAC"), XXO("Export as FLAC"), OnExportFLAC,
561 ))};
562 return menu;
563}
wxT("CloseDown"))
const ReservedCommandFlag & AudioIONotBusyFlag()
const ReservedCommandFlag & WaveTracksExistFlag()
XXO("&Cut/Copy/Paste Toolbar")
constexpr auto Section
Definition: MenuRegistry.h:436
constexpr auto Command
Definition: MenuRegistry.h:456
constexpr auto Menu
Items will appear in a main toolbar menu or in a sub-menu.
Definition: MenuRegistry.h:445
void OnExportOgg(const CommandContext &context)
Definition: FileMenus.cpp:285
void OnExportFLAC(const CommandContext &context)
Definition: FileMenus.cpp:425
void OnExportWav(const CommandContext &context)
Definition: FileMenus.cpp:279
void OnExportMp3(const CommandContext &context)
Definition: FileMenus.cpp:273

References AudioIONotBusyFlag(), MenuRegistry::Command, MenuRegistry::Menu, OnExportFLAC(), OnExportMp3(), OnExportOgg(), OnExportWav(), MenuRegistry::Section, WaveTracksExistFlag(), wxT(), and XXO().

Here is the call graph for this function:

◆ FileMenu()

auto anonymous_namespace{FileMenus.cpp}::FileMenu ( )

Definition at line 434 of file FileMenus.cpp.

435{
436 static auto menu = std::shared_ptr{
437 Menu( wxT("File"), XXO("&File"),
438 Section( "Basic",
439 /*i18n-hint: "New" is an action (verb) to create a NEW project*/
440 Command( wxT("New"), XXO("&New"), OnNew,
441 AudioIONotBusyFlag(), wxT("Ctrl+N") ),
442
443 /*i18n-hint: (verb)*/
444 Command( wxT("Open"), XXO("&Open..."), OnOpen,
445 AudioIONotBusyFlag(), wxT("Ctrl+O") ),
446
447 #ifdef EXPERIMENTAL_RESET
448 // Empty the current project and forget its name and path. DANGEROUS
449 // It's just for developers.
450 // Do not translate this menu item (no XXO).
451 // It MUST not be shown to regular users.
452 Command( wxT("Reset"), XXO("&Dangerous Reset..."), OnProjectReset,
454 #endif
455
457
458 Menu( wxT("Recent"),
459 #ifdef __WXMAC__
460 /* i18n-hint: This is the name of the menu item on Mac OS X only */
461 XXO("Open Recent")
462 #else
463 /* i18n-hint: This is the name of the menu item on Windows and Linux */
464 XXO("Recent &Files")
465 #endif
466 ,
467 MenuCreator::Special( wxT("PopulateRecentFilesStep"),
468 [](AudacityProject &, wxMenu &theMenu){
469 // Recent Files and Recent Projects menus
470 auto &history = FileHistory::Global();
471 history.UseMenu( &theMenu );
472
473 wxWeakRef<wxMenu> recentFilesMenu{ &theMenu };
474 wxTheApp->CallAfter( [=] {
475 // Bug 143 workaround.
476 // The bug is in wxWidgets. For a menu that has scrollers,
477 // the scrollers have an ID of 0 (not wxID_NONE which is -3).
478 // Therefore wxWidgets attempts to find a help string. See
479 // wxFrameBase::ShowMenuHelp(int menuId)
480 // It finds a bogus automatic help string of "Recent &Files"
481 // from that submenu.
482 // So we set the help string for command with Id 0 to empty.
483 if ( recentFilesMenu )
484 recentFilesMenu->GetParent()->SetHelpString( 0, "" );
485 } );
486 } )
487 )
488 ),
489
490 Section( "Save",
491 Menu( wxT("Save"), XXO("&Save Project"),
492 Command( wxT("Save"), XXO("&Save Project"), OnSave,
493 AudioIONotBusyFlag(), wxT("Ctrl+S") ),
494 Command( wxT("SaveAs"), XXO("Save Project &As..."), OnSaveAs,
496 Command( wxT("SaveCopy"), XXO("&Backup Project..."), OnSaveCopy,
498 )//,
499
500 // Bug 2600: Compact has interactions with undo/history that are bound
501 // to confuse some users. We don't see a way to recover useful amounts
502 // of space and not confuse users using undo.
503 // As additional space used by aup3 is 50% or so, perfectly valid
504 // approach to this P1 bug is to not provide the 'Compact' menu item.
505 //Command( wxT("Compact"), XXO("Co&mpact Project"), OnCompact,
506 // AudioIONotBusyFlag(), wxT("Shift+A") )
507 ),
508
509 Section( "Close", Command( wxT("Close"), XXO("&Close"), OnClose,
510 AudioIONotBusyFlag(), wxT("Ctrl+W") )
511 ),
512
513 Section( "Import-Export",
514 Command( wxT("Export"), XXO("&Export Audio..."), OnExportAudio,
515 AudioIONotBusyFlag() | WaveTracksExistFlag(), wxT("Ctrl+Shift+E") ),
516
517 Menu( wxT("ExportOther"), XXO("Expo&rt Other"),
518 Command( wxT("ExportLabels"), XXO("Export &Labels..."),
521 ),
522
523 Menu( wxT("Import"), XXO("&Import"),
524 Command( wxT("ImportAudio"), XXO("&Audio..."), OnImport,
525 AudioIONotBusyFlag(), wxT("Ctrl+Shift+I") ),
526 Command( wxT("ImportLabels"), XXO("&Labels..."), OnImportLabels,
528 Command( wxT("ImportRaw"), XXO("&Raw Data..."), OnImportRaw,
530 )
531 ),
532
533 Section( "Exit",
534 // On the Mac, the Exit item doesn't actually go here...wxMac will
535 // pull it out
536 // and put it in the Audacity menu for us based on its ID.
537 /* i18n-hint: (verb) It's item on a menu. */
538 Command( wxT("Exit"), XXO("E&xit"), OnExit,
539 AlwaysEnabledFlag, wxT("Ctrl+Q") )
540 )
541 ) };
542 return menu;
543}
constexpr CommandFlag AlwaysEnabledFlag
Definition: CommandFlag.h:34
const ReservedCommandFlag & LabelTracksExistFlag()
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:90
static constexpr auto Special
Definition: MenuCreator.h:36
void OnNew(const CommandContext &)
Definition: FileMenus.cpp:188
void OnSaveAs(const CommandContext &context)
Definition: FileMenus.cpp:259
void OnImportLabels(const CommandContext &context)
Definition: FileMenus.cpp:366
void OnExportAudio(const CommandContext &context)
Definition: FileMenus.cpp:291
void OnSave(const CommandContext &context)
Definition: FileMenus.cpp:252
void OnImportRaw(const CommandContext &context)
Definition: FileMenus.cpp:413
void OnExportLabels(const CommandContext &context)
Definition: FileMenus.cpp:297
void OnClose(const CommandContext &context)
Definition: FileMenus.cpp:239
void OnImport(const CommandContext &context)
Definition: FileMenus.cpp:361
void OnOpen(const CommandContext &context)
Definition: FileMenus.cpp:193
void OnProjectReset(const CommandContext &context)
Definition: FileMenus.cpp:233
void OnExit(const CommandContext &WXUNUSED(context))
Definition: FileMenus.cpp:418
void OnSaveCopy(const CommandContext &context)
Definition: FileMenus.cpp:266

References AlwaysEnabledFlag, AudioIONotBusyFlag(), MenuRegistry::Command, FileHistory::Global(), LabelTracksExistFlag(), MenuRegistry::Menu, OnClose(), OnExit(), OnExportAudio(), OnExportLabels(), OnImport(), OnImportLabels(), OnImportRaw(), OnNew(), OnOpen(), OnProjectReset(), OnSave(), OnSaveAs(), OnSaveCopy(), MenuRegistry::Section, MenuCreator::Special, WaveTracksExistFlag(), wxT(), and XXO().

Here is the call graph for this function:

◆ OnClose()

void anonymous_namespace{FileMenus.cpp}::OnClose ( const CommandContext context)

Definition at line 239 of file FileMenus.cpp.

240{
241 auto &project = context.project;
242 auto &window = GetProjectFrame(project);
244 window.Close();
245}
void SetMenuClose(bool value)

References ProjectFileManager::Get(), GetProjectFrame(), CommandContext::project, project, and ProjectFileManager::SetMenuClose().

Referenced by FileMenu().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnCompact()

void anonymous_namespace{FileMenus.cpp}::OnCompact ( const CommandContext context)

Definition at line 247 of file FileMenus.cpp.

References ProjectFileManager::Compact(), ProjectFileManager::Get(), and CommandContext::project.

Here is the call graph for this function:

◆ OnExit()

void anonymous_namespace{FileMenus.cpp}::OnExit ( const CommandContext WXUNUSEDcontext)

Definition at line 418 of file FileMenus.cpp.

419{
420 // Simulate the application Exit menu item
421 wxCommandEvent evt{ wxEVT_MENU, wxID_EXIT };
422 wxTheApp->ProcessEvent( evt );
423}

Referenced by FileMenu().

Here is the caller graph for this function:

◆ OnExportAudio()

void anonymous_namespace{FileMenus.cpp}::OnExportAudio ( const CommandContext context)

Definition at line 291 of file FileMenus.cpp.

292{
293 auto &project = context.project;
294 DoExport(project, "");
295}
void DoExport(AudacityProject &project, const FileExtension &format)
Definition: FileMenus.cpp:43

References DoExport(), CommandContext::project, and project.

Referenced by FileMenu().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnExportFLAC()

void anonymous_namespace{FileMenus.cpp}::OnExportFLAC ( const CommandContext context)

Definition at line 425 of file FileMenus.cpp.

426{
427 DoExport(context.project, "FLAC");
428}

References DoExport(), and CommandContext::project.

Referenced by ExtraExportMenu().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnExportLabels()

void anonymous_namespace{FileMenus.cpp}::OnExportLabels ( const CommandContext context)

Definition at line 297 of file FileMenus.cpp.

298{
299 auto &project = context.project;
300 auto &tracks = TrackList::Get( project );
301 auto &window = GetProjectFrame(project);
302
303 /* i18n-hint: filename containing exported text from label tracks */
304 wxString fName = _("labels.txt");
305 auto trackRange = tracks.Any<const LabelTrack>();
306 auto numLabelTracks = trackRange.size();
307
308 if (numLabelTracks == 0) {
309 AudacityMessageBox( XO("There are no label tracks to export.") );
310 return;
311 }
312 else
313 fName = (*trackRange.rbegin())->GetName();
314
315 fName = SelectFile(FileNames::Operation::Export,
316 XO("Export Labels As:"),
317 wxEmptyString,
318 fName,
319 wxT("txt"),
321 wxFD_SAVE | wxFD_OVERWRITE_PROMPT | wxRESIZE_BORDER,
322 &window);
323
324 if (fName.empty())
325 return;
326
328
329 // Move existing files out of the way. Otherwise wxTextFile will
330 // append to (rather than replace) the current file.
331
332 if (wxFileExists(fName)) {
333#ifdef __WXGTK__
334 wxString safetyFileName = fName + wxT("~");
335#else
336 wxString safetyFileName = fName + wxT(".bak");
337#endif
338
339 if (wxFileExists(safetyFileName))
340 wxRemoveFile(safetyFileName);
341
342 wxRename(fName, safetyFileName);
343 }
344
345 wxTextFile f(fName);
346 f.Create();
347 f.Open();
348 if (!f.IsOpened()) {
350 XO( "Couldn't write to file: %s" ).Format( fName ) );
351 return;
352 }
353
354 for (auto lt : trackRange)
355 lt->Export(f, format);
356
357 f.Write();
358 f.Close();
359}
#define _(s)
Definition: Internat.h:73
LabelFormat
Definition: LabelTrack.h:30
FilePath SelectFile(FileNames::Operation op, const TranslatableString &message, const FilePath &default_path, const FilePath &default_filename, const FileExtension &default_extension, const FileTypes &fileTypes, int flags, wxWindow *parent)
Definition: SelectFile.cpp:17
size_t size() const
How many attachment pointers are in the Site.
Definition: ClientData.h:260
FILES_API const FileType TextFiles
Definition: FileNames.h:73
Abstract base class used in importing a file.
A LabelTrack is a Track that holds labels (LabelStruct).
Definition: LabelTrack.h:95
static const FileNames::FileType WebVTTFiles
Definition: LabelTrack.h:128
static const FileNames::FileType SubripFiles
Definition: LabelTrack.h:127
static LabelFormat FormatForFileName(const wxString &fileName)
Definition: LabelTrack.cpp:704

References _, AudacityMessageBox(), anonymous_namespace{ExportPCM.cpp}::format, LabelTrack::FormatForFileName(), TrackList::Get(), GetProjectFrame(), CommandContext::project, project, SelectFile(), ClientData::Site< Host, ClientData, ObjectCopyingPolicy, Pointer, ObjectLockingPolicy, RegistryLockingPolicy >::size(), LabelTrack::SubripFiles, FileNames::TextFiles, tracks, LabelTrack::WebVTTFiles, wxT(), and XO().

Referenced by FileMenu().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnExportMp3()

void anonymous_namespace{FileMenus.cpp}::OnExportMp3 ( const CommandContext context)

Definition at line 273 of file FileMenus.cpp.

274{
275 auto &project = context.project;
276 DoExport(project, "MP3");
277}

References DoExport(), CommandContext::project, and project.

Referenced by ExtraExportMenu().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnExportOgg()

void anonymous_namespace{FileMenus.cpp}::OnExportOgg ( const CommandContext context)

Definition at line 285 of file FileMenus.cpp.

286{
287 auto &project = context.project;
288 DoExport(project, "OGG");
289}

References DoExport(), CommandContext::project, and project.

Referenced by ExtraExportMenu().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnExportWav()

void anonymous_namespace{FileMenus.cpp}::OnExportWav ( const CommandContext context)

Definition at line 279 of file FileMenus.cpp.

280{
281 auto &project = context.project;
282 DoExport(project, "WAV");
283}

References DoExport(), CommandContext::project, and project.

Referenced by ExtraExportMenu().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnImport()

void anonymous_namespace{FileMenus.cpp}::OnImport ( const CommandContext context)

Definition at line 361 of file FileMenus.cpp.

362{
363 DoImport(context, false);
364}
void DoImport(const CommandContext &context, bool isRaw)
Definition: FileMenus.cpp:136

References DoImport().

Referenced by FileMenu().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnImportLabels()

void anonymous_namespace{FileMenus.cpp}::OnImportLabels ( const CommandContext context)

Definition at line 366 of file FileMenus.cpp.

367{
368 auto &project = context.project;
369 auto &tracks = TrackList::Get( project );
370 auto &viewport = Viewport::Get(project);
371 auto &window = GetProjectFrame(project);
372
373 wxString fileName =
374 SelectFile(FileNames::Operation::Open,
375 XO("Select a text file containing labels"),
376 wxEmptyString, // Path
377 wxT(""), // Name
378 wxT("txt"), // Extension
380 wxRESIZE_BORDER, // Flags
381 &window); // Parent
382
383 if (!fileName.empty()) {
385 wxTextFile f;
386
387 f.Open(fileName);
388 if (!f.IsOpened()) {
390 XO("Could not open file: %s").Format( fileName ) );
391 return;
392 }
393
394 auto newTrack = std::make_shared<LabelTrack>();
395 wxString sTrackName;
396 wxFileName::SplitPath(fileName, NULL, NULL, &sTrackName, NULL);
397 newTrack->SetName(sTrackName);
398
399 newTrack->Import(f, format);
400
402 newTrack->SetSelected(true);
403 tracks.Add( newTrack );
404
406 XO("Imported labels from '%s'").Format( fileName ),
407 XO("Import Labels"));
408
409 viewport.ZoomFitHorizontallyAndShowTrack(nullptr);
410 }
411}
FILES_API const FileType AllFiles
Definition: FileNames.h:70
void PushState(const TranslatableString &desc, const TranslatableString &shortDesc)
static ProjectHistory & Get(AudacityProject &project)
void SelectNone(AudacityProject &project)

References FileNames::AllFiles, AudacityMessageBox(), anonymous_namespace{ExportPCM.cpp}::format, LabelTrack::FormatForFileName(), ProjectHistory::Get(), TrackList::Get(), Viewport::Get(), GetProjectFrame(), CommandContext::project, project, ProjectHistory::PushState(), SelectFile(), SelectUtilities::SelectNone(), LabelTrack::SubripFiles, FileNames::TextFiles, tracks, wxT(), and XO().

Referenced by FileMenu().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnImportRaw()

void anonymous_namespace{FileMenus.cpp}::OnImportRaw ( const CommandContext context)

Definition at line 413 of file FileMenus.cpp.

414{
415 DoImport(context, true);
416}

References DoImport().

Referenced by FileMenu().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnNew()

void anonymous_namespace{FileMenus.cpp}::OnNew ( const CommandContext )

Definition at line 188 of file FileMenus.cpp.

189{
190 ( void ) ProjectManager::New();
191}
static AudacityProject * New()

References ProjectManager::New().

Referenced by FileMenu().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnOpen()

void anonymous_namespace{FileMenus.cpp}::OnOpen ( const CommandContext context)

Definition at line 193 of file FileMenus.cpp.

194{
195 auto &project = context.project;
197
198 int unavailablePlugins = 0;
199
200 auto &trackList = TrackList::Get(project);
201 for (auto track : trackList.Any<WaveTrack>())
202 {
203 auto& effects = RealtimeEffectList::Get(*track);
204 effects.Visit([&unavailablePlugins](auto& state, bool)
205 {
206 const auto& ID = state.GetID();
208
209 if (plug)
210 {
212 unavailablePlugins++;
213 }
214 else
215 {
216 unavailablePlugins++;
217 }
218 });
219 }
220
221 if (unavailablePlugins > 0)
222 {
223 MissingPluginsErrorDialog dlg(nullptr);
224 dlg.ShowModal();
225 }
226}
An error dialog about missing plugins.
static bool IsPluginAvailable(const PluginDescriptor &plug)
const PluginDescriptor * GetPlugin(const PluginID &ID) const
static PluginManager & Get()
static void OpenFiles(AudacityProject *proj)
static RealtimeEffectList & Get(AudacityProject &project)
A Track that contains audio waveform data.
Definition: WaveTrack.h:203

References PluginManager::Get(), RealtimeEffectList::Get(), TrackList::Get(), PluginManager::GetPlugin(), PluginManager::IsPluginAvailable(), ProjectManager::OpenFiles(), CommandContext::project, and project.

Referenced by FileMenu(), and anonymous_namespace{ExportFFmpeg.cpp}::ExportOptionsFFmpegCustomEditor::PopulateUI().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnProjectReset()

void anonymous_namespace{FileMenus.cpp}::OnProjectReset ( const CommandContext context)

Definition at line 233 of file FileMenus.cpp.

234{
235 auto &project = context.project;
237}
static ProjectManager & Get(AudacityProject &project)
void ResetProjectToEmpty()

References ProjectManager::Get(), CommandContext::project, project, and ProjectManager::ResetProjectToEmpty().

Referenced by FileMenu().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnSave()

void anonymous_namespace{FileMenus.cpp}::OnSave ( const CommandContext context)

Definition at line 252 of file FileMenus.cpp.

253{
254 auto &project = context.project;
255 auto &projectFileManager = ProjectFileManager::Get( project );
256 projectFileManager.Save();
257}

References ProjectFileManager::Get(), CommandContext::project, and project.

Referenced by FileMenu(), and audacity::cloud::audiocom::sync::ProjectCloudUIExtension::OnCloudStatusChanged().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnSaveAs()

void anonymous_namespace{FileMenus.cpp}::OnSaveAs ( const CommandContext context)

Definition at line 259 of file FileMenus.cpp.

260{
261 auto &project = context.project;
262 auto &projectFileManager = ProjectFileManager::Get( project );
263 projectFileManager.SaveAs();
264}

References ProjectFileManager::Get(), CommandContext::project, and project.

Referenced by FileMenu().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnSaveCopy()

void anonymous_namespace{FileMenus.cpp}::OnSaveCopy ( const CommandContext context)

Definition at line 266 of file FileMenus.cpp.

267{
268 auto &project = context.project;
269 auto &projectFileManager = ProjectFileManager::Get( project );
270 projectFileManager.SaveCopy();
271}

References ProjectFileManager::Get(), CommandContext::project, and project.

Referenced by FileMenu().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ sAttachment1

AttachedItem anonymous_namespace{FileMenus.cpp}::sAttachment1 { Indirect(FileMenu()) }

Definition at line 545 of file FileMenus.cpp.

◆ sAttachment3

AttachedItem anonymous_namespace{FileMenus.cpp}::sAttachment3
Initial value:
{
wxT("Optional/Extra/Part1")
}
std::unique_ptr< detail::IndirectItem< Item > > Indirect(const std::shared_ptr< Item > &ptr)
A convenience function.
Definition: Registry.h:175

Definition at line 565 of file FileMenus.cpp.