1#include "../CommonCommandFlags.h"
3#include "../LabelTrack.h"
7#include "../ProjectFileManager.h"
9#include "../ProjectManager.h"
10#include "../ProjectWindows.h"
11#include "../ProjectWindow.h"
13#include "../SelectUtilities.h"
17#include "../commands/CommandContext.h"
18#include "../commands/CommandManager.h"
21#include "../export/ExportMultiple.h"
22#include "../import/Import.h"
23#include "../import/ImportRaw.h"
25#include "../widgets/FileHistory.h"
26#include "../widgets/MissingPluginsErrorDialog.h"
42 double t1 = tracks.GetEndTime();
46 bool bPromptingRequired = !project.
mBatchMode ||
47 projectName.empty() ||
51 if (bPromptingRequired) {
53 e.SetDefaultFormat(
format);
54 success = e.Process(
false, t0, t1);
74 wxFileName fileName(pathName, projectName,
format.Lower());
77 const wxString macroDir(
"macro-output" );
78 if (fileName.GetDirs().back() != macroDir) {
79 fileName.AppendDir(macroDir);
82 wxString justName = fileName.GetName();
83 wxString extension = fileName.GetExt();
84 FilePath fullPath = fileName.GetFullPath();
86 if (wxFileName::FileExists(fileName.GetPath())) {
88 XO(
"Cannot create directory '%s'. \n"
89 "File already exists that is not a directory"),
93 fileName.Mkdir(0777, wxPATH_MKDIR_FULL);
116 auto &project = context.
project;
121 if (selectedFiles.size() == 0) {
133 auto cleanup =
finally( [&] {
136 window.ZoomAfterImport(
nullptr);
137 window.HandleResize();
140 for (
size_t ff = 0; ff < selectedFiles.size(); ff++) {
141 wxString fileName = selectedFiles[ff];
148 ::ImportRaw(project, &window, fileName, &trackFactory, newTracks);
150 if (newTracks.size() > 0) {
170 auto &project = context.
project;
173 int unavailablePlugins = 0;
176 for (
auto track : trackList.Leaders<
WaveTrack>())
179 effects.Visit([&unavailablePlugins](
auto& state,
bool)
181 const auto& ID = state.GetID();
187 unavailablePlugins++;
191 unavailablePlugins++;
196 if (unavailablePlugins > 0)
210 auto &project = context.
project;
216 auto &project = context.
project;
229 auto &project = context.
project;
231 projectFileManager.Save();
236 auto &project = context.
project;
238 projectFileManager.SaveAs();
243 auto &project = context.
project;
245 projectFileManager.SaveCopy();
250 auto &project = context.
project;
256 auto &project = context.
project;
262 auto &project = context.
project;
268 auto &project = context.
project;
274 auto &project = context.
project;
279 e.Process(
true, selectedRegion.t0(),
280 selectedRegion.t1());
285 auto &project = context.
project;
290 wxString fName =
_(
"labels.txt");
291 auto trackRange = tracks.Any<
const LabelTrack>();
292 auto numLabelTracks = trackRange.
size();
294 if (numLabelTracks == 0) {
299 fName = (*trackRange.rbegin())->GetName();
301 fName =
SelectFile(FileNames::Operation::Export,
302 XO(
"Export Labels As:"),
307 wxFD_SAVE | wxFD_OVERWRITE_PROMPT | wxRESIZE_BORDER,
316 if (wxFileExists(fName)) {
318 wxString safetyFileName = fName +
wxT(
"~");
320 wxString safetyFileName = fName +
wxT(
".bak");
323 if (wxFileExists(safetyFileName))
324 wxRemoveFile(safetyFileName);
326 wxRename(fName, safetyFileName);
334 XO(
"Couldn't write to file: %s" ).
Format( fName ) );
338 for (
auto lt : trackRange)
347 auto &project = context.
project;
360 auto &project = context.
project;
367 XO(
"Select a text file containing labels"),
375 if (!fileName.empty()) {
381 XO(
"Could not open file: %s").
Format( fileName ) );
385 auto newTrack = std::make_shared<LabelTrack>();
387 wxFileName::SplitPath(fileName, NULL, NULL, &sTrackName, NULL);
388 newTrack->SetName(sTrackName);
393 newTrack->SetSelected(
true);
394 tracks.Add( newTrack );
397 XO(
"Imported labels from '%s'").
Format( fileName ),
398 XO(
"Import Labels"));
400 window.ZoomAfterImport(
nullptr);
412 wxCommandEvent evt{ wxEVT_MENU, wxID_EXIT };
413 wxTheApp->ProcessEvent( evt );
440 #ifdef EXPERIMENTAL_RESET
464 history.UseMenu( &theMenu );
466 wxWeakRef<wxMenu> recentFilesMenu{ &theMenu };
467 wxTheApp->CallAfter( [=] {
476 if ( recentFilesMenu )
477 recentFilesMenu->GetParent()->SetHelpString( 0,
"" );
574 Menu(
wxT(
"HiddenFileMenu"),
XXO(
"Hidden File Menu"),
int AudacityMessageBox(const TranslatableString &message, const TranslatableString &caption, long style, wxWindow *parent, int x, int y)
AttachedItem sAttachment1
AttachedItem sAttachment2
constexpr CommandFlag AlwaysEnabledFlag
const ReservedCommandFlag & AudioIONotBusyFlag()
const ReservedCommandFlag & LabelTracksExistFlag()
const ReservedCommandFlag & TimeSelectedFlag()
const ReservedCommandFlag & WaveTracksExistFlag()
const ReservedCommandFlag & WaveTracksSelectedFlag()
XXO("&Cut/Copy/Paste Toolbar")
wxString FileExtension
File extension, not including any leading dot.
BoolSetting NewImportingSession
std::vector< std::vector< std::shared_ptr< WaveTrack > > > TrackHolders
void ImportRaw(const AudacityProject &project, wxWindow *parent, const wxString &fileName, WaveTrackFactory *trackFactory, TrackHolders &outTracks)
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)
TranslatableString Verbatim(wxString str)
Require calls to the one-argument constructor to go through this distinct global function name.
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
const wxString & GetProjectName() const
size_t size() const
How many attachment pointers are in the Site.
CommandContext provides additional information to an 'Apply()' command. It provides the project,...
AudacityProject & project
Presents a dialog box allowing the user to export multiple files either by exporting each track as a ...
void SetFileDialogTitle(const TranslatableString &DialogTitle)
void Append(const FilePath &file)
static FileHistory & Global()
FILES_API const FileType AllFiles
FILES_API const FileType TextFiles
static void SetLastOpenType(const FileNames::FileType &type)
A LabelTrack is a Track that holds labels (LabelStruct).
An error dialog about missing plugins.
static bool IsPluginAvailable(const PluginDescriptor &plug)
const PluginDescriptor * GetPlugin(const PluginID &ID) const
static PluginManager & Get()
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)
void SetMenuClose(bool value)
void PushState(const TranslatableString &desc, const TranslatableString &shortDesc)
static ProjectHistory & Get(AudacityProject &project)
static ProjectManager & Get(AudacityProject &project)
static AudacityProject * New()
static void OpenFiles(AudacityProject *proj)
void ResetProjectToEmpty()
static ProjectWindow & Get(AudacityProject &project)
static RealtimeEffectList & Get(AudacityProject &project)
bool Write(const T &value)
Write value to config and return true if successful.
static TrackList & Get(AudacityProject &project)
NotifyingSelectedRegion selectedRegion
static ViewInfo & Get(AudacityProject &project)
static WaveTrackFactory & Get(AudacityProject &project)
A Track that contains audio waveform data.
FILES_API bool WritableLocationCheck(const FilePath &path, const TranslatableString &message)
Check location on writable access and return true if checked successfully.
FILES_API void UpdateDefaultPath(Operation op, const FilePath &path)
FILES_API int CompareNoCase(const wxString &first, const wxString &second)
FILES_API FilePath FindDefaultPath(Operation op)
std::shared_ptr< BaseItem > BaseItemSharedPtr
void SelectNone(AudacityProject &project)
CommandManager::Options Options