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 44 of file FileMenus.cpp.

45{
46 auto &tracks = TrackList::Get( project );
47
48 wxString projectName = project.GetProjectName();
49
50 // Prompt for file name and/or extension?
51 bool bPromptingRequired = !project.mBatchMode ||
52 projectName.empty() ||
53 format.empty();
54
55 if (bPromptingRequired) {
57 {
59 XO("All audio is muted."), //":576"
60 XO("Warning"),
61 false);
62 return;
63 }
65 project,
66 project.GetProjectName(),
67 format);
68 dialog.ShowModal();
69 }
70 else {
71 // We either use a configured output path,
72 // or we use the default documents folder - just as for exports.
73 FilePath pathName = FileNames::FindDefaultPath(FileNames::Operation::MacrosOut);
74
75 if (!FileNames::WritableLocationCheck(pathName, XO("Cannot proceed to export.")))
76 {
77 return;
78 }
79/*
80 // If we've gotten to this point, we are in batch mode, have a file format,
81 // and the project has either been saved or a file has been imported. So, we
82 // want to use the project's path if it has been saved, otherwise use the
83 // initial import path.
84 FilePath pathName = !projectFileIO.IsTemporary() ?
85 wxPathOnly(projectFileIO.GetFileName()) :
86 project.GetInitialImportPath();
87*/
88 wxFileName fileName(pathName, projectName, format.Lower());
89
90 // Append the "macro-output" directory to the path
91 const wxString macroDir( "macro-output" );
92 if (fileName.GetDirs().empty() || fileName.GetDirs().back() != macroDir) {
93 fileName.AppendDir(macroDir);
94 }
95
96 wxString justName = fileName.GetName();
97 wxString extension = fileName.GetExt();
98 FilePath fullPath = fileName.GetFullPath();
99
100 if (wxFileName::FileExists(fileName.GetPath())) {
102 XO("Cannot create directory '%s'. \n"
103 "File already exists that is not a directory"),
104 Verbatim(fullPath));
105 return;
106 }
107 fileName.Mkdir(0777, wxPATH_MKDIR_FULL); // make sure it exists
108
109 int nChannels = tracks.Any().max(&Track::NChannels);
110 auto [plugin, formatIndex] = ExportPluginRegistry::Get().FindFormat(format);
111 if(plugin != nullptr)
112 {
113 auto editor = plugin->CreateOptionsEditor(formatIndex, nullptr);
114 editor->Load(*gPrefs);
115
116 auto builder = ExportTaskBuilder {}
119 .SetPlugin(plugin)
120 .SetFileName(fullPath)
121 .SetNumChannels(nChannels)
122 .SetRange(0.0, tracks.GetEndTime(), false);
123
124 bool success = false;
126 {
127 // We're in batch mode, the file does not exist already.
128 // We really can proceed without prompting.
129 const auto result = ExportProgressUI::Show(builder.Build(project));
130 success = result == ExportResult::Success || result == ExportResult::Stopped;
131 });
132
133 if (success && !project.mBatchMode) {
134 FileHistory::Global().Append(fullPath);
135 }
136 }
137 }
138}
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
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 ...
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:18
static ExportProcessor::Parameters ParametersFromEditor(const ExportOptionsEditor &editor)
Definition: ExportUtils.cpp:28
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:347
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:196

References FileHistory::Append(), AudacityMessageBox(), ExportProgressUI::ExceptionWrappedCall(), FileNames::FindDefaultPath(), ExportUtils::FindExportWaveTracks(), ExportPluginRegistry::FindFormat(), anonymous_namespace{ExportPCM.cpp}::format, ExportPluginRegistry::Get(), ProjectRate::Get(), TrackList::Get(), GetProjectFrame(), anonymous_namespace{TimeTrack.cpp}::GetRate(), FileHistory::Global(), gPrefs, ChannelGroup::NChannels(), ExportUtils::ParametersFromEditor(), 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 140 of file FileMenus.cpp.

141{
142 auto &project = context.project;
143 auto &trackFactory = WaveTrackFactory::Get( project );
144 auto &viewport = Viewport::Get(project);
145 auto &window = GetProjectFrame(project);
146
147 auto selectedFiles = ProjectFileManager::ShowOpenDialog(FileNames::Operation::Import);
148 if (selectedFiles.size() == 0) {
150 return;
151 }
152
153 // PRL: This affects FFmpegImportPlugin::Open which resets the preference
154 // to false. Should it also be set to true on other paths that reach
155 // AudacityProject::Import ?
157
158 selectedFiles.Sort(FileNames::CompareNoCase);
159
160 auto cleanup = finally( [&] {
161
163 viewport.ZoomFitHorizontallyAndShowTrack(nullptr);
164 viewport.HandleResize(); // Adjust scrollers for NEW track sizes.
165 } );
166
167 std::vector<FilePath> filesToImport;
168 for (size_t ff = 0; ff < selectedFiles.size(); ff++) {
169 wxString fileName = selectedFiles[ff];
170
171 FileNames::UpdateDefaultPath(FileNames::Operation::Import, ::wxPathOnly(fileName));
172
173 if (isRaw) {
174 TrackHolders newTracks;
175
176 ::ImportRaw(project, &window, fileName, &trackFactory, newTracks);
177
178 if (newTracks.size() > 0) {
180 .AddImportedTracks(fileName, std::move(newTracks));
181 }
182 }
183 else
184 filesToImport.push_back(fileName);
185 }
186 if (!isRaw)
187 ProjectFileManager::Get(project).Import(filesToImport);
188}
BoolSetting NewImportingSession
Definition: Import.cpp:846
void ImportRaw(const AudacityProject &project, wxWindow *parent, const wxString &fileName, WaveTrackFactory *trackFactory, TrackHolders &outTracks)
Definition: ImportRaw.cpp:106
std::vector< std::shared_ptr< TrackList > > TrackHolders
Definition: ImportRaw.h:24
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:32
static WaveTrackFactory & Get(AudacityProject &project)
Definition: WaveTrack.cpp:4516
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 550 of file FileMenus.cpp.

551{
552 static auto menu = std::shared_ptr{
553 Section( "Import-Export",
554 Menu( wxT("Export"), XXO("&Export"),
555 // Enable Export audio commands only when there are audio tracks.
556 Command( wxT("ExportMp3"), XXO("Export as MP&3"), OnExportMp3,
558 Command( wxT("ExportWav"), XXO("Export as &WAV"), OnExportWav,
560 Command( wxT("ExportOgg"), XXO("Export as &OGG"), OnExportOgg,
562 Command( wxT("ExportFLAC"), XXO("Export as FLAC"), OnExportFLAC,
564 ))};
565 return menu;
566}
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:289
void OnExportFLAC(const CommandContext &context)
Definition: FileMenus.cpp:427
void OnExportWav(const CommandContext &context)
Definition: FileMenus.cpp:283
void OnExportMp3(const CommandContext &context)
Definition: FileMenus.cpp:277

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 436 of file FileMenus.cpp.

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

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 243 of file FileMenus.cpp.

244{
245 auto &project = context.project;
246 auto &window = GetProjectFrame(project);
248 window.Close();
249}
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 251 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 420 of file FileMenus.cpp.

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

Referenced by FileMenu().

Here is the caller graph for this function:

◆ OnExportAudio()

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

Definition at line 295 of file FileMenus.cpp.

296{
297 auto &project = context.project;
298 DoExport(project, "");
299}
void DoExport(AudacityProject &project, const FileExtension &format)
Definition: FileMenus.cpp:44

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 427 of file FileMenus.cpp.

428{
429 DoExport(context.project, "FLAC");
430}

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 301 of file FileMenus.cpp.

302{
303 auto &project = context.project;
304 auto &tracks = TrackList::Get( project );
305 auto &window = GetProjectFrame(project);
306
307 /* i18n-hint: filename containing exported text from label tracks */
308 wxString fName = _("labels.txt");
309 auto trackRange = tracks.Any<const LabelTrack>();
310 auto numLabelTracks = trackRange.size();
311
312 if (numLabelTracks == 0) {
313 AudacityMessageBox( XO("There are no label tracks to export.") );
314 return;
315 }
316 else
317 fName = (*trackRange.rbegin())->GetName();
318
319 fName = SelectFile(FileNames::Operation::Export,
320 XO("Export Labels As:"),
321 wxEmptyString,
322 fName,
323 wxT("txt"),
325 wxFD_SAVE | wxFD_OVERWRITE_PROMPT | wxRESIZE_BORDER,
326 &window);
327
328 if (fName.empty())
329 return;
330
331 // Move existing files out of the way. Otherwise wxTextFile will
332 // append to (rather than replace) the current file.
333
334 if (wxFileExists(fName)) {
335#ifdef __WXGTK__
336 wxString safetyFileName = fName + wxT("~");
337#else
338 wxString safetyFileName = fName + wxT(".bak");
339#endif
340
341 if (wxFileExists(safetyFileName))
342 wxRemoveFile(safetyFileName);
343
344 wxRename(fName, safetyFileName);
345 }
346
347 wxTextFile f(fName);
348 f.Create();
349 f.Open();
350 if (!f.IsOpened()) {
352 XO( "Couldn't write to file: %s" ).Format( fName ) );
353 return;
354 }
355
356 for (auto lt : trackRange)
357 lt->Export(f);
358
359 f.Write();
360 f.Close();
361}
#define _(s)
Definition: Internat.h:73
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:259
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:87

References _, AudacityMessageBox(), TrackList::Get(), GetProjectFrame(), CommandContext::project, project, SelectFile(), ClientData::Site< Host, ClientData, ObjectCopyingPolicy, Pointer, ObjectLockingPolicy, RegistryLockingPolicy >::size(), 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:

◆ OnExportMp3()

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

Definition at line 277 of file FileMenus.cpp.

278{
279 auto &project = context.project;
280 DoExport(project, "MP3");
281}

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 289 of file FileMenus.cpp.

290{
291 auto &project = context.project;
292 DoExport(project, "OGG");
293}

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 283 of file FileMenus.cpp.

284{
285 auto &project = context.project;
286 DoExport(project, "WAV");
287}

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 363 of file FileMenus.cpp.

364{
365 DoImport(context, false);
366}
void DoImport(const CommandContext &context, bool isRaw)
Definition: FileMenus.cpp:140

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 368 of file FileMenus.cpp.

369{
370 auto &project = context.project;
371 auto &trackFactory = WaveTrackFactory::Get( project );
372 auto &tracks = TrackList::Get( project );
373 auto &viewport = Viewport::Get(project);
374 auto &window = GetProjectFrame(project);
375
376 wxString fileName =
377 SelectFile(FileNames::Operation::Open,
378 XO("Select a text file containing labels"),
379 wxEmptyString, // Path
380 wxT(""), // Name
381 wxT("txt"), // Extension
383 wxRESIZE_BORDER, // Flags
384 &window); // Parent
385
386 if (!fileName.empty()) {
387 wxTextFile f;
388
389 f.Open(fileName);
390 if (!f.IsOpened()) {
392 XO("Could not open file: %s").Format( fileName ) );
393 return;
394 }
395
396 auto newTrack = std::make_shared<LabelTrack>();
397 wxString sTrackName;
398 wxFileName::SplitPath(fileName, NULL, NULL, &sTrackName, NULL);
399 newTrack->SetName(sTrackName);
400
401 newTrack->Import(f);
402
404 newTrack->SetSelected(true);
405 tracks.Add( newTrack );
406
408 XO("Imported labels from '%s'").Format( fileName ),
409 XO("Import Labels"));
410
411 viewport.ZoomFitHorizontallyAndShowTrack(nullptr);
412 }
413}
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(), ProjectHistory::Get(), TrackList::Get(), Viewport::Get(), WaveTrackFactory::Get(), GetProjectFrame(), CommandContext::project, project, ProjectHistory::PushState(), SelectFile(), SelectUtilities::SelectNone(), 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 415 of file FileMenus.cpp.

416{
417 DoImport(context, true);
418}

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 192 of file FileMenus.cpp.

193{
194 ( void ) ProjectManager::New();
195}
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 197 of file FileMenus.cpp.

198{
199 auto &project = context.project;
201
202 int unavailablePlugins = 0;
203
204 auto &trackList = TrackList::Get(project);
205 for (auto track : trackList.Any<WaveTrack>())
206 {
207 auto& effects = RealtimeEffectList::Get(*track);
208 effects.Visit([&unavailablePlugins](auto& state, bool)
209 {
210 const auto& ID = state.GetID();
212
213 if (plug)
214 {
216 unavailablePlugins++;
217 }
218 else
219 {
220 unavailablePlugins++;
221 }
222 });
223 }
224
225 if (unavailablePlugins > 0)
226 {
227 MissingPluginsErrorDialog dlg(nullptr);
228 dlg.ShowModal();
229 }
230}
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:227

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 237 of file FileMenus.cpp.

238{
239 auto &project = context.project;
241}
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 256 of file FileMenus.cpp.

257{
258 auto &project = context.project;
259 auto &projectFileManager = ProjectFileManager::Get( project );
260 projectFileManager.Save();
261}

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:

◆ OnSaveAs()

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

Definition at line 263 of file FileMenus.cpp.

264{
265 auto &project = context.project;
266 auto &projectFileManager = ProjectFileManager::Get( project );
267 projectFileManager.SaveAs();
268}

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 270 of file FileMenus.cpp.

271{
272 auto &project = context.project;
273 auto &projectFileManager = ProjectFileManager::Get( project );
274 projectFileManager.SaveCopy();
275}

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 548 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 568 of file FileMenus.cpp.