1#include "../CommonCommandFlags.h"
8#include "../ProjectFileManager.h"
10#include "../ProjectManager.h"
11#include "../ProjectWindows.h"
14#include "../TagsEditor.h"
15#include "../SelectUtilities.h"
24#include "../import/ImportRaw.h"
26#include "../widgets/FileHistory.h"
27#include "../widgets/MissingPluginsErrorDialog.h"
49 wxString projectName =
project.GetProjectName();
52 bool bPromptingRequired = !
project.mBatchMode ||
53 projectName.empty() ||
56 if (bPromptingRequired) {
60 XO(
"All audio is muted."),
86 wxFileName fileName(pathName, projectName,
format.Lower());
89 const wxString macroDir(
"macro-output" );
90 if (fileName.GetDirs().empty() || fileName.GetDirs().back() != macroDir) {
91 fileName.AppendDir(macroDir);
94 wxString justName = fileName.GetName();
96 FilePath fullPath = fileName.GetFullPath();
98 if (wxFileName::FileExists(fileName.GetPath())) {
100 XO(
"Cannot create directory '%s'. \n"
101 "File already exists that is not a directory"),
105 fileName.Mkdir(0777, wxPATH_MKDIR_FULL);
109 if(plugin !=
nullptr)
111 auto editor = plugin->CreateOptionsEditor(formatIndex,
nullptr);
122 bool success =
false;
131 if (success && !
project.mBatchMode) {
146 if (selectedFiles.size() == 0) {
158 auto cleanup =
finally( [&] {
161 viewport.ZoomFitHorizontallyAndShowTrack(
nullptr);
162 viewport.HandleResize();
165 wxArrayString filesToImport;
166 for (
size_t ff = 0; ff < selectedFiles.size(); ff++) {
167 wxString fileName = selectedFiles[ff];
176 if (newTracks.size() > 0) {
182 filesToImport.Add(fileName);
200 int unavailablePlugins = 0;
203 for (
auto track : trackList.Any<
WaveTrack>())
206 effects.Visit([&unavailablePlugins](
auto& state,
bool)
208 const auto& ID = state.GetID();
214 unavailablePlugins++;
218 unavailablePlugins++;
223 if (unavailablePlugins > 0)
258 projectFileManager.Save();
265 projectFileManager.SaveAs();
272 projectFileManager.SaveCopy();
314 wxString fName =
_(
"labels.txt");
316 auto numLabelTracks = trackRange.
size();
318 if (numLabelTracks == 0) {
323 fName = (*trackRange.rbegin())->GetName();
325 fName =
SelectFile(FileNames::Operation::Export,
326 XO(
"Export Labels As:"),
331 wxFD_SAVE | wxFD_OVERWRITE_PROMPT | wxRESIZE_BORDER,
342 if (wxFileExists(fName)) {
344 wxString safetyFileName = fName +
wxT(
"~");
346 wxString safetyFileName = fName +
wxT(
".bak");
349 if (wxFileExists(safetyFileName))
350 wxRemoveFile(safetyFileName);
352 wxRename(fName, safetyFileName);
360 XO(
"Couldn't write to file: %s" ).
Format( fName ) );
364 for (
auto lt : trackRange)
385 XO(
"Select a text file containing labels"),
393 if (!fileName.empty()) {
400 XO(
"Could not open file: %s").
Format( fileName ) );
404 auto newTrack = std::make_shared<LabelTrack>();
406 wxFileName::SplitPath(fileName, NULL, NULL, &sTrackName, NULL);
407 newTrack->SetName(sTrackName);
409 newTrack->Import(f,
format);
412 newTrack->SetSelected(
true);
416 XO(
"Imported labels from '%s'").
Format( fileName ),
417 XO(
"Import Labels"));
419 viewport.ZoomFitHorizontallyAndShowTrack(
nullptr);
431 wxCommandEvent evt{ wxEVT_MENU, wxID_EXIT };
432 wxTheApp->ProcessEvent( evt );
459 static auto menu = std::shared_ptr{
470 #ifdef EXPERIMENTAL_RESET
494 history.UseMenu( &theMenu );
496 wxWeakRef<wxMenu> recentFilesMenu{ &theMenu };
497 wxTheApp->CallAfter( [=] {
506 if ( recentFilesMenu )
507 recentFilesMenu->GetParent()->SetHelpString( 0,
"" );
536 Menu(
wxT(
"ExportOther"),
XXO(
"Expo&rt Other"),
572 static auto menu = std::shared_ptr{
592 wxT(
"Optional/Extra/Part1")
int AudacityMessageBox(const TranslatableString &message, const TranslatableString &caption, long style, wxWindow *parent, int x, int y)
AttachedItem sAttachment1
AttachedItem sAttachment3
constexpr CommandFlag AlwaysEnabledFlag
const ReservedCommandFlag & AudioIONotBusyFlag()
const ReservedCommandFlag & LabelTracksExistFlag()
const ReservedCommandFlag & TimeSelectedFlag()
const ReservedCommandFlag & WaveTracksExistFlag()
const ReservedCommandFlag & WaveTracksSelectedFlag()
void ShowExportErrorDialog(const TranslatableString &message, const TranslatableString &caption, bool allowReporting)
@ ShareAudioExportExtraMenu
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< Track > > 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 void PerformInteractiveExport(AudacityProject &project, const FileExtension &format, AudiocomTrace trace, bool selectedOnly)
static ExportProcessor::Parameters ParametersFromEditor(const ExportOptionsEditor &editor)
static bool HasSelectedAudio(const AudacityProject &project)
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).
static const FileNames::FileType WebVTTFiles
static const FileNames::FileType SubripFiles
static LabelFormat FormatForFileName(const wxString &fileName)
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 RealtimeEffectList & Get(AudacityProject &project)
Generates classes whose instances register items at construction.
bool Write(const T &value)
Write value to config and return true if successful.
static TrackList & Get(AudacityProject &project)
static Viewport & Get(AudacityProject &project)
static WaveTrackFactory & Get(AudacityProject &project)
A Track that contains audio waveform data.
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 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.
void SelectNone(AudacityProject &project)
ProjectFileIOExtensionRegistry::Extension extension
double GetRate(const Track &track)