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

Functions

void DoExport (AudacityProject &project, const FileExtension &format, AudiocomTrace trace)
 
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)
 
void OnExportSelectedAudio (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,
AudiocomTrace  trace 
)

Definition at line 44 of file FileMenus.cpp.

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

139{
140 auto &project = context.project;
141 auto &trackFactory = WaveTrackFactory::Get( project );
142 auto &viewport = Viewport::Get(project);
143 auto &window = GetProjectFrame(project);
144
145 auto selectedFiles = ProjectFileManager::ShowOpenDialog(FileNames::Operation::Import);
146 if (selectedFiles.size() == 0) {
148 return;
149 }
150
151 // PRL: This affects FFmpegImportPlugin::Open which resets the preference
152 // to false. Should it also be set to true on other paths that reach
153 // AudacityProject::Import ?
155
156 selectedFiles.Sort(FileNames::CompareNoCase);
157
158 auto cleanup = finally( [&] {
159
161 viewport.ZoomFitHorizontallyAndShowTrack(nullptr);
162 viewport.HandleResize(); // Adjust scrollers for NEW track sizes.
163 } );
164
165 wxArrayString filesToImport;
166 for (size_t ff = 0; ff < selectedFiles.size(); ff++) {
167 wxString fileName = selectedFiles[ff];
168
169 FileNames::UpdateDefaultPath(FileNames::Operation::Import, ::wxPathOnly(fileName));
170
171 if (isRaw) {
172 TrackHolders newTracks;
173
174 ::ImportRaw(project, &window, fileName, &trackFactory, newTracks);
175
176 if (newTracks.size() > 0) {
178 .AddImportedTracks(fileName, std::move(newTracks));
179 }
180 }
181 else
182 filesToImport.Add(fileName);
183 }
184 if (!isRaw)
185 ProjectFileManager::Get(project).Import(filesToImport);
186}
BoolSetting NewImportingSession
Definition: Import.cpp:860
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:254
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)
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:3376
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 570 of file FileMenus.cpp.

571{
572 static auto menu = std::shared_ptr{
573 Section( "Import-Export",
574 Menu( wxT("Export"), XXO("&Export"),
575 // Enable Export audio commands only when there are audio tracks.
576 Command( wxT("ExportMp3"), XXO("Export as MP&3"), OnExportMp3,
578 Command( wxT("ExportWav"), XXO("Export as &WAV"), OnExportWav,
580 Command( wxT("ExportOgg"), XXO("Export as &OGG"), OnExportOgg,
582 Command( wxT("ExportFLAC"), XXO("Export as FLAC"), OnExportFLAC,
584 Command( wxT("ExportSel"), XXO("Expo&rt Selected Audio..."), OnExportSelectedAudio,
586 ))};
587 return menu;
588}
wxT("CloseDown"))
const ReservedCommandFlag & AudioIONotBusyFlag()
const ReservedCommandFlag & TimeSelectedFlag()
const ReservedCommandFlag & WaveTracksExistFlag()
const ReservedCommandFlag & WaveTracksSelectedFlag()
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 OnExportSelectedAudio(const CommandContext &context)
Definition: FileMenus.cpp:442
void OnExportOgg(const CommandContext &context)
Definition: FileMenus.cpp:291
void OnExportFLAC(const CommandContext &context)
Definition: FileMenus.cpp:435
void OnExportWav(const CommandContext &context)
Definition: FileMenus.cpp:283
void OnExportMp3(const CommandContext &context)
Definition: FileMenus.cpp:275

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

Here is the call graph for this function:

◆ FileMenu()

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

Definition at line 457 of file FileMenus.cpp.

458{
459 static auto menu = std::shared_ptr{
460 Menu( wxT("File"), XXO("&File"),
461 Section( "Basic",
462 /*i18n-hint: "New" is an action (verb) to create a NEW project*/
463 Command( wxT("New"), XXO("&New"), OnNew,
464 AudioIONotBusyFlag(), wxT("Ctrl+N") ),
465
466 /*i18n-hint: (verb)*/
467 Command( wxT("Open"), XXO("&Open..."), OnOpen,
468 AudioIONotBusyFlag(), wxT("Ctrl+O") ),
469
470 #ifdef EXPERIMENTAL_RESET
471 // Empty the current project and forget its name and path. DANGEROUS
472 // It's just for developers.
473 // Do not translate this menu item (no XXO).
474 // It MUST not be shown to regular users.
475 Command( wxT("Reset"), XXO("&Dangerous Reset..."), OnProjectReset,
477 #endif
478
480
481 Menu( wxT("Recent"),
482 #ifdef __WXMAC__
483 /* i18n-hint: This is the name of the menu item on Mac OS X only */
484 XXO("Open Recent")
485 #else
486 /* i18n-hint: This is the name of the menu item on Windows and Linux */
487 XXO("Recent &Files")
488 #endif
489 ,
490 MenuCreator::Special( wxT("PopulateRecentFilesStep"),
491 [](AudacityProject &, wxMenu &theMenu){
492 // Recent Files and Recent Projects menus
493 auto &history = FileHistory::Global();
494 history.UseMenu( &theMenu );
495
496 wxWeakRef<wxMenu> recentFilesMenu{ &theMenu };
497 wxTheApp->CallAfter( [=] {
498 // Bug 143 workaround.
499 // The bug is in wxWidgets. For a menu that has scrollers,
500 // the scrollers have an ID of 0 (not wxID_NONE which is -3).
501 // Therefore wxWidgets attempts to find a help string. See
502 // wxFrameBase::ShowMenuHelp(int menuId)
503 // It finds a bogus automatic help string of "Recent &Files"
504 // from that submenu.
505 // So we set the help string for command with Id 0 to empty.
506 if ( recentFilesMenu )
507 recentFilesMenu->GetParent()->SetHelpString( 0, "" );
508 } );
509 } )
510 )
511 ),
512
513 Section( "Save",
514 Menu( wxT("Save"), XXO("&Save Project"),
515 Command( wxT("Save"), XXO("&Save Project"), OnSave,
516 AudioIONotBusyFlag(), wxT("Ctrl+S") ),
517 Command( wxT("SaveAs"), XXO("Save Project &As..."), OnSaveAs,
519 Command( wxT("SaveCopy"), XXO("&Backup Project..."), OnSaveCopy,
521 )//,
522
523 // Bug 2600: Compact has interactions with undo/history that are bound
524 // to confuse some users. We don't see a way to recover useful amounts
525 // of space and not confuse users using undo.
526 // As additional space used by aup3 is 50% or so, perfectly valid
527 // approach to this P1 bug is to not provide the 'Compact' menu item.
528 //Command( wxT("Compact"), XXO("Co&mpact Project"), OnCompact,
529 // AudioIONotBusyFlag(), wxT("Shift+A") )
530 ),
531
532 Section( "Import-Export",
533 Command( wxT("Export"), XXO("&Export Audio..."), OnExportAudio,
534 AudioIONotBusyFlag() | WaveTracksExistFlag(), wxT("Ctrl+Shift+E") ),
535
536 Menu( wxT("ExportOther"), XXO("Expo&rt Other"),
537 Command( wxT("ExportLabels"), XXO("Export &Labels..."),
540 ),
541
542 Menu( wxT("Import"), XXO("&Import"),
543 Command( wxT("ImportAudio"), XXO("&Audio..."), OnImport,
544 AudioIONotBusyFlag(), wxT("Ctrl+Shift+I") ),
545 Command( wxT("ImportLabels"), XXO("&Labels..."), OnImportLabels,
547 Command( wxT("ImportRaw"), XXO("&Raw Data..."), OnImportRaw,
549 )
550 ),
551
552 Section( "Close", Command( wxT("Close"), XXO("&Close Project"), OnClose,
553 AudioIONotBusyFlag(), wxT("Ctrl+W") )
554 ),
555
556 Section( "Exit",
557 // On the Mac, the Exit item doesn't actually go here...wxMac will
558 // pull it out
559 // and put it in the Audacity menu for us based on its ID.
560 /* i18n-hint: (verb) It's item on a menu. */
561 Command( wxT("Exit"), XXO("&Quit Audacity"), OnExit,
562 AlwaysEnabledFlag, wxT("Ctrl+Q") )
563 )
564 ) };
565 return menu;
566}
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:190
void OnSaveAs(const CommandContext &context)
Definition: FileMenus.cpp:261
void OnImportLabels(const CommandContext &context)
Definition: FileMenus.cpp:376
void OnExportAudio(const CommandContext &context)
Definition: FileMenus.cpp:299
void OnSave(const CommandContext &context)
Definition: FileMenus.cpp:254
void OnImportRaw(const CommandContext &context)
Definition: FileMenus.cpp:423
void OnExportLabels(const CommandContext &context)
Definition: FileMenus.cpp:307
void OnClose(const CommandContext &context)
Definition: FileMenus.cpp:241
void OnImport(const CommandContext &context)
Definition: FileMenus.cpp:371
void OnOpen(const CommandContext &context)
Definition: FileMenus.cpp:195
void OnProjectReset(const CommandContext &context)
Definition: FileMenus.cpp:235
void OnExit(const CommandContext &WXUNUSED(context))
Definition: FileMenus.cpp:428
void OnSaveCopy(const CommandContext &context)
Definition: FileMenus.cpp:268

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

242{
243 auto &project = context.project;
244 auto &window = GetProjectFrame(project);
246 window.Close();
247}
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 249 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 428 of file FileMenus.cpp.

429{
430 // Simulate the application Exit menu item
431 wxCommandEvent evt{ wxEVT_MENU, wxID_EXIT };
432 wxTheApp->ProcessEvent( evt );
433}

Referenced by FileMenu().

Here is the caller graph for this function:

◆ OnExportAudio()

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

Definition at line 299 of file FileMenus.cpp.

300{
301 auto &project = context.project;
302 DoExport(
303 project, "",
305}
void DoExport(AudacityProject &project, const FileExtension &format, AudiocomTrace trace)
Definition: FileMenus.cpp:44

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

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

436{
437 DoExport(
438 context.project, "FLAC",
440}
@ ShareAudioExportExtraMenu

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

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

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

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

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

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

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

292{
293 auto &project = context.project;
294 DoExport(
295 project, "OGG",
297}

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

Referenced by ExtraExportMenu().

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

◆ OnExportSelectedAudio()

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

Definition at line 442 of file FileMenus.cpp.

443{
445 return;
446
448 context.project, "",
449 AudiocomTrace::ignore, // Local save, no need.
450 true);
451}
static bool HasSelectedAudio(const AudacityProject &project)
Definition: ExportUtils.cpp:33

References ExportUtils::HasSelectedAudio(), ignore, ExportUtils::PerformInteractiveExport(), and CommandContext::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(
287 project, "WAV",
289}

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

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

372{
373 DoImport(context, false);
374}
void DoImport(const CommandContext &context, bool isRaw)
Definition: FileMenus.cpp:138

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

377{
378 auto &project = context.project;
379 auto &tracks = TrackList::Get( project );
380 auto &viewport = Viewport::Get(project);
381 auto &window = GetProjectFrame(project);
382
383 wxString fileName =
384 SelectFile(FileNames::Operation::Open,
385 XO("Select a text file containing labels"),
386 wxEmptyString, // Path
387 wxT(""), // Name
388 wxT("txt"), // Extension
390 wxRESIZE_BORDER, // Flags
391 &window); // Parent
392
393 if (!fileName.empty()) {
395 wxTextFile f;
396
397 f.Open(fileName);
398 if (!f.IsOpened()) {
400 XO("Could not open file: %s").Format( fileName ) );
401 return;
402 }
403
404 auto newTrack = std::make_shared<LabelTrack>();
405 wxString sTrackName;
406 wxFileName::SplitPath(fileName, NULL, NULL, &sTrackName, NULL);
407 newTrack->SetName(sTrackName);
408
409 newTrack->Import(f, format);
410
412 newTrack->SetSelected(true);
413 tracks.Add( newTrack );
414
416 XO("Imported labels from '%s'").Format( fileName ),
417 XO("Import Labels"));
418
419 viewport.ZoomFitHorizontallyAndShowTrack(nullptr);
420 }
421}
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 423 of file FileMenus.cpp.

424{
425 DoImport(context, true);
426}

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

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

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

236{
237 auto &project = context.project;
239}
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 254 of file FileMenus.cpp.

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

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

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

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

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

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