1#include "../CommonCommandFlags.h"
3#include "../LabelTrack.h"
8#include "../ProjectFileManager.h"
10#include "../ProjectManager.h"
11#include "../ProjectWindows.h"
12#include "../ProjectWindow.h"
14#include "../TagsEditor.h"
15#include "../SelectUtilities.h"
19#include "../commands/CommandContext.h"
20#include "../commands/CommandManager.h"
24#include "../import/ImportRaw.h"
26#include "../widgets/FileHistory.h"
27#include "../widgets/MissingPluginsErrorDialog.h"
47 wxString projectName =
project.GetProjectName();
50 bool bPromptingRequired = !
project.mBatchMode ||
51 projectName.empty() ||
54 if (bPromptingRequired) {
58 XO(
"All audio is muted."),
87 wxFileName fileName(pathName, projectName,
format.Lower());
90 const wxString macroDir(
"macro-output" );
91 if (fileName.GetDirs().empty() || fileName.GetDirs().back() != macroDir) {
92 fileName.AppendDir(macroDir);
95 wxString justName = fileName.GetName();
96 wxString extension = fileName.GetExt();
97 FilePath fullPath = fileName.GetFullPath();
99 if (wxFileName::FileExists(fileName.GetPath())) {
101 XO(
"Cannot create directory '%s'. \n"
102 "File already exists that is not a directory"),
106 fileName.Mkdir(0777, wxPATH_MKDIR_FULL);
110 if(plugin !=
nullptr)
112 auto editor = plugin->CreateOptionsEditor(formatIndex,
nullptr);
123 bool success =
false;
132 if (success && !
project.mBatchMode) {
146 if (selectedFiles.size() == 0) {
158 auto cleanup =
finally( [&] {
161 window.ZoomAfterImport(
nullptr);
162 window.HandleResize();
165 for (
size_t ff = 0; ff < selectedFiles.size(); ff++) {
166 wxString fileName = selectedFiles[ff];
175 if (newTracks.size() > 0) {
198 int unavailablePlugins = 0;
201 for (
auto track : trackList.Any<
WaveTrack>())
204 effects.Visit([&unavailablePlugins](
auto& state,
bool)
206 const auto& ID = state.GetID();
212 unavailablePlugins++;
216 unavailablePlugins++;
221 if (unavailablePlugins > 0)
256 projectFileManager.Save();
263 projectFileManager.SaveAs();
270 projectFileManager.SaveCopy();
304 wxString fName =
_(
"labels.txt");
306 auto numLabelTracks = trackRange.
size();
308 if (numLabelTracks == 0) {
313 fName = (*trackRange.rbegin())->GetName();
315 fName =
SelectFile(FileNames::Operation::Export,
316 XO(
"Export Labels As:"),
321 wxFD_SAVE | wxFD_OVERWRITE_PROMPT | wxRESIZE_BORDER,
330 if (wxFileExists(fName)) {
332 wxString safetyFileName = fName +
wxT(
"~");
334 wxString safetyFileName = fName +
wxT(
".bak");
337 if (wxFileExists(safetyFileName))
338 wxRemoveFile(safetyFileName);
340 wxRename(fName, safetyFileName);
348 XO(
"Couldn't write to file: %s" ).
Format( fName ) );
352 for (
auto lt : trackRange)
373 XO(
"Select a text file containing labels"),
381 if (!fileName.empty()) {
387 XO(
"Could not open file: %s").
Format( fileName ) );
391 auto newTrack = std::make_shared<LabelTrack>();
393 wxFileName::SplitPath(fileName, NULL, NULL, &sTrackName, NULL);
394 newTrack->SetName(sTrackName);
399 newTrack->SetSelected(
true);
403 XO(
"Imported labels from '%s'").
Format( fileName ),
404 XO(
"Import Labels"));
406 window.ZoomAfterImport(
nullptr);
418 wxCommandEvent evt{ wxEVT_MENU, wxID_EXIT };
419 wxTheApp->ProcessEvent( evt );
446 #ifdef EXPERIMENTAL_RESET
470 history.UseMenu( &theMenu );
472 wxWeakRef<wxMenu> recentFilesMenu{ &theMenu };
473 wxTheApp->CallAfter( [=] {
482 if ( recentFilesMenu )
483 recentFilesMenu->GetParent()->SetHelpString( 0,
"" );
517 Menu(
wxT(
"ExportOther"),
XXO(
"Export Other"),
561 Menu(
wxT(
"HiddenFileMenu"),
XXO(
"Hidden File Menu"),
596 wxT(
"Optional/Extra/Part1"),
int AudacityMessageBox(const TranslatableString &message, const TranslatableString &caption, long style, wxWindow *parent, int x, int y)
AttachedItem sAttachment1
AttachedItem sAttachment3
AttachedItem sAttachment2
constexpr CommandFlag AlwaysEnabledFlag
const ReservedCommandFlag & AudioIONotBusyFlag()
const ReservedCommandFlag & LabelTracksExistFlag()
const ReservedCommandFlag & WaveTracksExistFlag()
void ShowExportErrorDialog(const TranslatableString &message, const TranslatableString &caption, bool allowReporting)
XXO("&Cut/Copy/Paste Toolbar")
wxString FileExtension
File extension, not including any leading dot.
BoolSetting NewImportingSession
void ImportRaw(const AudacityProject &project, wxWindow *parent, const wxString &fileName, WaveTrackFactory *trackFactory, TrackHolders &outTracks)
std::vector< std::shared_ptr< TrackList > > TrackHolders
audacity::BasicSettings * gPrefs
an object holding per-project preferred sample rate
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...
virtual size_t NChannels() const =0
Report the number of channels.
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
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
ExportTaskBuilder & SetParameters(ExportProcessor::Parameters parameters) noexcept
ExportTaskBuilder & SetNumChannels(unsigned numChannels) noexcept
ExportTaskBuilder & SetSampleRate(double sampleRate) noexcept
ExportTaskBuilder & SetFileName(const wxFileName &filename)
ExportTaskBuilder & SetRange(double t0, double t1, bool selectedOnly=false) noexcept
static TrackIterRange< const WaveTrack > FindExportWaveTracks(const TrackList &tracks, bool selectedOnly)
static ExportProcessor::Parameters ParametersFromEditor(const ExportOptionsEditor &editor)
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 ProjectRate & Get(AudacityProject &project)
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)
static WaveTrackFactory & Get(AudacityProject &project)
A Track that contains audio waveform data.
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 void UpdateDefaultPath(Operation op, const FilePath &path)
FILES_API int CompareNoCase(const wxString &first, const wxString &second)
FILES_API FilePath FindDefaultPath(Operation op)
std::unique_ptr< detail::IndirectItem< Item > > Indirect(const std::shared_ptr< Item > &ptr)
A convenience function.
std::shared_ptr< BaseItem > BaseItemSharedPtr
void SelectNone(AudacityProject &project)
CommandManager::Options Options
double GetRate(const Track &track)