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 OnExportSelection (const CommandContext &context)
 
void OnExportLabels (const CommandContext &context)
 
void OnExportMultiple (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)
 
BaseItemSharedPtr FileMenu ()
 
BaseItemSharedPtr HiddenFileMenu ()
 

Variables

AttachedItem sAttachment1
 
AttachedItem sAttachment2
 

Function Documentation

◆ DoExport()

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

Definition at line 35 of file FileMenus.cpp.

36{
37 auto &tracks = TrackList::Get( project );
38
39 Exporter e{ project };
40
41 double t0 = 0.0;
42 double t1 = tracks.GetEndTime();
43 wxString projectName = project.GetProjectName();
44
45 // Prompt for file name and/or extension?
46 bool bPromptingRequired = !project.mBatchMode ||
47 projectName.empty() ||
48 format.empty();
49
50 bool success = false;
51 if (bPromptingRequired) {
52 // Do export with prompting.
53 e.SetDefaultFormat(format);
54 success = e.Process(false, t0, t1);
55 }
56 else {
57 // We either use a configured output path,
58 // or we use the default documents folder - just as for exports.
59 FilePath pathName = FileNames::FindDefaultPath(FileNames::Operation::MacrosOut);
60
61 if (!FileNames::WritableLocationCheck(pathName, XO("Cannot proceed to export.")))
62 {
63 return;
64 }
65/*
66 // If we've gotten to this point, we are in batch mode, have a file format,
67 // and the project has either been saved or a file has been imported. So, we
68 // want to use the project's path if it has been saved, otherwise use the
69 // initial import path.
70 FilePath pathName = !projectFileIO.IsTemporary() ?
71 wxPathOnly(projectFileIO.GetFileName()) :
72 project.GetInitialImportPath();
73*/
74 wxFileName fileName(pathName, projectName, format.Lower());
75
76 // Append the "macro-output" directory to the path
77 const wxString macroDir( "macro-output" );
78 if (fileName.GetDirs().back() != macroDir) {
79 fileName.AppendDir(macroDir);
80 }
81
82 wxString justName = fileName.GetName();
83 wxString extension = fileName.GetExt();
84 FilePath fullPath = fileName.GetFullPath();
85
86 if (wxFileName::FileExists(fileName.GetPath())) {
88 XO("Cannot create directory '%s'. \n"
89 "File already exists that is not a directory"),
90 Verbatim(fullPath));
91 return;
92 }
93 fileName.Mkdir(0777, wxPATH_MKDIR_FULL); // make sure it exists
94
95 int nChannels = (tracks.Any() - &Track::IsLeader ).empty() ? 1 : 2;
96
97 // We're in batch mode, the file does not exist already.
98 // We really can proceed without prompting.
99 success = e.Process(
100 nChannels, // numChannels,
101 format, // type,
102 fullPath, // full path,
103 false, // selectedOnly,
104 t0, // t0
105 t1 // t1
106 );
107 }
108
109 if (success && !project.mBatchMode) {
110 FileHistory::Global().Append(e.GetAutoExportFileName().GetFullPath());
111 }
112}
int AudacityMessageBox(const TranslatableString &message, const TranslatableString &caption, long style, wxWindow *parent, int x, int y)
int format
Definition: ExportPCM.cpp:53
XO("Cut/Copy/Paste")
wxString FilePath
Definition: Project.h:21
TranslatableString Verbatim(wxString str)
Require calls to the one-argument constructor to go through this distinct global function name.
const wxString & GetProjectName() const
Definition: Project.cpp:100
void Append(const FilePath &file)
Definition: FileHistory.h:42
static FileHistory & Global()
Definition: FileHistory.cpp:37
bool IsLeader() const
Definition: Track.cpp:305
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:385
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)

References FileHistory::Append(), AudacityMessageBox(), FileNames::FindDefaultPath(), format, TrackList::Get(), AudacityProject::GetProjectName(), FileHistory::Global(), Track::IsLeader(), AudacityProject::mBatchMode, 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 114 of file FileMenus.cpp.

115{
116 auto &project = context.project;
117 auto &trackFactory = WaveTrackFactory::Get( project );
118 auto &window = ProjectWindow::Get( project );
119
120 auto selectedFiles = ProjectFileManager::ShowOpenDialog(FileNames::Operation::Import);
121 if (selectedFiles.size() == 0) {
123 return;
124 }
125
126 // PRL: This affects FFmpegImportPlugin::Open which resets the preference
127 // to false. Should it also be set to true on other paths that reach
128 // AudacityProject::Import ?
130
131 selectedFiles.Sort(FileNames::CompareNoCase);
132
133 auto cleanup = finally( [&] {
134
136 window.ZoomAfterImport(nullptr);
137 window.HandleResize(); // Adjust scrollers for NEW track sizes.
138 } );
139
140 for (size_t ff = 0; ff < selectedFiles.size(); ff++) {
141 wxString fileName = selectedFiles[ff];
142
143 FileNames::UpdateDefaultPath(FileNames::Operation::Import, ::wxPathOnly(fileName));
144
145 if (isRaw) {
146 TrackHolders newTracks;
147
148 ::ImportRaw(project, &window, fileName, &trackFactory, newTracks);
149
150 if (newTracks.size() > 0) {
151 ProjectFileManager::Get( project )
152 .AddImportedTracks(fileName, std::move(newTracks));
153 }
154 }
155 else {
156 ProjectFileManager::Get( project ).Import(fileName);
157 }
158 }
159}
BoolSetting NewImportingSession
Definition: Import.cpp:899
std::vector< std::vector< std::shared_ptr< WaveTrack > > > TrackHolders
Definition: Import.h:39
void ImportRaw(const AudacityProject &project, wxWindow *parent, const wxString &fileName, WaveTrackFactory *trackFactory, TrackHolders &outTracks)
Definition: ImportRaw.cpp:105
AudacityProject & project
static void SetLastOpenType(const FileNames::FileType &type)
Definition: Import.cpp:224
bool Import(const FilePath &fileName, 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)
static ProjectWindow & Get(AudacityProject &project)
bool Write(const T &value)
Write value to config and return true if successful.
Definition: Prefs.h:252
static WaveTrackFactory & Get(AudacityProject &project)
Definition: WaveTrack.cpp:2606
FILES_API void UpdateDefaultPath(Operation op, const FilePath &path)
FILES_API int CompareNoCase(const wxString &first, const wxString &second)

References ProjectFileManager::AddImportedTracks(), FileNames::CompareNoCase(), WaveTrackFactory::Get(), ProjectFileManager::Get(), ProjectWindow::Get(), ProjectFileManager::Import(), ImportRaw(), NewImportingSession, CommandContext::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:

◆ FileMenu()

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

Definition at line 425 of file FileMenus.cpp.

426{
428
429 static BaseItemSharedPtr menu{
430 Menu( wxT("File"), XXO("&File"),
431 Section( "Basic",
432 /*i18n-hint: "New" is an action (verb) to create a NEW project*/
433 Command( wxT("New"), XXO("&New"), OnNew,
434 AudioIONotBusyFlag(), wxT("Ctrl+N") ),
435
436 /*i18n-hint: (verb)*/
437 Command( wxT("Open"), XXO("&Open..."), OnOpen,
438 AudioIONotBusyFlag(), wxT("Ctrl+O") ),
439
440 #ifdef EXPERIMENTAL_RESET
441 // Empty the current project and forget its name and path. DANGEROUS
442 // It's just for developers.
443 // Do not translate this menu item (no XXO).
444 // It MUST not be shown to regular users.
445 Command( wxT("Reset"), XXO("&Dangerous Reset..."), OnProjectReset,
447 #endif
448
450
451 Menu( wxT("Recent"),
452 #ifdef __WXMAC__
453 /* i18n-hint: This is the name of the menu item on Mac OS X only */
454 XXO("Open Recent")
455 #else
456 /* i18n-hint: This is the name of the menu item on Windows and Linux */
457 XXO("Recent &Files")
458 #endif
459 ,
460 Special( wxT("PopulateRecentFilesStep"),
461 [](AudacityProject &, wxMenu &theMenu){
462 // Recent Files and Recent Projects menus
463 auto &history = FileHistory::Global();
464 history.UseMenu( &theMenu );
465
466 wxWeakRef<wxMenu> recentFilesMenu{ &theMenu };
467 wxTheApp->CallAfter( [=] {
468 // Bug 143 workaround.
469 // The bug is in wxWidgets. For a menu that has scrollers,
470 // the scrollers have an ID of 0 (not wxID_NONE which is -3).
471 // Therefore wxWidgets attempts to find a help string. See
472 // wxFrameBase::ShowMenuHelp(int menuId)
473 // It finds a bogus automatic help string of "Recent &Files"
474 // from that submenu.
475 // So we set the help string for command with Id 0 to empty.
476 if ( recentFilesMenu )
477 recentFilesMenu->GetParent()->SetHelpString( 0, "" );
478 } );
479 } )
480 ),
481
483
484 Command( wxT("Close"), XXO("&Close"), OnClose,
485 AudioIONotBusyFlag(), wxT("Ctrl+W") )
486 ),
487
488 Section( "Save",
489 Menu( wxT("Save"), XXO("&Save Project"),
490 Command( wxT("Save"), XXO("&Save Project"), OnSave,
491 AudioIONotBusyFlag(), wxT("Ctrl+S") ),
492 Command( wxT("SaveAs"), XXO("Save Project &As..."), OnSaveAs,
494 Command( wxT("SaveCopy"), XXO("&Backup Project..."), OnSaveCopy,
496 )//,
497
498 // Bug 2600: Compact has interactions with undo/history that are bound
499 // to confuse some users. We don't see a way to recover useful amounts
500 // of space and not confuse users using undo.
501 // As additional space used by aup3 is 50% or so, perfectly valid
502 // approach to this P1 bug is to not provide the 'Compact' menu item.
503 //Command( wxT("Compact"), XXO("Co&mpact Project"), OnCompact,
504 // AudioIONotBusyFlag(), wxT("Shift+A") )
505 ),
506
507 Section( "Import-Export",
508 Menu( wxT("Export"), XXO("&Export"),
509 // Enable Export audio commands only when there are audio tracks.
510 Command( wxT("ExportMp3"), XXO("Export as MP&3"), OnExportMp3,
512
513 Command( wxT("ExportWav"), XXO("Export as &WAV"), OnExportWav,
515
516 Command( wxT("ExportOgg"), XXO("Export as &OGG"), OnExportOgg,
518
519 Command( wxT("Export"), XXO("&Export Audio..."), OnExportAudio,
520 AudioIONotBusyFlag() | WaveTracksExistFlag(), wxT("Ctrl+Shift+E") ),
521
522 // Enable Export Selection commands only when there's a selection.
523 Command( wxT("ExportSel"), XXO("Expo&rt Selected Audio..."),
526
527 Command( wxT("ExportLabels"), XXO("Export &Labels..."),
530 // Enable Export audio commands only when there are audio tracks.
531 Command( wxT("ExportMultiple"), XXO("Export &Multiple..."),
533 AudioIONotBusyFlag() | WaveTracksExistFlag(), wxT("Ctrl+Shift+L") )
534 ),
535
536 Menu( wxT("Import"), XXO("&Import"),
537 Command( wxT("ImportAudio"), XXO("&Audio..."), OnImport,
538 AudioIONotBusyFlag(), wxT("Ctrl+Shift+I") ),
539 Command( wxT("ImportLabels"), XXO("&Labels..."), OnImportLabels,
541 Command( wxT("ImportRaw"), XXO("&Raw Data..."), OnImportRaw,
543 )
544 ),
545
546 Section( "Exit",
547 // On the Mac, the Exit item doesn't actually go here...wxMac will
548 // pull it out
549 // and put it in the Audacity menu for us based on its ID.
550 /* i18n-hint: (verb) It's item on a menu. */
551 Command( wxT("Exit"), XXO("E&xit"), OnExit,
552 AlwaysEnabledFlag, wxT("Ctrl+Q") )
553 )
554 ) };
555 return menu;
556}
wxT("CloseDown"))
constexpr CommandFlag AlwaysEnabledFlag
Definition: CommandFlag.h:34
const ReservedCommandFlag & AudioIONotBusyFlag()
const ReservedCommandFlag & LabelTracksExistFlag()
const ReservedCommandFlag & TimeSelectedFlag()
const ReservedCommandFlag & WaveTracksExistFlag()
const ReservedCommandFlag & WaveTracksSelectedFlag()
XXO("&Cut/Copy/Paste Toolbar")
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:90
constexpr auto Special
constexpr auto Section
constexpr auto Menu
constexpr auto Command
std::shared_ptr< BaseItem > BaseItemSharedPtr
Definition: Registry.h:74
void OnNew(const CommandContext &)
Definition: FileMenus.cpp:163
void OnSaveAs(const CommandContext &context)
Definition: FileMenus.cpp:234
void OnImportLabels(const CommandContext &context)
Definition: FileMenus.cpp:358
void OnExportAudio(const CommandContext &context)
Definition: FileMenus.cpp:266
void OnExportSelection(const CommandContext &context)
Definition: FileMenus.cpp:272
void OnSave(const CommandContext &context)
Definition: FileMenus.cpp:227
void OnImportRaw(const CommandContext &context)
Definition: FileMenus.cpp:404
void OnExportLabels(const CommandContext &context)
Definition: FileMenus.cpp:283
void OnClose(const CommandContext &context)
Definition: FileMenus.cpp:214
void OnExportOgg(const CommandContext &context)
Definition: FileMenus.cpp:260
void OnImport(const CommandContext &context)
Definition: FileMenus.cpp:353
void OnExportMultiple(const CommandContext &context)
Definition: FileMenus.cpp:345
void OnOpen(const CommandContext &context)
Definition: FileMenus.cpp:168
void OnExportWav(const CommandContext &context)
Definition: FileMenus.cpp:254
void OnProjectReset(const CommandContext &context)
Definition: FileMenus.cpp:208
void OnExit(const CommandContext &WXUNUSED(context))
Definition: FileMenus.cpp:409
void OnExportMp3(const CommandContext &context)
Definition: FileMenus.cpp:248
void OnSaveCopy(const CommandContext &context)
Definition: FileMenus.cpp:241

References AlwaysEnabledFlag, AudioIONotBusyFlag(), MenuTable::Command, FileHistory::Global(), LabelTracksExistFlag(), MenuTable::Menu, OnClose(), OnExit(), OnExportAudio(), OnExportLabels(), OnExportMp3(), OnExportMultiple(), OnExportOgg(), OnExportSelection(), OnExportWav(), OnImport(), OnImportLabels(), OnImportRaw(), OnNew(), OnOpen(), OnProjectReset(), OnSave(), OnSaveAs(), OnSaveCopy(), MenuTable::Section, MenuTable::Special, TimeSelectedFlag(), WaveTracksExistFlag(), WaveTracksSelectedFlag(), wxT(), and XXO().

Here is the call graph for this function:

◆ HiddenFileMenu()

BaseItemSharedPtr anonymous_namespace{FileMenus.cpp}::HiddenFileMenu ( )

Definition at line 563 of file FileMenus.cpp.

564{
565 static BaseItemSharedPtr menu
566 {
567 ConditionalItems( wxT("HiddenFileItems"),
568 []()
569 {
570 // Ensures that these items never appear in a menu, but
571 // are still available to scripting
572 return false;
573 },
574 Menu( wxT("HiddenFileMenu"), XXO("Hidden File Menu"),
575 Command( wxT("ExportFLAC"), XXO("Export as FLAC"),
578 )
579 )
580 };
581 return menu;
582}
constexpr auto ConditionalItems
void OnExportFLAC(const CommandContext &context)
Definition: FileMenus.cpp:416

References AudioIONotBusyFlag(), MenuTable::Command, MenuTable::ConditionalItems, MenuTable::Menu, OnExportFLAC(), wxT(), and XXO().

Here is the call graph for this function:

◆ OnClose()

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

Definition at line 214 of file FileMenus.cpp.

215{
216 auto &project = context.project;
217 auto &window = ProjectWindow::Get( project );
218 ProjectFileManager::Get( project ).SetMenuClose(true);
219 window.Close();
220}
void SetMenuClose(bool value)

References ProjectFileManager::Get(), ProjectWindow::Get(), CommandContext::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 222 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 409 of file FileMenus.cpp.

410{
411 // Simulate the application Exit menu item
412 wxCommandEvent evt{ wxEVT_MENU, wxID_EXIT };
413 wxTheApp->ProcessEvent( evt );
414}

Referenced by FileMenu().

Here is the caller graph for this function:

◆ OnExportAudio()

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

Definition at line 266 of file FileMenus.cpp.

267{
268 auto &project = context.project;
269 DoExport(project, "");
270}
void DoExport(AudacityProject &project, const FileExtension &format)
Definition: FileMenus.cpp:35

References DoExport(), and CommandContext::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 416 of file FileMenus.cpp.

417{
418 DoExport(context.project, "FLAC");
419}

References DoExport(), and CommandContext::project.

Referenced by HiddenFileMenu().

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

284{
285 auto &project = context.project;
286 auto &tracks = TrackList::Get( project );
287 auto &window = GetProjectFrame( project );
288
289 /* i18n-hint: filename containing exported text from label tracks */
290 wxString fName = _("labels.txt");
291 auto trackRange = tracks.Any<const LabelTrack>();
292 auto numLabelTracks = trackRange.size();
293
294 if (numLabelTracks == 0) {
295 AudacityMessageBox( XO("There are no label tracks to export.") );
296 return;
297 }
298 else
299 fName = (*trackRange.rbegin())->GetName();
300
301 fName = SelectFile(FileNames::Operation::Export,
302 XO("Export Labels As:"),
303 wxEmptyString,
304 fName,
305 wxT("txt"),
307 wxFD_SAVE | wxFD_OVERWRITE_PROMPT | wxRESIZE_BORDER,
308 &window);
309
310 if (fName.empty())
311 return;
312
313 // Move existing files out of the way. Otherwise wxTextFile will
314 // append to (rather than replace) the current file.
315
316 if (wxFileExists(fName)) {
317#ifdef __WXGTK__
318 wxString safetyFileName = fName + wxT("~");
319#else
320 wxString safetyFileName = fName + wxT(".bak");
321#endif
322
323 if (wxFileExists(safetyFileName))
324 wxRemoveFile(safetyFileName);
325
326 wxRename(fName, safetyFileName);
327 }
328
329 wxTextFile f(fName);
330 f.Create();
331 f.Open();
332 if (!f.IsOpened()) {
334 XO( "Couldn't write to file: %s" ).Format( fName ) );
335 return;
336 }
337
338 for (auto lt : trackRange)
339 lt->Export(f);
340
341 f.Write();
342 f.Close();
343}
#define _(s)
Definition: Internat.h:73
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 ...
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:251
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, SelectFile(), ClientData::Site< Host, ClientData, ObjectCopyingPolicy, Pointer, ObjectLockingPolicy, RegistryLockingPolicy >::size(), FileNames::TextFiles, 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 248 of file FileMenus.cpp.

249{
250 auto &project = context.project;
251 DoExport(project, "MP3");
252}

References DoExport(), and CommandContext::project.

Referenced by FileMenu().

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

◆ OnExportMultiple()

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

Definition at line 345 of file FileMenus.cpp.

346{
347 auto &project = context.project;
348 ExportMultipleDialog em(&project);
349
350 em.ShowModal();
351}
Presents a dialog box allowing the user to export multiple files either by exporting each track as a ...

References CommandContext::project, and ExportMultipleDialog::ShowModal().

Referenced by FileMenu().

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

261{
262 auto &project = context.project;
263 DoExport(project, "OGG");
264}

References DoExport(), and CommandContext::project.

Referenced by FileMenu().

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

◆ OnExportSelection()

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

Definition at line 272 of file FileMenus.cpp.

273{
274 auto &project = context.project;
275 auto &selectedRegion = ViewInfo::Get( project ).selectedRegion;
276 Exporter e{ project };
277
278 e.SetFileDialogTitle( XO("Export Selected Audio") );
279 e.Process(true, selectedRegion.t0(),
280 selectedRegion.t1());
281}
void SetFileDialogTitle(const TranslatableString &DialogTitle)
Definition: Export.cpp:375
NotifyingSelectedRegion selectedRegion
Definition: ViewInfo.h:219
static ViewInfo & Get(AudacityProject &project)
Definition: ViewInfo.cpp:235

References ViewInfo::Get(), CommandContext::project, ViewInfo::selectedRegion, Exporter::SetFileDialogTitle(), and XO().

Referenced by FileMenu().

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

255{
256 auto &project = context.project;
257 DoExport(project, "WAV");
258}

References DoExport(), and CommandContext::project.

Referenced by FileMenu().

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

354{
355 DoImport(context, false);
356}
void DoImport(const CommandContext &context, bool isRaw)
Definition: FileMenus.cpp:114

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

359{
360 auto &project = context.project;
361 auto &trackFactory = WaveTrackFactory::Get( project );
362 auto &tracks = TrackList::Get( project );
363 auto &window = ProjectWindow::Get( project );
364
365 wxString fileName =
366 SelectFile(FileNames::Operation::Open,
367 XO("Select a text file containing labels"),
368 wxEmptyString, // Path
369 wxT(""), // Name
370 wxT("txt"), // Extension
372 wxRESIZE_BORDER, // Flags
373 &window); // Parent
374
375 if (!fileName.empty()) {
376 wxTextFile f;
377
378 f.Open(fileName);
379 if (!f.IsOpened()) {
381 XO("Could not open file: %s").Format( fileName ) );
382 return;
383 }
384
385 auto newTrack = std::make_shared<LabelTrack>();
386 wxString sTrackName;
387 wxFileName::SplitPath(fileName, NULL, NULL, &sTrackName, NULL);
388 newTrack->SetName(sTrackName);
389
390 newTrack->Import(f);
391
393 newTrack->SetSelected(true);
394 tracks.Add( newTrack );
395
397 XO("Imported labels from '%s'").Format( fileName ),
398 XO("Import Labels"));
399
400 window.ZoomAfterImport(nullptr);
401 }
402}
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(), WaveTrackFactory::Get(), ProjectWindow::Get(), CommandContext::project, ProjectHistory::PushState(), SelectFile(), SelectUtilities::SelectNone(), FileNames::TextFiles, 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 404 of file FileMenus.cpp.

405{
406 DoImport(context, true);
407}

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

164{
165 ( void ) ProjectManager::New();
166}
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 168 of file FileMenus.cpp.

169{
170 auto &project = context.project;
172
173 int unavailablePlugins = 0;
174
175 auto &trackList = TrackList::Get(project);
176 for (auto track : trackList.Leaders<WaveTrack>())
177 {
178 auto& effects = RealtimeEffectList::Get(*track);
179 effects.Visit([&unavailablePlugins](auto& state, bool)
180 {
181 const auto& ID = state.GetID();
183
184 if (plug)
185 {
187 unavailablePlugins++;
188 }
189 else
190 {
191 unavailablePlugins++;
192 }
193 });
194 }
195
196 if (unavailablePlugins > 0)
197 {
198 MissingPluginsErrorDialog dlg(nullptr);
199 dlg.ShowModal();
200 }
201}
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:51

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

Referenced by FileMenu().

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

209{
210 auto &project = context.project;
212}
static ProjectManager & Get(AudacityProject &project)
void ResetProjectToEmpty()

References ProjectManager::Get(), CommandContext::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 227 of file FileMenus.cpp.

228{
229 auto &project = context.project;
230 auto &projectFileManager = ProjectFileManager::Get( project );
231 projectFileManager.Save();
232}

References ProjectFileManager::Get(), and CommandContext::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 234 of file FileMenus.cpp.

235{
236 auto &project = context.project;
237 auto &projectFileManager = ProjectFileManager::Get( project );
238 projectFileManager.SaveAs();
239}

References ProjectFileManager::Get(), and CommandContext::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 241 of file FileMenus.cpp.

242{
243 auto &project = context.project;
244 auto &projectFileManager = ProjectFileManager::Get( project );
245 projectFileManager.SaveCopy();
246}

References ProjectFileManager::Get(), and CommandContext::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
Initial value:
{
wxT(""),
}
std::unique_ptr< IndirectItem > Indirect(const BaseItemSharedPtr &ptr)
A convenience function.
Definition: Registry.h:97

Definition at line 558 of file FileMenus.cpp.

◆ sAttachment2

AttachedItem anonymous_namespace{FileMenus.cpp}::sAttachment2
Initial value:
{
wxT(""),
}
BaseItemSharedPtr HiddenFileMenu()
Definition: FileMenus.cpp:563

Definition at line 584 of file FileMenus.cpp.