Audacity  3.0.3
FileMenus.cpp
Go to the documentation of this file.
1 
2 
3 #include "../CommonCommandFlags.h"
4 #include "FileNames.h"
5 #include "../LabelTrack.h"
6 #include "../NoteTrack.h"
7 #include "Prefs.h"
8 #include "../Printing.h"
9 #include "Project.h"
10 #include "../ProjectFileIO.h"
11 #include "../ProjectFileManager.h"
12 #include "../ProjectHistory.h"
13 #include "../ProjectManager.h"
14 #include "../ProjectWindows.h"
15 #include "../ProjectWindow.h"
16 #include "../SelectFile.h"
17 #include "../SelectUtilities.h"
18 #include "../TrackPanel.h"
19 #include "../UndoManager.h"
20 #include "ViewInfo.h"
21 #include "../WaveTrack.h"
22 #include "../commands/CommandContext.h"
23 #include "../commands/CommandManager.h"
24 #include "../export/ExportMP3.h"
25 #include "../export/ExportMultiple.h"
26 #include "../import/Import.h"
27 #include "../import/ImportMIDI.h"
28 #include "../import/ImportRaw.h"
29 #include "../widgets/AudacityMessageBox.h"
30 #include "../widgets/FileHistory.h"
31 #include "../widgets/wxPanelWrapper.h"
32 
33 #ifdef USE_MIDI
34 #include "../import/ImportMIDI.h"
35 #endif // USE_MIDI
36 
37 #include <wx/app.h>
38 #include <wx/menu.h>
39 
40 // private helper classes and functions
41 namespace {
42 
44 {
45  auto &tracks = TrackList::Get( project );
46  auto &projectFileIO = ProjectFileIO::Get( project );
47 
48  Exporter e{ project };
49 
50  double t0 = 0.0;
51  double t1 = tracks.GetEndTime();
52  wxString projectName = project.GetProjectName();
53 
54  // Prompt for file name and/or extension?
55  bool bPromptingRequired = !project.mBatchMode ||
56  projectName.empty() ||
57  format.empty();
58 
59  bool success = false;
60  if (bPromptingRequired) {
61  // Do export with prompting.
62  e.SetDefaultFormat(format);
63  success = e.Process(false, t0, t1);
64  }
65  else {
66  // We either use a configured output path,
67  // or we use the default documents folder - just as for exports.
68  FilePath pathName = FileNames::FindDefaultPath(FileNames::Operation::MacrosOut);
69 
70  if (!FileNames::WritableLocationCheck(pathName, XO("Cannot proceed to export.")))
71  {
72  return;
73  }
74 /*
75  // If we've gotten to this point, we are in batch mode, have a file format,
76  // and the project has either been saved or a file has been imported. So, we
77  // want to use the project's path if it has been saved, otherwise use the
78  // initial import path.
79  FilePath pathName = !projectFileIO.IsTemporary() ?
80  wxPathOnly(projectFileIO.GetFileName()) :
81  project.GetInitialImportPath();
82 */
83  wxFileName fileName(pathName, projectName, format.Lower());
84 
85  // Append the "macro-output" directory to the path
86  const wxString macroDir( "macro-output" );
87  if (fileName.GetDirs().back() != macroDir) {
88  fileName.AppendDir(macroDir);
89  }
90 
91  wxString justName = fileName.GetName();
92  wxString extension = fileName.GetExt();
93  FilePath fullPath = fileName.GetFullPath();
94 
95  if (wxFileName::FileExists(fileName.GetPath())) {
97  XO("Cannot create directory '%s'. \n"
98  "File already exists that is not a directory"),
99  Verbatim(fullPath));
100  return;
101  }
102  fileName.Mkdir(0777, wxPATH_MKDIR_FULL); // make sure it exists
103 
104  int nChannels = (tracks.Any() - &Track::IsLeader ).empty() ? 1 : 2;
105 
106  // We're in batch mode, the file does not exist already.
107  // We really can proceed without prompting.
108  success = e.Process(
109  nChannels, // numChannels,
110  format, // type,
111  fullPath, // full path,
112  false, // selectedOnly,
113  t0, // t0
114  t1 // t1
115  );
116  }
117 
118  if (success && !project.mBatchMode) {
119  FileHistory::Global().Append(e.GetAutoExportFileName().GetFullPath());
120  }
121 }
122 
123 void DoImport(const CommandContext &context, bool isRaw)
124 {
125  auto &project = context.project;
126  auto &trackFactory = WaveTrackFactory::Get( project );
127  auto &window = ProjectWindow::Get( project );
128 
129  auto selectedFiles = ProjectFileManager::ShowOpenDialog(FileNames::Operation::Import);
130  if (selectedFiles.size() == 0) {
132  return;
133  }
134 
135  // PRL: This affects FFmpegImportPlugin::Open which resets the preference
136  // to false. Should it also be set to true on other paths that reach
137  // AudacityProject::Import ?
138  gPrefs->Write(wxT("/NewImportingSession"), true);
139 
140  selectedFiles.Sort(FileNames::CompareNoCase);
141 
142  auto cleanup = finally( [&] {
143 
145  window.ZoomAfterImport(nullptr);
146  window.HandleResize(); // Adjust scrollers for NEW track sizes.
147  } );
148 
149  for (size_t ff = 0; ff < selectedFiles.size(); ff++) {
150  wxString fileName = selectedFiles[ff];
151 
152  FileNames::UpdateDefaultPath(FileNames::Operation::Import, ::wxPathOnly(fileName));
153 
154  if (isRaw) {
155  TrackHolders newTracks;
156 
157  ::ImportRaw(project, &window, fileName, &trackFactory, newTracks);
158 
159  if (newTracks.size() > 0) {
160  ProjectFileManager::Get( project )
161  .AddImportedTracks(fileName, std::move(newTracks));
162  }
163  }
164  else {
165  ProjectFileManager::Get( project ).Import(fileName);
166  }
167  }
168 }
169 
170 }
171 
172 // Menu handler functions
173 
174 namespace FileActions {
175 
177 
178 void OnNew(const CommandContext & )
179 {
180  ( void ) ProjectManager::New();
181 }
182 
183 void OnOpen(const CommandContext &context )
184 {
185  auto &project = context.project;
186  ProjectManager::OpenFiles(&project);
187 }
188 
189 // JKC: This is like OnClose, except it empties the project in place,
190 // rather than creating a new empty project (with new toolbars etc).
191 // It does not test for unsaved changes.
192 // It is not in the menus by default. Its main purpose is/was for
193 // developers checking functionality of ResetProjectToEmpty().
194 void OnProjectReset(const CommandContext &context)
195 {
196  auto &project = context.project;
198 }
199 
200 void OnClose(const CommandContext &context )
201 {
202  auto &project = context.project;
203  auto &window = ProjectWindow::Get( project );
204  ProjectFileManager::Get( project ).SetMenuClose(true);
205  window.Close();
206 }
207 
208 void OnCompact(const CommandContext &context)
209 {
211 }
212 
213 void OnSave(const CommandContext &context )
214 {
215  auto &project = context.project;
216  auto &projectFileManager = ProjectFileManager::Get( project );
217  projectFileManager.Save();
218 }
219 
220 void OnSaveAs(const CommandContext &context )
221 {
222  auto &project = context.project;
223  auto &projectFileManager = ProjectFileManager::Get( project );
224  projectFileManager.SaveAs();
225 }
226 
227 void OnSaveCopy(const CommandContext &context )
228 {
229  auto &project = context.project;
230  auto &projectFileManager = ProjectFileManager::Get( project );
231  projectFileManager.SaveCopy();
232 }
233 
234 void OnExportMp3(const CommandContext &context)
235 {
236  auto &project = context.project;
237  DoExport(project, "MP3");
238 }
239 
240 void OnExportWav(const CommandContext &context)
241 {
242  auto &project = context.project;
243  DoExport(project, "WAV");
244 }
245 
246 void OnExportOgg(const CommandContext &context)
247 {
248  auto &project = context.project;
249  DoExport(project, "OGG");
250 }
251 
252 void OnExportAudio(const CommandContext &context)
253 {
254  auto &project = context.project;
255  DoExport(project, "");
256 }
257 
258 void OnExportSelection(const CommandContext &context)
259 {
260  auto &project = context.project;
261  auto &selectedRegion = ViewInfo::Get( project ).selectedRegion;
262  Exporter e{ project };
263 
264  e.SetFileDialogTitle( XO("Export Selected Audio") );
265  e.Process(true, selectedRegion.t0(),
266  selectedRegion.t1());
267 }
268 
269 void OnExportLabels(const CommandContext &context)
270 {
271  auto &project = context.project;
272  auto &tracks = TrackList::Get( project );
273  auto &window = GetProjectFrame( project );
274 
275  /* i18n-hint: filename containing exported text from label tracks */
276  wxString fName = _("labels.txt");
277  auto trackRange = tracks.Any<const LabelTrack>();
278  auto numLabelTracks = trackRange.size();
279 
280  if (numLabelTracks == 0) {
281  AudacityMessageBox( XO("There are no label tracks to export.") );
282  return;
283  }
284  else
285  fName = (*trackRange.rbegin())->GetName();
286 
287  fName = SelectFile(FileNames::Operation::Export,
288  XO("Export Labels As:"),
289  wxEmptyString,
290  fName,
291  wxT("txt"),
293  wxFD_SAVE | wxFD_OVERWRITE_PROMPT | wxRESIZE_BORDER,
294  &window);
295 
296  if (fName.empty())
297  return;
298 
299  // Move existing files out of the way. Otherwise wxTextFile will
300  // append to (rather than replace) the current file.
301 
302  if (wxFileExists(fName)) {
303 #ifdef __WXGTK__
304  wxString safetyFileName = fName + wxT("~");
305 #else
306  wxString safetyFileName = fName + wxT(".bak");
307 #endif
308 
309  if (wxFileExists(safetyFileName))
310  wxRemoveFile(safetyFileName);
311 
312  wxRename(fName, safetyFileName);
313  }
314 
315  wxTextFile f(fName);
316  f.Create();
317  f.Open();
318  if (!f.IsOpened()) {
320  XO( "Couldn't write to file: %s" ).Format( fName ) );
321  return;
322  }
323 
324  for (auto lt : trackRange)
325  lt->Export(f);
326 
327  f.Write();
328  f.Close();
329 }
330 
331 void OnExportMultiple(const CommandContext &context)
332 {
333  auto &project = context.project;
334  ExportMultipleDialog em(&project);
335 
336  em.ShowModal();
337 }
338 
339 #ifdef USE_MIDI
340 void OnExportMIDI(const CommandContext &context)
341 {
342  auto &project = context.project;
343  auto &tracks = TrackList::Get( project );
344  auto &window = GetProjectFrame( project );
345 
346  // Make sure that there is
347  // exactly one NoteTrack selected.
348  const auto range = tracks.Selected< const NoteTrack >();
349  const auto numNoteTracksSelected = range.size();
350 
351  if(numNoteTracksSelected > 1) {
353  XO("Please select only one Note Track at a time.") );
354  return;
355  }
356  else if(numNoteTracksSelected < 1) {
358  XO("Please select a Note Track.") );
359  return;
360  }
361 
362  wxASSERT(numNoteTracksSelected);
363  if (!numNoteTracksSelected)
364  return;
365 
366  const auto nt = *range.begin();
367 
368  while(true) {
369 
370  wxString fName;
371 
372  fName = SelectFile(FileNames::Operation::Export,
373  XO("Export MIDI As:"),
374  wxEmptyString,
375  fName,
376  wxT("mid"),
377  {
378  { XO("MIDI file"), { wxT("mid") }, true },
379  { XO("Allegro file"), { wxT("gro") }, true },
380  },
381  wxFD_SAVE | wxFD_OVERWRITE_PROMPT | wxRESIZE_BORDER,
382  &window);
383 
384  if (fName.empty())
385  return;
386 
387  if(!fName.Contains(wxT("."))) {
388  fName = fName + wxT(".mid");
389  }
390 
391  // Move existing files out of the way. Otherwise wxTextFile will
392  // append to (rather than replace) the current file.
393 
394  if (wxFileExists(fName)) {
395 #ifdef __WXGTK__
396  wxString safetyFileName = fName + wxT("~");
397 #else
398  wxString safetyFileName = fName + wxT(".bak");
399 #endif
400 
401  if (wxFileExists(safetyFileName))
402  wxRemoveFile(safetyFileName);
403 
404  wxRename(fName, safetyFileName);
405  }
406 
407  if(fName.EndsWith(wxT(".mid")) || fName.EndsWith(wxT(".midi"))) {
408  nt->ExportMIDI(fName);
409  } else if(fName.EndsWith(wxT(".gro"))) {
410  nt->ExportAllegro(fName);
411  } else {
412  auto msg = XO(
413 "You have selected a filename with an unrecognized file extension.\nDo you want to continue?");
414  auto title = XO("Export MIDI");
415  int id = AudacityMessageBox( msg, title, wxYES_NO );
416  if (id == wxNO) {
417  continue;
418  } else if (id == wxYES) {
419  nt->ExportMIDI(fName);
420  }
421  }
422  break;
423  }
424 }
425 #endif // USE_MIDI
426 
427 void OnImport(const CommandContext &context)
428 {
429  DoImport(context, false);
430 }
431 
432 void OnImportLabels(const CommandContext &context)
433 {
434  auto &project = context.project;
435  auto &trackFactory = WaveTrackFactory::Get( project );
436  auto &tracks = TrackList::Get( project );
437  auto &window = ProjectWindow::Get( project );
438 
439  wxString fileName =
440  SelectFile(FileNames::Operation::Open,
441  XO("Select a text file containing labels"),
442  wxEmptyString, // Path
443  wxT(""), // Name
444  wxT("txt"), // Extension
446  wxRESIZE_BORDER, // Flags
447  &window); // Parent
448 
449  if (!fileName.empty()) {
450  wxTextFile f;
451 
452  f.Open(fileName);
453  if (!f.IsOpened()) {
455  XO("Could not open file: %s").Format( fileName ) );
456  return;
457  }
458 
459  auto newTrack = std::make_shared<LabelTrack>();
460  wxString sTrackName;
461  wxFileName::SplitPath(fileName, NULL, NULL, &sTrackName, NULL);
462  newTrack->SetName(sTrackName);
463 
464  newTrack->Import(f);
465 
466  SelectUtilities::SelectNone( project );
467  newTrack->SetSelected(true);
468  tracks.Add( newTrack );
469 
470  ProjectHistory::Get( project ).PushState(
471  XO("Imported labels from '%s'").Format( fileName ),
472  XO("Import Labels"));
473 
474  window.ZoomAfterImport(nullptr);
475  }
476 }
477 
478 #ifdef USE_MIDI
479 void OnImportMIDI(const CommandContext &context)
480 {
481  auto &project = context.project;
482  auto &window = GetProjectFrame( project );
483 
484  wxString fileName = SelectFile(FileNames::Operation::Open,
485  XO("Select a MIDI file"),
486  wxEmptyString, // Path
487  wxT(""), // Name
488  wxT(""), // Extension
489  {
490  { XO("MIDI and Allegro files"),
491  { wxT("mid"), wxT("midi"), wxT("gro"), }, true },
492  { XO("MIDI files"),
493  { wxT("mid"), wxT("midi"), }, true },
494  { XO("Allegro files"),
495  { wxT("gro"), }, true },
497  },
498  wxRESIZE_BORDER, // Flags
499  &window); // Parent
500 
501  if (!fileName.empty())
502  DoImportMIDI(project, fileName);
503 }
504 #endif
505 
506 void OnImportRaw(const CommandContext &context)
507 {
508  DoImport(context, true);
509 }
510 
511 void OnPageSetup(const CommandContext &context)
512 {
513  auto &project = context.project;
514  auto &window = GetProjectFrame( project );
515  HandlePageSetup(&window);
516 }
517 
518 void OnPrint(const CommandContext &context)
519 {
520  auto &project = context.project;
521  auto name = project.GetProjectName();
522  auto &tracks = TrackList::Get( project );
523  auto &window = GetProjectFrame( project );
524  HandlePrint(&window, name, &tracks, TrackPanel::Get( project ));
525 }
526 
527 void OnExit(const CommandContext &WXUNUSED(context) )
528 {
529  // Simulate the application Exit menu item
530  wxCommandEvent evt{ wxEVT_MENU, wxID_EXIT };
531  wxTheApp->ProcessEvent( evt );
532 }
533 
534 void OnExportFLAC(const CommandContext &context)
535 {
536  DoExport(context.project, "FLAC");
537 }
538 
539 }; // struct Handler
540 
541 } // namespace
542 
544  // Handler is not stateful. Doesn't need a factory registered with
545  // AudacityProject.
546  static FileActions::Handler instance;
547  return instance;
548 };
549 
550 // Menu definitions
551 
552 #define FN(X) (& FileActions::Handler :: X)
553 
554 namespace {
555 using namespace MenuTable;
556 
557 #ifdef USE_MIDI
558 const ReservedCommandFlag&
560  [](const AudacityProject &project){
561  return !TrackList::Get( project ).Any<const NoteTrack>().empty();
562  }
563  }; return flag; } //gsw
564 #endif
565 
567 {
569 
570  static BaseItemSharedPtr menu{
572  Menu( wxT("File"), XXO("&File"),
573  Section( "Basic",
574  /*i18n-hint: "New" is an action (verb) to create a NEW project*/
575  Command( wxT("New"), XXO("&New"), FN(OnNew),
576  AudioIONotBusyFlag(), wxT("Ctrl+N") ),
577 
578  /*i18n-hint: (verb)*/
579  Command( wxT("Open"), XXO("&Open..."), FN(OnOpen),
580  AudioIONotBusyFlag(), wxT("Ctrl+O") ),
581 
582  #ifdef EXPERIMENTAL_RESET
583  // Empty the current project and forget its name and path. DANGEROUS
584  // It's just for developers.
585  // Do not translate this menu item (no XXO).
586  // It MUST not be shown to regular users.
587  Command( wxT("Reset"), XXO("&Dangerous Reset..."), FN(OnProjectReset),
588  AudioIONotBusyFlag() ),
589  #endif
590 
592 
593  Menu( wxT("Recent"),
594  #ifdef __WXMAC__
595  /* i18n-hint: This is the name of the menu item on Mac OS X only */
596  XXO("Open Recent")
597  #else
598  /* i18n-hint: This is the name of the menu item on Windows and Linux */
599  XXO("Recent &Files")
600  #endif
601  ,
602  Special( wxT("PopulateRecentFilesStep"),
603  [](AudacityProject &, wxMenu &theMenu){
604  // Recent Files and Recent Projects menus
605  auto &history = FileHistory::Global();
606  history.UseMenu( &theMenu );
607 
608  wxWeakRef<wxMenu> recentFilesMenu{ &theMenu };
609  wxTheApp->CallAfter( [=] {
610  // Bug 143 workaround.
611  // The bug is in wxWidgets. For a menu that has scrollers,
612  // the scrollers have an ID of 0 (not wxID_NONE which is -3).
613  // Therefore wxWidgets attempts to find a help string. See
614  // wxFrameBase::ShowMenuHelp(int menuId)
615  // It finds a bogus automatic help string of "Recent &Files"
616  // from that submenu.
617  // So we set the help string for command with Id 0 to empty.
618  if ( recentFilesMenu )
619  recentFilesMenu->GetParent()->SetHelpString( 0, "" );
620  } );
621  } )
622  ),
623 
625 
626  Command( wxT("Close"), XXO("&Close"), FN(OnClose),
627  AudioIONotBusyFlag(), wxT("Ctrl+W") )
628  ),
629 
630  Section( "Save",
631  Menu( wxT("Save"), XXO("&Save Project"),
632  Command( wxT("Save"), XXO("&Save Project"), FN(OnSave),
633  AudioIONotBusyFlag(), wxT("Ctrl+S") ),
634  Command( wxT("SaveAs"), XXO("Save Project &As..."), FN(OnSaveAs),
635  AudioIONotBusyFlag() ),
636  Command( wxT("SaveCopy"), XXO("&Backup Project..."), FN(OnSaveCopy),
638  )//,
639 
640  // Bug 2600: Compact has interactions with undo/history that are bound
641  // to confuse some users. We don't see a way to recover useful amounts
642  // of space and not confuse users using undo.
643  // As additional space used by aup3 is 50% or so, perfectly valid
644  // approach to this P1 bug is to not provide the 'Compact' menu item.
645  //Command( wxT("Compact"), XXO("Co&mpact Project"), FN(OnCompact),
646  // AudioIONotBusyFlag(), wxT("Shift+A") )
647  ),
648 
649  Section( "Import-Export",
650  Menu( wxT("Export"), XXO("&Export"),
651  // Enable Export audio commands only when there are audio tracks.
652  Command( wxT("ExportMp3"), XXO("Export as MP&3"), FN(OnExportMp3),
654 
655  Command( wxT("ExportWav"), XXO("Export as &WAV"), FN(OnExportWav),
657 
658  Command( wxT("ExportOgg"), XXO("Export as &OGG"), FN(OnExportOgg),
660 
661  Command( wxT("Export"), XXO("&Export Audio..."), FN(OnExportAudio),
662  AudioIONotBusyFlag() | WaveTracksExistFlag(), wxT("Ctrl+Shift+E") ),
663 
664  // Enable Export Selection commands only when there's a selection.
665  Command( wxT("ExportSel"), XXO("Expo&rt Selected Audio..."),
666  FN(OnExportSelection),
668 
669  Command( wxT("ExportLabels"), XXO("Export &Labels..."),
670  FN(OnExportLabels),
672  // Enable Export audio commands only when there are audio tracks.
673  Command( wxT("ExportMultiple"), XXO("Export &Multiple..."),
674  FN(OnExportMultiple),
675  AudioIONotBusyFlag() | WaveTracksExistFlag(), wxT("Ctrl+Shift+L") )
676  #if defined(USE_MIDI)
677  ,
678  Command( wxT("ExportMIDI"), XXO("Export MI&DI..."), FN(OnExportMIDI),
680  #endif
681  ),
682 
683  Menu( wxT("Import"), XXO("&Import"),
684  Command( wxT("ImportAudio"), XXO("&Audio..."), FN(OnImport),
685  AudioIONotBusyFlag(), wxT("Ctrl+Shift+I") ),
686  Command( wxT("ImportLabels"), XXO("&Labels..."), FN(OnImportLabels),
687  AudioIONotBusyFlag() ),
688  #ifdef USE_MIDI
689  Command( wxT("ImportMIDI"), XXO("&MIDI..."), FN(OnImportMIDI),
690  AudioIONotBusyFlag() ),
691  #endif // USE_MIDI
692  Command( wxT("ImportRaw"), XXO("&Raw Data..."), FN(OnImportRaw),
694  )
695  ),
696 
697  Section( "Print",
698  Command( wxT("PageSetup"), XXO("Pa&ge Setup..."), FN(OnPageSetup),
700  /* i18n-hint: (verb) It's item on a menu. */
701  Command( wxT("Print"), XXO("&Print..."), FN(OnPrint),
703  ),
704 
705  Section( "Exit",
706  // On the Mac, the Exit item doesn't actually go here...wxMac will
707  // pull it out
708  // and put it in the Audacity menu for us based on its ID.
709  /* i18n-hint: (verb) It's item on a menu. */
710  Command( wxT("Exit"), XXO("E&xit"), FN(OnExit),
711  AlwaysEnabledFlag, wxT("Ctrl+Q") )
712  )
713  ) ) };
714  return menu;
715 }
716 
718  wxT(""),
719  Shared( FileMenu() )
720 };
721 
723 {
724  static BaseItemSharedPtr menu
725  {
726  (
728  ConditionalItems( wxT("HiddenFileItems"),
729  []()
730  {
731  // Ensures that these items never appear in a menu, but
732  // are still available to scripting
733  return false;
734  },
735  Menu( wxT("HiddenFileMenu"), XXO("Hidden File Menu"),
736  Command( wxT("ExportFLAC"), XXO("Export as FLAC"),
737  FN(OnExportFLAC),
739  )
740  )
741  )
742  };
743  return menu;
744 }
745 
747  wxT(""),
749 };
750 
751 }
752 
753 #undef FN
FileActions::Handler::OnExportFLAC
void OnExportFLAC(const CommandContext &context)
Definition: FileMenus.cpp:534
anonymous_namespace{FileMenus.cpp}::DoImport
void DoImport(const CommandContext &context, bool isRaw)
Definition: FileMenus.cpp:123
ViewInfo::Get
static ViewInfo & Get(AudacityProject &project)
Definition: ViewInfo.cpp:161
FileActions::Handler::OnExportMp3
void OnExportMp3(const CommandContext &context)
Definition: FileMenus.cpp:234
FileActions::Handler::OnOpen
void OnOpen(const CommandContext &context)
Definition: FileMenus.cpp:183
FileActions::Handler::OnImport
void OnImport(const CommandContext &context)
Definition: FileMenus.cpp:427
WaveTrackFactory::Get
static WaveTrackFactory & Get(AudacityProject &project)
Definition: WaveTrack.cpp:2901
FileActions::Handler::OnPageSetup
void OnPageSetup(const CommandContext &context)
Definition: FileMenus.cpp:511
TrackHolders
std::vector< std::vector< std::shared_ptr< WaveTrack > > > TrackHolders
Definition: Import.h:39
FileActions::Handler::OnImportRaw
void OnImportRaw(const CommandContext &context)
Definition: FileMenus.cpp:506
AudacityMessageBox
int AudacityMessageBox(const TranslatableString &message, const TranslatableString &caption, long style, wxWindow *parent, int x, int y)
Definition: AudacityMessageBox.cpp:17
FileNames::FindDefaultPath
FILES_API FilePath FindDefaultPath(Operation op)
MenuTable::FinderScope
Definition: CommandManager.h:485
FileActions::Handler::OnProjectReset
void OnProjectReset(const CommandContext &context)
Definition: FileMenus.cpp:194
flag
static std::once_flag flag
Definition: WaveformView.cpp:1124
gPrefs
FileConfig * gPrefs
Definition: Prefs.cpp:70
anonymous_namespace{FileMenus.cpp}::NoteTracksExistFlag
const ReservedCommandFlag & NoteTracksExistFlag()
Definition: FileMenus.cpp:559
Exporter::SetFileDialogTitle
void SetFileDialogTitle(const TranslatableString &DialogTitle)
Definition: Export.cpp:374
Project.h
SelectFile
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
ExportMultipleDialog::ShowModal
int ShowModal()
Definition: ExportMultiple.cpp:182
AudioIONotBusyFlag
const ReservedCommandFlag & AudioIONotBusyFlag()
Definition: CommonCommandFlags.cpp:127
FileActions::Handler::OnExportAudio
void OnExportAudio(const CommandContext &context)
Definition: FileMenus.cpp:252
FileNames::UpdateDefaultPath
FILES_API void UpdateDefaultPath(Operation op, const FilePath &path)
ImportRaw
void ImportRaw(const AudacityProject &project, wxWindow *parent, const wxString &fileName, WaveTrackFactory *trackFactory, TrackHolders &outTracks)
Definition: ImportRaw.cpp:110
FileActions::Handler::OnImportMIDI
void OnImportMIDI(const CommandContext &context)
Definition: FileMenus.cpp:479
Format
Abstract base class used in importing a file.
WaveTracksExistFlag
const ReservedCommandFlag & WaveTracksExistFlag()
Definition: CommonCommandFlags.cpp:286
Exporter
Definition: Export.h:166
ReservedCommandFlag
Definition: CommandFlag.h:89
FileActions::Handler::OnSave
void OnSave(const CommandContext &context)
Definition: FileMenus.cpp:213
Registry::Shared
std::unique_ptr< SharedItem > Shared(const BaseItemSharedPtr &ptr)
Definition: Registry.h:93
FileActions::Handler::OnImportLabels
void OnImportLabels(const CommandContext &context)
Definition: FileMenus.cpp:432
LabelTracksExistFlag
const ReservedCommandFlag & LabelTracksExistFlag()
Definition: CommonCommandFlags.cpp:224
TrackPanel::Get
static TrackPanel & Get(AudacityProject &project)
Definition: TrackPanel.cpp:227
XO
#define XO(s)
Definition: Internat.h:31
ProjectFileIO::Get
static ProjectFileIO & Get(AudacityProject &project)
Definition: ProjectFileIO.cpp:265
ClientData::Site::size
size_t size() const
How many attachment pointers are in the Site.
Definition: ClientData.h:251
FileActions
Definition: FileMenus.cpp:174
LabelTrack
A LabelTrack is a Track that holds labels (LabelStruct).
Definition: LabelTrack.h:88
ProjectFileManager::AddImportedTracks
void AddImportedTracks(const FilePath &fileName, TrackHolders &&newTracks)
Definition: ProjectFileManager.cpp:1073
findCommandHandler
static CommandHandlerObject & findCommandHandler(AudacityProject &)
Definition: FileMenus.cpp:543
ProjectWindow::Get
static ProjectWindow & Get(AudacityProject &project)
Definition: ProjectWindow.cpp:535
AlwaysEnabledFlag
constexpr CommandFlag AlwaysEnabledFlag
Definition: CommandFlag.h:35
MenuTable::AttachedItem
Definition: CommandManager.h:708
anonymous_namespace{FileMenus.cpp}::sAttachment2
AttachedItem sAttachment2
Definition: FileMenus.cpp:746
FileActions::Handler::OnNew
void OnNew(const CommandContext &)
Definition: FileMenus.cpp:178
FileNames::AllFiles
FILES_API const FileType AllFiles
Definition: FileNames.h:71
ProjectFileManager::SetMenuClose
void SetMenuClose(bool value)
Definition: ProjectFileManager.h:107
FileActions::Handler::OnSaveCopy
void OnSaveCopy(const CommandContext &context)
Definition: FileMenus.cpp:227
ProjectManager::ResetProjectToEmpty
void ResetProjectToEmpty()
Definition: ProjectManager.cpp:972
WaveTracksSelectedFlag
const ReservedCommandFlag & WaveTracksSelectedFlag()
Definition: CommonCommandFlags.cpp:164
FileActions::Handler::OnExportMultiple
void OnExportMultiple(const CommandContext &context)
Definition: FileMenus.cpp:331
FileHistory::Global
static FileHistory & Global()
Definition: FileHistory.cpp:37
MenuTable::ConditionalItems
std::unique_ptr< ConditionalGroupItem > ConditionalItems(const Identifier &internalName, ConditionalGroupItem::Condition condition, Args &&... args)
Definition: CommandManager.h:639
anonymous_namespace{FileMenus.cpp}::sAttachment1
AttachedItem sAttachment1
Definition: FileMenus.cpp:717
FileExtension
wxString FileExtension
File extension, not including any leading dot.
Definition: Identifier.h:224
ProjectManager::Get
static ProjectManager & Get(AudacityProject &project)
Definition: ProjectManager.cpp:70
ViewInfo::selectedRegion
NotifyingSelectedRegion selectedRegion
Definition: ViewInfo.h:196
XXO
#define XXO(s)
Definition: Internat.h:44
anonymous_namespace{FileMenus.cpp}::DoExport
void DoExport(AudacityProject &project, const FileExtension &format)
Definition: FileMenus.cpp:43
FileActions::Handler
Definition: FileMenus.cpp:176
FN
#define FN(X)
Definition: FileMenus.cpp:552
FileActions::Handler::OnCompact
void OnCompact(const CommandContext &context)
Definition: FileMenus.cpp:208
FilePath
wxString FilePath
Definition: Project.h:20
CommandContext
CommandContext provides additional information to an 'Apply()' command. It provides the project,...
Definition: CommandContext.h:34
ProjectFileManager::Get
static ProjectFileManager & Get(AudacityProject &project)
Definition: ProjectFileManager.cpp:66
FileNames::TextFiles
FILES_API const FileType TextFiles
Definition: FileNames.h:74
FileActions::Handler::OnExportWav
void OnExportWav(const CommandContext &context)
Definition: FileMenus.cpp:240
Registry::BaseItemSharedPtr
std::shared_ptr< BaseItem > BaseItemSharedPtr
Definition: Registry.h:72
AudacityProject::mBatchMode
int mBatchMode
Definition: Project.h:129
FileActions::Handler::OnExportOgg
void OnExportOgg(const CommandContext &context)
Definition: FileMenus.cpp:246
FileActions::Handler::OnPrint
void OnPrint(const CommandContext &context)
Definition: FileMenus.cpp:518
name
const TranslatableString name
Definition: Distortion.cpp:98
ProjectManager::New
static AudacityProject * New()
Definition: ProjectManager.cpp:529
format
int format
Definition: ExportPCM.cpp:56
ProjectFileManager::Compact
void Compact()
Definition: ProjectFileManager.cpp:1380
Importer::SetLastOpenType
static void SetLastOpenType(const FileNames::FileType &type)
Definition: Import.cpp:224
HandlePageSetup
void HandlePageSetup(wxWindow *parent)
Definition: Printing.cpp:161
anonymous_namespace{LogWindow.cpp}::OnSave
void OnSave(wxCommandEvent &e)
anonymous_namespace{LogWindow.cpp}::OnClose
void OnClose(wxCommandEvent &e)
TracksExistFlag
const ReservedCommandFlag & TracksExistFlag()
Definition: CommonCommandFlags.cpp:173
HandlePrint
void HandlePrint(wxWindow *parent, const wxString &name, TrackList *tracks, TrackPanel &panel)
Definition: Printing.cpp:171
FileHistory::Append
void Append(const FilePath &file)
Definition: FileHistory.h:42
ViewInfo.h
anonymous_namespace{FileMenus.cpp}::FileMenu
BaseItemSharedPtr FileMenu()
Definition: FileMenus.cpp:566
title
static const auto title
Definition: UpdateNoticeDialog.cpp:23
ProjectHistory::PushState
void PushState(const TranslatableString &desc, const TranslatableString &shortDesc)
Definition: ProjectHistory.cpp:90
ExportMultipleDialog
Presents a dialog box allowing the user to export multiple files either by exporting each track as a ...
Definition: ExportMultiple.h:33
FileNames::WritableLocationCheck
FILES_API bool WritableLocationCheck(const FilePath &path, const TranslatableString &message)
Check location on writable access and return true if checked successfully.
TrackList::Get
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:506
Track::IsLeader
bool IsLeader() const
Definition: Track.cpp:379
_
#define _(s)
Definition: Internat.h:75
MenuTable::Command
std::unique_ptr< CommandItem > Command(const CommandID &name, const TranslatableString &label_in, void(Handler::*pmf)(const CommandContext &), CommandFlag flags, const CommandManager::Options &options={}, CommandHandlerFinder finder=FinderScope::DefaultFinder())
Definition: CommandManager.h:675
AudacityProject
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:92
FileNames.h
TimeSelectedFlag
const ReservedCommandFlag & TimeSelectedFlag()
Definition: CommonCommandFlags.cpp:159
SelectUtilities::SelectNone
void SelectNone(AudacityProject &project)
Definition: SelectUtilities.cpp:73
GetProjectFrame
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 ...
Definition: ProjectWindows.cpp:72
CommandHandlerObject
wxEvtHandler CommandHandlerObject
Definition: CommandFunctors.h:28
MenuTable::Menu
std::unique_ptr< MenuItem > Menu(const Identifier &internalName, const TranslatableString &title, Args &&... args)
Definition: CommandManager.h:623
Verbatim
TranslatableString Verbatim(wxString str)
Require calls to the one-argument constructor to go through this distinct global function name.
Definition: TranslatableString.h:321
anonymous_namespace{FileMenus.cpp}::HiddenFileMenu
BaseItemSharedPtr HiddenFileMenu()
Definition: FileMenus.cpp:722
ProjectManager::OpenFiles
static void OpenFiles(AudacityProject *proj)
Definition: ProjectManager.cpp:866
ProjectFileManager::Import
bool Import(const FilePath &fileName, bool addToHistory=true)
Definition: ProjectFileManager.cpp:1207
FileNames::CompareNoCase
FILES_API int CompareNoCase(const wxString &first, const wxString &second)
MenuTable::Section
std::unique_ptr< MenuPart > Section(const Identifier &internalName, Args &&... args)
Definition: CommandManager.h:611
Prefs.h
FileActions::Handler::OnClose
void OnClose(const CommandContext &context)
Definition: FileMenus.cpp:200
MenuTable
Definition: CommandManager.h:416
FileActions::Handler::OnExportSelection
void OnExportSelection(const CommandContext &context)
Definition: FileMenus.cpp:258
TrackList::Any
auto Any() -> TrackIterRange< TrackType >
Definition: Track.h:1371
FileActions::Handler::OnExit
void OnExit(const CommandContext &WXUNUSED(context))
Definition: FileMenus.cpp:527
MenuTable::Special
std::unique_ptr< SpecialItem > Special(const Identifier &name, const SpecialItem::Appender &fn)
Definition: CommandManager.h:700
FileActions::Handler::OnSaveAs
void OnSaveAs(const CommandContext &context)
Definition: FileMenus.cpp:220
CommandContext::project
AudacityProject & project
Definition: CommandContext.h:64
anonymous_namespace{Menus.cpp}::Options
std::vector< CommandFlagOptions > & Options()
Definition: Menus.cpp:527
AudacityProject::GetProjectName
const wxString & GetProjectName() const
Definition: Project.cpp:92
ProjectHistory::Get
static ProjectHistory & Get(AudacityProject &project)
Definition: ProjectHistory.cpp:26
NoteTrack
A Track that is used for Midi notes. (Somewhat old code).
Definition: NoteTrack.h:67
FileActions::Handler::OnExportLabels
void OnExportLabels(const CommandContext &context)
Definition: FileMenus.cpp:269
ProjectFileManager::ShowOpenDialog
static wxArrayString ShowOpenDialog(FileNames::Operation op, const FileNames::FileType &extraType={})
Show an open dialogue for opening audio files, and possibly other sorts of files.
Definition: ProjectFileManager.cpp:805
DoImportMIDI
bool DoImportMIDI(AudacityProject &project, const FilePath &fileName)
Definition: ImportMIDI.cpp:37
FileActions::Handler::OnExportMIDI
void OnExportMIDI(const CommandContext &context)
Definition: FileMenus.cpp:340