mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-16 08:09:32 +02:00
Friendlier command names in the Edit Chains dialogs...
... Both the pane that lists the steps of the chain, and the selection dialog for adding a new step. NOT translating command names yet, though.
This commit is contained in:
parent
fa53d521a2
commit
0319d6ea68
@ -118,16 +118,15 @@ void BatchCommandDialog::PopulateOrExchange(ShuttleGui &S)
|
|||||||
|
|
||||||
void BatchCommandDialog::PopulateCommandList()
|
void BatchCommandDialog::PopulateCommandList()
|
||||||
{
|
{
|
||||||
wxArrayString commandList = BatchCommands::GetAllCommands();
|
mCommandNames = BatchCommands::GetAllCommands();
|
||||||
|
|
||||||
unsigned int i;
|
|
||||||
mChoices->DeleteAllItems();
|
mChoices->DeleteAllItems();
|
||||||
for( i=0;i<commandList.GetCount();i++)
|
for (size_t ii = 0, size = mCommandNames.size(); ii < size; ++ii)
|
||||||
{
|
// insert the user-facing string
|
||||||
mChoices->InsertItem( i, commandList[i]);
|
mChoices->InsertItem( ii, mCommandNames[ii].first );
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
int BatchCommandDialog::GetSelectedItem()
|
int BatchCommandDialog::GetSelectedItem()
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
@ -142,6 +141,7 @@ int BatchCommandDialog::GetSelectedItem()
|
|||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void BatchCommandDialog::ValidateChoices()
|
void BatchCommandDialog::ValidateChoices()
|
||||||
{
|
{
|
||||||
@ -153,7 +153,7 @@ void BatchCommandDialog::OnChoice(wxCommandEvent & WXUNUSED(event))
|
|||||||
|
|
||||||
void BatchCommandDialog::OnOk(wxCommandEvent & WXUNUSED(event))
|
void BatchCommandDialog::OnOk(wxCommandEvent & WXUNUSED(event))
|
||||||
{
|
{
|
||||||
mSelectedCommand = mCommand->GetValue().Strip(wxString::both);
|
mSelectedCommand = mInternalCommandName.Strip(wxString::both);
|
||||||
mSelectedParameters = mParameters->GetValue().Strip(wxString::trailing);
|
mSelectedParameters = mParameters->GetValue().Strip(wxString::trailing);
|
||||||
EndModal(true);
|
EndModal(true);
|
||||||
}
|
}
|
||||||
@ -165,24 +165,23 @@ void BatchCommandDialog::OnCancel(wxCommandEvent & WXUNUSED(event))
|
|||||||
|
|
||||||
void BatchCommandDialog::OnItemSelected(wxListEvent &event)
|
void BatchCommandDialog::OnItemSelected(wxListEvent &event)
|
||||||
{
|
{
|
||||||
wxString command = mChoices->GetItemText(event.GetIndex());
|
const auto &command = mCommandNames[ event.GetIndex() ];
|
||||||
|
|
||||||
EffectManager & em = EffectManager::Get();
|
EffectManager & em = EffectManager::Get();
|
||||||
PluginID ID = em.GetEffectByIdentifier(command);
|
PluginID ID = em.GetEffectByIdentifier(command.second);
|
||||||
|
|
||||||
// If ID is empty, then the effect wasn't found, in which case, the user must have
|
// If ID is empty, then the effect wasn't found, in which case, the user must have
|
||||||
// selected one of the "special" commands.
|
// selected one of the "special" commands.
|
||||||
mEditParams->Enable(!ID.IsEmpty());
|
mEditParams->Enable(!ID.IsEmpty());
|
||||||
mUsePreset->Enable(em.HasPresets(ID));
|
mUsePreset->Enable(em.HasPresets(ID));
|
||||||
|
|
||||||
if (command == mCommand->GetValue())
|
if (command.first == mCommand->GetValue())
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
mCommand->SetValue(command);
|
mCommand->SetValue(command.first);
|
||||||
|
mInternalCommandName = command.second;
|
||||||
|
|
||||||
wxString params = BatchCommands::GetCurrentParamsFor(command);
|
wxString params = BatchCommands::GetCurrentParamsFor(command.second);
|
||||||
if (params.IsEmpty())
|
if (params.IsEmpty())
|
||||||
{
|
{
|
||||||
params = em.GetDefaultPreset(ID);
|
params = em.GetDefaultPreset(ID);
|
||||||
@ -193,7 +192,7 @@ void BatchCommandDialog::OnItemSelected(wxListEvent &event)
|
|||||||
|
|
||||||
void BatchCommandDialog::OnEditParams(wxCommandEvent & WXUNUSED(event))
|
void BatchCommandDialog::OnEditParams(wxCommandEvent & WXUNUSED(event))
|
||||||
{
|
{
|
||||||
wxString command = mCommand->GetValue();
|
wxString command = mInternalCommandName;
|
||||||
wxString params = mParameters->GetValue();
|
wxString params = mParameters->GetValue();
|
||||||
|
|
||||||
params = BatchCommands::PromptForParamsFor(command, params, this).Trim();
|
params = BatchCommands::PromptForParamsFor(command, params, this).Trim();
|
||||||
@ -204,7 +203,7 @@ void BatchCommandDialog::OnEditParams(wxCommandEvent & WXUNUSED(event))
|
|||||||
|
|
||||||
void BatchCommandDialog::OnUsePreset(wxCommandEvent & WXUNUSED(event))
|
void BatchCommandDialog::OnUsePreset(wxCommandEvent & WXUNUSED(event))
|
||||||
{
|
{
|
||||||
wxString command = mCommand->GetValue();
|
wxString command = mInternalCommandName;
|
||||||
wxString params = mParameters->GetValue();
|
wxString params = mParameters->GetValue();
|
||||||
|
|
||||||
wxString preset = BatchCommands::PromptForPresetFor(command, params, this).Trim();
|
wxString preset = BatchCommands::PromptForPresetFor(command, params, this).Trim();
|
||||||
@ -215,12 +214,17 @@ void BatchCommandDialog::OnUsePreset(wxCommandEvent & WXUNUSED(event))
|
|||||||
|
|
||||||
void BatchCommandDialog::SetCommandAndParams(const wxString &Command, const wxString &Params)
|
void BatchCommandDialog::SetCommandAndParams(const wxString &Command, const wxString &Params)
|
||||||
{
|
{
|
||||||
mCommand->SetValue( Command );
|
auto item = make_iterator_range(mCommandNames).index_if(
|
||||||
|
[&](const CommandName &name){ return Command == name.second; }
|
||||||
|
);
|
||||||
|
|
||||||
mParameters->SetValue( Params );
|
mParameters->SetValue( Params );
|
||||||
|
|
||||||
int item = mChoices->FindItem(-1, Command);
|
mInternalCommandName = Command;
|
||||||
if (item != wxNOT_FOUND)
|
if (item < 0)
|
||||||
{
|
mCommand->SetValue( Command );
|
||||||
|
else {
|
||||||
|
mCommand->SetValue( mCommandNames[item].first );
|
||||||
mChoices->SetItemState(item, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
|
mChoices->SetItemState(item, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
|
||||||
|
|
||||||
EffectManager & em = EffectManager::Get();
|
EffectManager & em = EffectManager::Get();
|
||||||
|
@ -56,13 +56,20 @@ class BatchCommandDialog final : public wxDialogWrapper {
|
|||||||
|
|
||||||
void ValidateChoices();
|
void ValidateChoices();
|
||||||
void PopulateCommandList();
|
void PopulateCommandList();
|
||||||
int GetSelectedItem();
|
//int GetSelectedItem();
|
||||||
|
|
||||||
wxButton *mEditParams;
|
wxButton *mEditParams;
|
||||||
wxButton *mUsePreset;
|
wxButton *mUsePreset;
|
||||||
wxListCtrl *mChoices;
|
wxListCtrl *mChoices;
|
||||||
wxTextCtrl * mCommand;
|
wxTextCtrl * mCommand;
|
||||||
wxTextCtrl * mParameters;
|
wxTextCtrl * mParameters;
|
||||||
|
|
||||||
|
wxString mInternalCommandName;
|
||||||
|
|
||||||
|
using CommandName = std::pair<wxString, wxString>;
|
||||||
|
using CommandNameVector = std::vector<CommandName>;
|
||||||
|
CommandNameVector mCommandNames;
|
||||||
|
|
||||||
DECLARE_EVENT_TABLE()
|
DECLARE_EVENT_TABLE()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -54,15 +54,30 @@ enum eCommandType { CtEffect, CtMenu, CtSpecial };
|
|||||||
// TIDY-ME: Not currently translated,
|
// TIDY-ME: Not currently translated,
|
||||||
// but there are issues to address if we do.
|
// but there are issues to address if we do.
|
||||||
// CLEANSPEECH remnant
|
// CLEANSPEECH remnant
|
||||||
static wxString SpecialCommands[] = {
|
static const std::pair<const wxChar*, const wxChar*> SpecialCommands[] = {
|
||||||
wxT("NoAction"),
|
// Use translations of the first members, some other day.
|
||||||
// wxT("Import"), // non-functioning
|
// For 2.2.2 we'll get them into the catalog at least.
|
||||||
wxT("ExportMP3_56k_before"),
|
|
||||||
wxT("ExportMP3_56k_after"),
|
{ XO("No Action"), wxT("NoAction") },
|
||||||
wxT("ExportFLAC"),
|
|
||||||
wxT("ExportMP3"),
|
// { wxT("Import"), wxT("Import") }, // non-functioning
|
||||||
wxT("ExportOgg"),
|
/* i18n-hint: before is adverb; MP3 names an audio file format */
|
||||||
wxT("ExportWAV")
|
{ XO("Export as MP3 56k before"), wxT("ExportMP3_56k_before") },
|
||||||
|
|
||||||
|
/* i18n-hint: after is adverb; MP3 names an audio file format */
|
||||||
|
{ XO("Export as MP3 56k after"), wxT("ExportMP3_56k_after") },
|
||||||
|
|
||||||
|
/* i18n-hint: FLAC names an audio file format */
|
||||||
|
{ XO("Export as FLAC"), wxT("ExportFLAC") },
|
||||||
|
|
||||||
|
/* i18n-hint: MP3 names an audio file format */
|
||||||
|
{ XO("Export as MP3"), wxT("ExportMP3") },
|
||||||
|
|
||||||
|
/* i18n-hint: Ogg names an audio file format */
|
||||||
|
{ XO("Export as Ogg"), wxT("ExportOgg") },
|
||||||
|
|
||||||
|
/* i18n-hint: WAV names an audio file format */
|
||||||
|
{ XO("Export as WAV"), wxT("ExportWAV") },
|
||||||
};
|
};
|
||||||
// end CLEANSPEECH remnant
|
// end CLEANSPEECH remnant
|
||||||
|
|
||||||
@ -259,25 +274,22 @@ void BatchCommands::SetWavToMp3Chain() // a function per default chain? This is
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Gets all commands that are valid for this mode.
|
// Gets all commands that are valid for this mode.
|
||||||
wxArrayString BatchCommands::GetAllCommands()
|
auto BatchCommands::GetAllCommands() -> CommandNameVector
|
||||||
{
|
{
|
||||||
wxArrayString commands;
|
CommandNameVector commands;
|
||||||
wxString command;
|
|
||||||
commands.Clear();
|
|
||||||
|
|
||||||
AudacityProject *project = GetActiveProject();
|
AudacityProject *project = GetActiveProject();
|
||||||
if (!project)
|
if (!project)
|
||||||
{
|
|
||||||
return commands;
|
return commands;
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int i;
|
|
||||||
|
|
||||||
// CLEANSPEECH remnant
|
// CLEANSPEECH remnant
|
||||||
for(i=0;i<sizeof(SpecialCommands)/sizeof(SpecialCommands[0]);i++)
|
for( const auto &command : SpecialCommands )
|
||||||
{
|
commands.push_back( {
|
||||||
commands.Add( SpecialCommands[i] );
|
//wxGetTranslation
|
||||||
}
|
(command.first),
|
||||||
|
command.second
|
||||||
|
} );
|
||||||
|
|
||||||
// end CLEANSPEECH remnant
|
// end CLEANSPEECH remnant
|
||||||
|
|
||||||
PluginManager & pm = PluginManager::Get();
|
PluginManager & pm = PluginManager::Get();
|
||||||
@ -285,15 +297,23 @@ wxArrayString BatchCommands::GetAllCommands()
|
|||||||
const PluginDescriptor *plug = pm.GetFirstPlugin(PluginTypeEffect);
|
const PluginDescriptor *plug = pm.GetFirstPlugin(PluginTypeEffect);
|
||||||
while (plug)
|
while (plug)
|
||||||
{
|
{
|
||||||
command = em.GetEffectIdentifier(plug->GetID());
|
auto command = em.GetEffectIdentifier(plug->GetID());
|
||||||
if (!command.IsEmpty())
|
if (!command.IsEmpty())
|
||||||
{
|
commands.push_back( {
|
||||||
commands.Add(command);
|
plug->GetUntranslatedName(), // plug->GetTranslatedName(),
|
||||||
}
|
command
|
||||||
|
} );
|
||||||
plug = pm.GetNextPlugin(PluginTypeEffect);
|
plug = pm.GetNextPlugin(PluginTypeEffect);
|
||||||
}
|
}
|
||||||
|
|
||||||
commands.Sort();
|
// Sort commands by their user-visible names.
|
||||||
|
// PRL: What should happen if first members of pairs are not unique?
|
||||||
|
// Sort stably?
|
||||||
|
std::sort(
|
||||||
|
commands.begin(), commands.end(),
|
||||||
|
[](const CommandName &a, const CommandName &b)
|
||||||
|
{ return a.first < b.first; }
|
||||||
|
);
|
||||||
|
|
||||||
/* This is for later in development: include the menu commands.
|
/* This is for later in development: include the menu commands.
|
||||||
CommandManager * mManager = project->GetCommandManager();
|
CommandManager * mManager = project->GetCommandManager();
|
||||||
@ -626,9 +646,8 @@ bool BatchCommands::ApplyCommand(const wxString & command, const wxString & para
|
|||||||
unsigned int i;
|
unsigned int i;
|
||||||
// Test for a special command.
|
// Test for a special command.
|
||||||
// CLEANSPEECH remnant
|
// CLEANSPEECH remnant
|
||||||
for(i=0;i<sizeof(SpecialCommands)/sizeof(SpecialCommands[0]);i++)
|
for( i = 0; i < sizeof(SpecialCommands)/sizeof(*SpecialCommands); ++i ) {
|
||||||
{
|
if( command == SpecialCommands[i].second )
|
||||||
if( command == SpecialCommands[i] )
|
|
||||||
return ApplySpecialCommand( i, command, params );
|
return ApplySpecialCommand( i, command, params );
|
||||||
}
|
}
|
||||||
// end CLEANSPEECH remnant
|
// end CLEANSPEECH remnant
|
||||||
|
@ -40,7 +40,12 @@ class BatchCommands final {
|
|||||||
|
|
||||||
// These commands do not depend on the command list.
|
// These commands do not depend on the command list.
|
||||||
static wxArrayString GetNames();
|
static wxArrayString GetNames();
|
||||||
static wxArrayString GetAllCommands();
|
|
||||||
|
// A pair of user-visible name, and internal string identifier
|
||||||
|
using CommandName = std::pair<wxString, wxString>;
|
||||||
|
using CommandNameVector = std::vector<CommandName>;
|
||||||
|
// Result is sorted by user-visible name
|
||||||
|
static CommandNameVector GetAllCommands();
|
||||||
|
|
||||||
static wxString GetCurrentParamsFor(const wxString & command);
|
static wxString GetCurrentParamsFor(const wxString & command);
|
||||||
static wxString PromptForParamsFor(const wxString & command, const wxString & params, wxWindow *parent);
|
static wxString PromptForParamsFor(const wxString & command, const wxString & params, wxWindow *parent);
|
||||||
|
@ -486,6 +486,8 @@ EditChainsDialog::~EditChainsDialog()
|
|||||||
/// Creates the dialog and its contents.
|
/// Creates the dialog and its contents.
|
||||||
void EditChainsDialog::Populate()
|
void EditChainsDialog::Populate()
|
||||||
{
|
{
|
||||||
|
mCommandNames = BatchCommands::GetAllCommands();
|
||||||
|
|
||||||
//------------------------- Main section --------------------
|
//------------------------- Main section --------------------
|
||||||
ShuttleGui S(this, eIsCreating);
|
ShuttleGui S(this, eIsCreating);
|
||||||
PopulateOrExchange(S);
|
PopulateOrExchange(S);
|
||||||
@ -627,11 +629,20 @@ void EditChainsDialog::PopulateList()
|
|||||||
/// Add one item into mList
|
/// Add one item into mList
|
||||||
void EditChainsDialog::AddItem(const wxString &Action, const wxString &Params)
|
void EditChainsDialog::AddItem(const wxString &Action, const wxString &Params)
|
||||||
{
|
{
|
||||||
|
// Translate internal command name to a friendly form
|
||||||
|
auto item = make_iterator_range(mCommandNames).index_if(
|
||||||
|
[&](const CommandName &name){ return Action == name.second; }
|
||||||
|
);
|
||||||
|
auto friendlyName = item >= 0
|
||||||
|
? // wxGetTranslation
|
||||||
|
( mCommandNames[item].first )
|
||||||
|
: Action;
|
||||||
|
|
||||||
int i = mList->GetItemCount();
|
int i = mList->GetItemCount();
|
||||||
|
|
||||||
mList->InsertItem(i, wxT(""));
|
mList->InsertItem(i, wxT(""));
|
||||||
mList->SetItem(i, ItemNumberColumn, wxString::Format(wxT(" %02i"), i + 1));
|
mList->SetItem(i, ItemNumberColumn, wxString::Format(wxT(" %02i"), i + 1));
|
||||||
mList->SetItem(i, ActionColumn, Action );
|
mList->SetItem(i, ActionColumn, friendlyName );
|
||||||
mList->SetItem(i, ParamsColumn, Params );
|
mList->SetItem(i, ParamsColumn, Params );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,6 +110,10 @@ private:
|
|||||||
int mSelectedCommand;
|
int mSelectedCommand;
|
||||||
bool mChanged;
|
bool mChanged;
|
||||||
|
|
||||||
|
using CommandName = std::pair<wxString, wxString>;
|
||||||
|
using CommandNameVector = std::vector<CommandName>;
|
||||||
|
CommandNameVector mCommandNames;
|
||||||
|
|
||||||
DECLARE_EVENT_TABLE()
|
DECLARE_EVENT_TABLE()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user