Bug 1856 - Applying Macros to Files is no longer a batch process
This restores the 2.2.2 behaviour, with a subdirectory called 'cleaned'. The problem was that 2.2.2 used special cases for MP3 Ogg and WAV exports, which were stripped out in favour of using the built-in Export command. However, the differences in behaviour (prompting) between batch and non batch mode were not taken into account.
This commit is contained in:
parent
9f7fa4e1f9
commit
c94df54157
|
@ -798,19 +798,22 @@ bool MacroCommands::ApplyCommand( const wxString &friendlyCommand,
|
|||
}
|
||||
|
||||
bool MacroCommands::ApplyCommandInBatchMode( const wxString &friendlyCommand,
|
||||
const wxString & command, const wxString ¶ms)
|
||||
const wxString & command, const wxString ¶ms,
|
||||
CommandContext const * pContext)
|
||||
{
|
||||
AudacityProject *project = GetActiveProject();
|
||||
// Recalc flags and enable items that may have become enabled.
|
||||
project->UpdateMenus(false);
|
||||
// enter batch mode...
|
||||
bool prevShowMode = project->GetShowId3Dialog();
|
||||
project->mBatchMode++;
|
||||
auto cleanup = finally( [&] {
|
||||
// exit batch mode...
|
||||
project->SetShowId3Dialog(prevShowMode);
|
||||
project->mBatchMode--;
|
||||
} );
|
||||
|
||||
return ApplyCommand( friendlyCommand, command, params );
|
||||
return ApplyCommand( friendlyCommand, command, params, pContext );
|
||||
}
|
||||
|
||||
static int MacroReentryCount = 0;
|
||||
|
|
|
@ -60,7 +60,8 @@ class MacroCommands final {
|
|||
const wxString & command, const wxString & params,
|
||||
CommandContext const * pContext=NULL );
|
||||
bool ApplyCommandInBatchMode( const wxString &friendlyCommand,
|
||||
const wxString & command, const wxString ¶ms);
|
||||
const wxString & command, const wxString ¶ms,
|
||||
CommandContext const * pContext = NULL);
|
||||
bool ApplySpecialCommand(
|
||||
int iCommand, const wxString &friendlyCommand,
|
||||
const wxString & command, const wxString & params);
|
||||
|
@ -72,10 +73,10 @@ class MacroCommands final {
|
|||
void AbortBatch();
|
||||
|
||||
// Utility functions for the special commands.
|
||||
wxString BuildCleanFileName(const wxString &fileName, const wxString &extension);
|
||||
static wxString BuildCleanFileName(const wxString &fileName, const wxString &extension);
|
||||
bool WriteMp3File( const wxString & Name, int bitrate );
|
||||
double GetEndTime();
|
||||
bool IsMono();
|
||||
static bool IsMono();
|
||||
|
||||
// These commands do not depend on the command list.
|
||||
static void MigrateLegacyChains();
|
||||
|
|
|
@ -4957,10 +4957,37 @@ void AudacityProject::OnExportMIDI(const CommandContext &WXUNUSED(context) ){
|
|||
void AudacityProject::OnExport(const wxString & Format )
|
||||
{
|
||||
Exporter e;
|
||||
e.SetDefaultFormat( Format );
|
||||
|
||||
wxGetApp().SetMissingAliasedFileWarningShouldShow(true);
|
||||
e.Process(this, false, 0.0, mTracks->GetEndTime());
|
||||
double t0 = 0.0;
|
||||
double t1 = mTracks->GetEndTime();
|
||||
|
||||
// Prompt for file name and/or extension?
|
||||
bool bPromptingRequired = (mBatchMode == 0) || mFileName.IsEmpty() || Format.IsEmpty();
|
||||
|
||||
if (bPromptingRequired) {
|
||||
e.SetDefaultFormat(Format);
|
||||
e.Process(this, false, 0.0, mTracks->GetEndTime());
|
||||
}
|
||||
else {
|
||||
// We're in batch mode, and we have an mFileName and Format.
|
||||
wxString extension = ".";
|
||||
extension += Format;
|
||||
extension.MakeLower();
|
||||
|
||||
wxString filename = MacroCommands::BuildCleanFileName(mFileName, extension);
|
||||
|
||||
int nChannels = MacroCommands::IsMono() ? 1 : 2;
|
||||
e.Process(
|
||||
this, // AudacityProject
|
||||
nChannels, // numChannels,
|
||||
Format, // type,
|
||||
filename, // filename,
|
||||
false, // selectedOnly,
|
||||
t0, // t0
|
||||
t1 // t1
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void AudacityProject::OnExportAudio(const CommandContext &WXUNUSED(context) ){ OnExport("");}
|
||||
|
|
|
@ -706,6 +706,7 @@ private:
|
|||
wxString mHelpPref;
|
||||
wxString mSoloPref;
|
||||
bool mbBusyImporting{ false }; // used to fix bug 584
|
||||
int mBatchMode{ 0 };// 0 menas not, >0 means in batch mode.
|
||||
|
||||
void SetNormalizedWindowState(wxRect pSizeAndLocation) { mNormalizedWindowState = pSizeAndLocation; }
|
||||
wxRect GetNormalizedWindowState() const { return mNormalizedWindowState; }
|
||||
|
|
|
@ -61,7 +61,7 @@ bool BatchEvalCommand::Apply(const CommandContext & context)
|
|||
|
||||
// Create a Batch that will have just one command in it...
|
||||
MacroCommands Batch;
|
||||
bool bResult = Batch.ApplyCommand(friendly, cmdName, cmdParams, &context);
|
||||
bool bResult = Batch.ApplyCommandInBatchMode(friendly, cmdName, cmdParams, &context);
|
||||
// Relay messages, if any.
|
||||
wxString Message = Batch.GetMessage();
|
||||
if( !Message.IsEmpty() )
|
||||
|
|
Loading…
Reference in New Issue
Block a user