mirror of
https://github.com/cookiengineer/audacity
synced 2025-08-01 08:29:27 +02:00
Show friendly names of commands in message boxes...
... With spaces in the English; maybe later they will localize
This commit is contained in:
parent
9298ac575d
commit
77f720b0c8
@ -595,9 +595,11 @@ bool MacroCommands::WriteMp3File( const wxString & Name, int bitrate )
|
|||||||
// and think again.
|
// and think again.
|
||||||
// ======= IMPORTANT ========
|
// ======= IMPORTANT ========
|
||||||
// CLEANSPEECH remnant
|
// CLEANSPEECH remnant
|
||||||
bool MacroCommands::ApplySpecialCommand(int WXUNUSED(iCommand), const wxString & command,const wxString & params)
|
bool MacroCommands::ApplySpecialCommand(
|
||||||
|
int WXUNUSED(iCommand), const wxString &friendlyCommand,
|
||||||
|
const wxString & command, const wxString & params)
|
||||||
{
|
{
|
||||||
if (ReportAndSkip(command, params))
|
if (ReportAndSkip(friendlyCommand, params))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
AudacityProject *project = GetActiveProject();
|
AudacityProject *project = GetActiveProject();
|
||||||
@ -674,15 +676,19 @@ bool MacroCommands::ApplySpecialCommand(int WXUNUSED(iCommand), const wxString &
|
|||||||
return false;
|
return false;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
AudacityMessageBox(wxString::Format(_("Command %s not implemented yet"),command));
|
AudacityMessageBox(
|
||||||
|
wxString::Format(_("Command %s not implemented yet"), friendlyCommand));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// end CLEANSPEECH remnant
|
// end CLEANSPEECH remnant
|
||||||
|
|
||||||
bool MacroCommands::ApplyEffectCommand(const PluginID & ID, const wxString & command, const wxString & params, const CommandContext & Context)
|
bool MacroCommands::ApplyEffectCommand(
|
||||||
|
const PluginID & ID, const wxString &friendlyCommand,
|
||||||
|
const wxString & command, const wxString & params,
|
||||||
|
const CommandContext & Context)
|
||||||
{
|
{
|
||||||
//Possibly end processing here, if in batch-debug
|
//Possibly end processing here, if in batch-debug
|
||||||
if( ReportAndSkip(command, params))
|
if( ReportAndSkip(friendlyCommand, params))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
const PluginDescriptor *plug = PluginManager::Get().GetPlugin(ID);
|
const PluginDescriptor *plug = PluginManager::Get().GetPlugin(ID);
|
||||||
@ -723,7 +729,9 @@ bool MacroCommands::ApplyEffectCommand(const PluginID & ID, const wxString & com
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MacroCommands::ApplyCommand(const wxString & command, const wxString & params, CommandContext const * pContext)
|
bool MacroCommands::ApplyCommand( const wxString &friendlyCommand,
|
||||||
|
const wxString & command, const wxString & params,
|
||||||
|
CommandContext const * pContext)
|
||||||
{
|
{
|
||||||
|
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
@ -731,7 +739,7 @@ bool MacroCommands::ApplyCommand(const wxString & command, const wxString & para
|
|||||||
// CLEANSPEECH remnant
|
// CLEANSPEECH remnant
|
||||||
for( i = 0; i < sizeof(SpecialCommands)/sizeof(*SpecialCommands); ++i ) {
|
for( i = 0; i < sizeof(SpecialCommands)/sizeof(*SpecialCommands); ++i ) {
|
||||||
if( command.IsSameAs( SpecialCommands[i].second, false) )
|
if( command.IsSameAs( SpecialCommands[i].second, false) )
|
||||||
return ApplySpecialCommand( i, command, params );
|
return ApplySpecialCommand( i, friendlyCommand, command, params );
|
||||||
}
|
}
|
||||||
// end CLEANSPEECH remnant
|
// end CLEANSPEECH remnant
|
||||||
|
|
||||||
@ -740,9 +748,11 @@ bool MacroCommands::ApplyCommand(const wxString & command, const wxString & para
|
|||||||
if (!ID.empty())
|
if (!ID.empty())
|
||||||
{
|
{
|
||||||
if( pContext )
|
if( pContext )
|
||||||
return ApplyEffectCommand(ID, command, params, *pContext);
|
return ApplyEffectCommand(
|
||||||
|
ID, friendlyCommand, command, params, *pContext);
|
||||||
const CommandContext context( *GetActiveProject() );
|
const CommandContext context( *GetActiveProject() );
|
||||||
return ApplyEffectCommand(ID, command, params, context);
|
return ApplyEffectCommand(
|
||||||
|
ID, friendlyCommand, command, params, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
AudacityProject *project = GetActiveProject();
|
AudacityProject *project = GetActiveProject();
|
||||||
@ -751,7 +761,7 @@ bool MacroCommands::ApplyCommand(const wxString & command, const wxString & para
|
|||||||
if( pManager->HandleTextualCommand( command, *pContext, AlwaysEnabledFlag, AlwaysEnabledFlag ) )
|
if( pManager->HandleTextualCommand( command, *pContext, AlwaysEnabledFlag, AlwaysEnabledFlag ) )
|
||||||
return true;
|
return true;
|
||||||
pContext->Status( wxString::Format(
|
pContext->Status( wxString::Format(
|
||||||
_("Your batch command of %s was not recognized."), command ));
|
_("Your batch command of %s was not recognized."), friendlyCommand ));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -763,12 +773,13 @@ bool MacroCommands::ApplyCommand(const wxString & command, const wxString & para
|
|||||||
|
|
||||||
AudacityMessageBox(
|
AudacityMessageBox(
|
||||||
wxString::Format(
|
wxString::Format(
|
||||||
_("Your batch command of %s was not recognized."), command ));
|
_("Your batch command of %s was not recognized."), friendlyCommand ));
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MacroCommands::ApplyCommandInBatchMode(const wxString & command, const wxString ¶ms)
|
bool MacroCommands::ApplyCommandInBatchMode( const wxString &friendlyCommand,
|
||||||
|
const wxString & command, const wxString ¶ms)
|
||||||
{
|
{
|
||||||
AudacityProject *project = GetActiveProject();
|
AudacityProject *project = GetActiveProject();
|
||||||
|
|
||||||
@ -779,14 +790,15 @@ bool MacroCommands::ApplyCommandInBatchMode(const wxString & command, const wxSt
|
|||||||
project->SetShowId3Dialog(prevShowMode);
|
project->SetShowId3Dialog(prevShowMode);
|
||||||
} );
|
} );
|
||||||
|
|
||||||
return ApplyCommand( command, params );
|
return ApplyCommand( friendlyCommand, command, params );
|
||||||
}
|
}
|
||||||
|
|
||||||
static int MacroReentryCount = 0;
|
static int MacroReentryCount = 0;
|
||||||
// ApplyMacro returns true on success, false otherwise.
|
// ApplyMacro returns true on success, false otherwise.
|
||||||
// Any error reporting to the user in setting up the chain
|
// Any error reporting to the user in setting up the chain
|
||||||
// has already been done.
|
// has already been done.
|
||||||
bool MacroCommands::ApplyMacro(const wxString & filename)
|
bool MacroCommands::ApplyMacro(
|
||||||
|
const MacroCommandsCatalog &catalog, const wxString & filename)
|
||||||
{
|
{
|
||||||
// Check for reentrant ApplyMacro commands.
|
// Check for reentrant ApplyMacro commands.
|
||||||
// We'll allow 1 level of reentry, but not more.
|
// We'll allow 1 level of reentry, but not more.
|
||||||
@ -814,12 +826,17 @@ bool MacroCommands::ApplyMacro(const wxString & filename)
|
|||||||
mAbort = false;
|
mAbort = false;
|
||||||
|
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
for (; i < mCommandMacro.GetCount(); i++) {
|
for (; i < mCommandMacro.size(); i++) {
|
||||||
if (!ApplyCommandInBatchMode(mCommandMacro[i], mParamsMacro[i]) || mAbort)
|
const auto &command = mCommandMacro[i];
|
||||||
|
auto iter = catalog.ByCommandId(command);
|
||||||
|
auto friendly = (iter == catalog.end())
|
||||||
|
? command // Expose internal name to user, in default of a better one!
|
||||||
|
: iter->friendly;
|
||||||
|
if (!ApplyCommandInBatchMode(friendly, command, mParamsMacro[i]) || mAbort)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
res = (i == mCommandMacro.GetCount());
|
res = (i == mCommandMacro.size());
|
||||||
if (!res)
|
if (!res)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -887,7 +904,8 @@ void MacroCommands::ResetMacro()
|
|||||||
|
|
||||||
// ReportAndSkip() is a diagnostic function that avoids actually
|
// ReportAndSkip() is a diagnostic function that avoids actually
|
||||||
// applying the requested effect if in batch-debug mode.
|
// applying the requested effect if in batch-debug mode.
|
||||||
bool MacroCommands::ReportAndSkip(const wxString & command, const wxString & params)
|
bool MacroCommands::ReportAndSkip(
|
||||||
|
const wxString & friendlyCommand, const wxString & params)
|
||||||
{
|
{
|
||||||
int bDebug;
|
int bDebug;
|
||||||
gPrefs->Read(wxT("/Batch/Debug"), &bDebug, false);
|
gPrefs->Read(wxT("/Batch/Debug"), &bDebug, false);
|
||||||
@ -897,12 +915,12 @@ bool MacroCommands::ReportAndSkip(const wxString & command, const wxString & par
|
|||||||
//TODO: Add a cancel button to these, and add the logic so that we can abort.
|
//TODO: Add a cancel button to these, and add the logic so that we can abort.
|
||||||
if( params != wxT("") )
|
if( params != wxT("") )
|
||||||
{
|
{
|
||||||
AudacityMessageBox( wxString::Format(_("Apply %s with parameter(s)\n\n%s"),command, params),
|
AudacityMessageBox( wxString::Format(_("Apply %s with parameter(s)\n\n%s"),friendlyCommand, params),
|
||||||
_("Test Mode"));
|
_("Test Mode"));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
AudacityMessageBox( wxString::Format(_("Apply %s"),command),
|
AudacityMessageBox( wxString::Format(_("Apply %s"), friendlyCommand),
|
||||||
_("Test Mode"));
|
_("Test Mode"));
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -55,12 +55,21 @@ class MacroCommands final {
|
|||||||
// constructors and destructors
|
// constructors and destructors
|
||||||
MacroCommands();
|
MacroCommands();
|
||||||
public:
|
public:
|
||||||
bool ApplyMacro(const wxString & filename = wxT(""));
|
bool ApplyMacro( const MacroCommandsCatalog &catalog,
|
||||||
bool ApplyCommand( const wxString & command, const wxString & params, CommandContext const * pContext=NULL );
|
const wxString & filename = wxT(""));
|
||||||
bool ApplyCommandInBatchMode(const wxString & command, const wxString ¶ms);
|
bool ApplyCommand( const wxString &friendlyCommand,
|
||||||
bool ApplySpecialCommand(int iCommand, const wxString & command,const wxString & params);
|
const wxString & command, const wxString & params,
|
||||||
bool ApplyEffectCommand(const PluginID & ID, const wxString & command, const wxString & params, const CommandContext & Context);
|
CommandContext const * pContext=NULL );
|
||||||
bool ReportAndSkip( const wxString & command, const wxString & params );
|
bool ApplyCommandInBatchMode( const wxString &friendlyCommand,
|
||||||
|
const wxString & command, const wxString ¶ms);
|
||||||
|
bool ApplySpecialCommand(
|
||||||
|
int iCommand, const wxString &friendlyCommand,
|
||||||
|
const wxString & command, const wxString & params);
|
||||||
|
bool ApplyEffectCommand(
|
||||||
|
const PluginID & ID, const wxString &friendlyCommand,
|
||||||
|
const wxString & command,
|
||||||
|
const wxString & params, const CommandContext & Context);
|
||||||
|
bool ReportAndSkip( const wxString & friendlyCommand, const wxString & params );
|
||||||
void AbortBatch();
|
void AbortBatch();
|
||||||
|
|
||||||
// Utility functions for the special commands.
|
// Utility functions for the special commands.
|
||||||
|
@ -73,6 +73,7 @@ ApplyMacroDialog::ApplyMacroDialog(wxWindow * parent, bool bInherited):
|
|||||||
wxDialogWrapper(parent, wxID_ANY, _("Apply Macro"),
|
wxDialogWrapper(parent, wxID_ANY, _("Apply Macro"),
|
||||||
wxDefaultPosition, wxDefaultSize,
|
wxDefaultPosition, wxDefaultSize,
|
||||||
wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
|
wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
|
||||||
|
, mCatalog( GetActiveProject() )
|
||||||
{
|
{
|
||||||
//AudacityProject * p = GetActiveProject();
|
//AudacityProject * p = GetActiveProject();
|
||||||
mAbort = false;
|
mAbort = false;
|
||||||
@ -269,7 +270,7 @@ void ApplyMacroDialog::ApplyMacroToProject( int iMacro, bool bHasGui )
|
|||||||
{
|
{
|
||||||
wxWindowDisabler wd(&activityWin);
|
wxWindowDisabler wd(&activityWin);
|
||||||
success = GuardedCall< bool >(
|
success = GuardedCall< bool >(
|
||||||
[this]{ return mMacroCommands.ApplyMacro(); } );
|
[this]{ return mMacroCommands.ApplyMacro(mCatalog); } );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !bHasGui )
|
if( !bHasGui )
|
||||||
@ -436,7 +437,7 @@ void ApplyMacroDialog::OnApplyToFiles(wxCommandEvent & WXUNUSED(event))
|
|||||||
project->Import(files[i]);
|
project->Import(files[i]);
|
||||||
project->ZoomAfterImport(nullptr);
|
project->ZoomAfterImport(nullptr);
|
||||||
project->OnSelectAll(*project);
|
project->OnSelectAll(*project);
|
||||||
if (!mMacroCommands.ApplyMacro())
|
if (!mMacroCommands.ApplyMacro(mCatalog))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!activityWin.IsShown() || mAbort)
|
if (!activityWin.IsShown() || mAbort)
|
||||||
@ -525,7 +526,6 @@ enum {
|
|||||||
/// Constructor
|
/// Constructor
|
||||||
MacrosWindow::MacrosWindow(wxWindow * parent, bool bExpanded):
|
MacrosWindow::MacrosWindow(wxWindow * parent, bool bExpanded):
|
||||||
ApplyMacroDialog(parent, true)
|
ApplyMacroDialog(parent, true)
|
||||||
, mCatalog( GetActiveProject() )
|
|
||||||
{
|
{
|
||||||
mbExpanded = bExpanded;
|
mbExpanded = bExpanded;
|
||||||
SetLabel(_("Manage Macros")); // Provide visual label
|
SetLabel(_("Manage Macros")); // Provide visual label
|
||||||
|
@ -74,6 +74,9 @@ class ApplyMacroDialog : public wxDialogWrapper {
|
|||||||
bool mbExpanded;
|
bool mbExpanded;
|
||||||
wxString mActiveMacro;
|
wxString mActiveMacro;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
const MacroCommandsCatalog mCatalog;
|
||||||
|
|
||||||
DECLARE_EVENT_TABLE()
|
DECLARE_EVENT_TABLE()
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -142,8 +145,6 @@ private:
|
|||||||
int mSelectedCommand;
|
int mSelectedCommand;
|
||||||
bool mChanged;
|
bool mChanged;
|
||||||
|
|
||||||
const MacroCommandsCatalog mCatalog;
|
|
||||||
|
|
||||||
DECLARE_EVENT_TABLE()
|
DECLARE_EVENT_TABLE()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -39,21 +39,29 @@ OldStyleCommandPointer BatchEvalCommandType::Create(std::unique_ptr<CommandOutpu
|
|||||||
|
|
||||||
bool BatchEvalCommand::Apply(const CommandContext & context)
|
bool BatchEvalCommand::Apply(const CommandContext & context)
|
||||||
{
|
{
|
||||||
|
// Uh oh, I need to build a catalog, expensively
|
||||||
|
// Maybe it can be built in one long-lived place and shared among command
|
||||||
|
// objects instead?
|
||||||
|
MacroCommandsCatalog catalog(&context.project);
|
||||||
|
|
||||||
wxString macroName = GetString(wxT("MacroName"));
|
wxString macroName = GetString(wxT("MacroName"));
|
||||||
if (macroName != wxT(""))
|
if (macroName != wxT(""))
|
||||||
{
|
{
|
||||||
MacroCommands batch;
|
MacroCommands batch;
|
||||||
batch.ReadMacro(macroName);
|
batch.ReadMacro(macroName);
|
||||||
return batch.ApplyMacro();
|
return batch.ApplyMacro(catalog);
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString cmdName = GetString(wxT("CommandName"));
|
wxString cmdName = GetString(wxT("CommandName"));
|
||||||
wxString cmdParams = GetString(wxT("ParamString"));
|
wxString cmdParams = GetString(wxT("ParamString"));
|
||||||
|
auto iter = catalog.ByCommandId(cmdName);
|
||||||
|
const wxString &friendly = (iter == catalog.end())
|
||||||
|
? cmdName // Expose internal name to user, in default of a better one!
|
||||||
|
: iter->friendly;
|
||||||
|
|
||||||
// Create a Batch that will have just one command in it...
|
// Create a Batch that will have just one command in it...
|
||||||
MacroCommands Batch;
|
MacroCommands Batch;
|
||||||
bool bResult = Batch.ApplyCommand(cmdName, cmdParams, &context);
|
bool bResult = Batch.ApplyCommand(friendly, cmdName, cmdParams, &context);
|
||||||
// Relay messages, if any.
|
// Relay messages, if any.
|
||||||
wxString Message = Batch.GetMessage();
|
wxString Message = Batch.GetMessage();
|
||||||
if( !Message.IsEmpty() )
|
if( !Message.IsEmpty() )
|
||||||
|
Loading…
x
Reference in New Issue
Block a user