mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-15 15:49:36 +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.
|
||||
// ======= IMPORTANT ========
|
||||
// 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;
|
||||
|
||||
AudacityProject *project = GetActiveProject();
|
||||
@ -674,15 +676,19 @@ bool MacroCommands::ApplySpecialCommand(int WXUNUSED(iCommand), const wxString &
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
AudacityMessageBox(wxString::Format(_("Command %s not implemented yet"),command));
|
||||
AudacityMessageBox(
|
||||
wxString::Format(_("Command %s not implemented yet"), friendlyCommand));
|
||||
return false;
|
||||
}
|
||||
// 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
|
||||
if( ReportAndSkip(command, params))
|
||||
if( ReportAndSkip(friendlyCommand, params))
|
||||
return true;
|
||||
|
||||
const PluginDescriptor *plug = PluginManager::Get().GetPlugin(ID);
|
||||
@ -723,7 +729,9 @@ bool MacroCommands::ApplyEffectCommand(const PluginID & ID, const wxString & com
|
||||
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;
|
||||
@ -731,7 +739,7 @@ bool MacroCommands::ApplyCommand(const wxString & command, const wxString & para
|
||||
// CLEANSPEECH remnant
|
||||
for( i = 0; i < sizeof(SpecialCommands)/sizeof(*SpecialCommands); ++i ) {
|
||||
if( command.IsSameAs( SpecialCommands[i].second, false) )
|
||||
return ApplySpecialCommand( i, command, params );
|
||||
return ApplySpecialCommand( i, friendlyCommand, command, params );
|
||||
}
|
||||
// end CLEANSPEECH remnant
|
||||
|
||||
@ -740,9 +748,11 @@ bool MacroCommands::ApplyCommand(const wxString & command, const wxString & para
|
||||
if (!ID.empty())
|
||||
{
|
||||
if( pContext )
|
||||
return ApplyEffectCommand(ID, command, params, *pContext);
|
||||
return ApplyEffectCommand(
|
||||
ID, friendlyCommand, command, params, *pContext);
|
||||
const CommandContext context( *GetActiveProject() );
|
||||
return ApplyEffectCommand(ID, command, params, context);
|
||||
return ApplyEffectCommand(
|
||||
ID, friendlyCommand, command, params, context);
|
||||
}
|
||||
|
||||
AudacityProject *project = GetActiveProject();
|
||||
@ -751,7 +761,7 @@ bool MacroCommands::ApplyCommand(const wxString & command, const wxString & para
|
||||
if( pManager->HandleTextualCommand( command, *pContext, AlwaysEnabledFlag, AlwaysEnabledFlag ) )
|
||||
return true;
|
||||
pContext->Status( wxString::Format(
|
||||
_("Your batch command of %s was not recognized."), command ));
|
||||
_("Your batch command of %s was not recognized."), friendlyCommand ));
|
||||
return false;
|
||||
}
|
||||
else
|
||||
@ -763,12 +773,13 @@ bool MacroCommands::ApplyCommand(const wxString & command, const wxString & para
|
||||
|
||||
AudacityMessageBox(
|
||||
wxString::Format(
|
||||
_("Your batch command of %s was not recognized."), command ));
|
||||
_("Your batch command of %s was not recognized."), friendlyCommand ));
|
||||
|
||||
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();
|
||||
|
||||
@ -779,14 +790,15 @@ bool MacroCommands::ApplyCommandInBatchMode(const wxString & command, const wxSt
|
||||
project->SetShowId3Dialog(prevShowMode);
|
||||
} );
|
||||
|
||||
return ApplyCommand( command, params );
|
||||
return ApplyCommand( friendlyCommand, command, params );
|
||||
}
|
||||
|
||||
static int MacroReentryCount = 0;
|
||||
// ApplyMacro returns true on success, false otherwise.
|
||||
// Any error reporting to the user in setting up the chain
|
||||
// has already been done.
|
||||
bool MacroCommands::ApplyMacro(const wxString & filename)
|
||||
bool MacroCommands::ApplyMacro(
|
||||
const MacroCommandsCatalog &catalog, const wxString & filename)
|
||||
{
|
||||
// Check for reentrant ApplyMacro commands.
|
||||
// We'll allow 1 level of reentry, but not more.
|
||||
@ -814,12 +826,17 @@ bool MacroCommands::ApplyMacro(const wxString & filename)
|
||||
mAbort = false;
|
||||
|
||||
size_t i = 0;
|
||||
for (; i < mCommandMacro.GetCount(); i++) {
|
||||
if (!ApplyCommandInBatchMode(mCommandMacro[i], mParamsMacro[i]) || mAbort)
|
||||
for (; i < mCommandMacro.size(); i++) {
|
||||
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;
|
||||
}
|
||||
|
||||
res = (i == mCommandMacro.GetCount());
|
||||
res = (i == mCommandMacro.size());
|
||||
if (!res)
|
||||
return false;
|
||||
|
||||
@ -887,7 +904,8 @@ void MacroCommands::ResetMacro()
|
||||
|
||||
// ReportAndSkip() is a diagnostic function that avoids actually
|
||||
// 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;
|
||||
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.
|
||||
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"));
|
||||
}
|
||||
else
|
||||
{
|
||||
AudacityMessageBox( wxString::Format(_("Apply %s"),command),
|
||||
AudacityMessageBox( wxString::Format(_("Apply %s"), friendlyCommand),
|
||||
_("Test Mode"));
|
||||
}
|
||||
return true;
|
||||
|
@ -55,12 +55,21 @@ class MacroCommands final {
|
||||
// constructors and destructors
|
||||
MacroCommands();
|
||||
public:
|
||||
bool ApplyMacro(const wxString & filename = wxT(""));
|
||||
bool ApplyCommand( const wxString & command, const wxString & params, CommandContext const * pContext=NULL );
|
||||
bool ApplyCommandInBatchMode(const wxString & command, const wxString ¶ms);
|
||||
bool ApplySpecialCommand(int iCommand, const wxString & command,const wxString & params);
|
||||
bool ApplyEffectCommand(const PluginID & ID, const wxString & command, const wxString & params, const CommandContext & Context);
|
||||
bool ReportAndSkip( const wxString & command, const wxString & params );
|
||||
bool ApplyMacro( const MacroCommandsCatalog &catalog,
|
||||
const wxString & filename = wxT(""));
|
||||
bool ApplyCommand( const wxString &friendlyCommand,
|
||||
const wxString & command, const wxString & params,
|
||||
CommandContext const * pContext=NULL );
|
||||
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();
|
||||
|
||||
// Utility functions for the special commands.
|
||||
|
@ -73,6 +73,7 @@ ApplyMacroDialog::ApplyMacroDialog(wxWindow * parent, bool bInherited):
|
||||
wxDialogWrapper(parent, wxID_ANY, _("Apply Macro"),
|
||||
wxDefaultPosition, wxDefaultSize,
|
||||
wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
|
||||
, mCatalog( GetActiveProject() )
|
||||
{
|
||||
//AudacityProject * p = GetActiveProject();
|
||||
mAbort = false;
|
||||
@ -269,7 +270,7 @@ void ApplyMacroDialog::ApplyMacroToProject( int iMacro, bool bHasGui )
|
||||
{
|
||||
wxWindowDisabler wd(&activityWin);
|
||||
success = GuardedCall< bool >(
|
||||
[this]{ return mMacroCommands.ApplyMacro(); } );
|
||||
[this]{ return mMacroCommands.ApplyMacro(mCatalog); } );
|
||||
}
|
||||
|
||||
if( !bHasGui )
|
||||
@ -436,7 +437,7 @@ void ApplyMacroDialog::OnApplyToFiles(wxCommandEvent & WXUNUSED(event))
|
||||
project->Import(files[i]);
|
||||
project->ZoomAfterImport(nullptr);
|
||||
project->OnSelectAll(*project);
|
||||
if (!mMacroCommands.ApplyMacro())
|
||||
if (!mMacroCommands.ApplyMacro(mCatalog))
|
||||
return false;
|
||||
|
||||
if (!activityWin.IsShown() || mAbort)
|
||||
@ -525,7 +526,6 @@ enum {
|
||||
/// Constructor
|
||||
MacrosWindow::MacrosWindow(wxWindow * parent, bool bExpanded):
|
||||
ApplyMacroDialog(parent, true)
|
||||
, mCatalog( GetActiveProject() )
|
||||
{
|
||||
mbExpanded = bExpanded;
|
||||
SetLabel(_("Manage Macros")); // Provide visual label
|
||||
|
@ -74,6 +74,9 @@ class ApplyMacroDialog : public wxDialogWrapper {
|
||||
bool mbExpanded;
|
||||
wxString mActiveMacro;
|
||||
|
||||
protected:
|
||||
const MacroCommandsCatalog mCatalog;
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
@ -142,8 +145,6 @@ private:
|
||||
int mSelectedCommand;
|
||||
bool mChanged;
|
||||
|
||||
const MacroCommandsCatalog mCatalog;
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
|
@ -39,21 +39,29 @@ OldStyleCommandPointer BatchEvalCommandType::Create(std::unique_ptr<CommandOutpu
|
||||
|
||||
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"));
|
||||
if (macroName != wxT(""))
|
||||
{
|
||||
MacroCommands batch;
|
||||
batch.ReadMacro(macroName);
|
||||
return batch.ApplyMacro();
|
||||
return batch.ApplyMacro(catalog);
|
||||
}
|
||||
|
||||
wxString cmdName = GetString(wxT("CommandName"));
|
||||
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...
|
||||
MacroCommands Batch;
|
||||
bool bResult = Batch.ApplyCommand(cmdName, cmdParams, &context);
|
||||
bool bResult = Batch.ApplyCommand(friendly, cmdName, cmdParams, &context);
|
||||
// Relay messages, if any.
|
||||
wxString Message = Batch.GetMessage();
|
||||
if( !Message.IsEmpty() )
|
||||
|
Loading…
x
Reference in New Issue
Block a user