1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-15 15:49:36 +02:00

Just one accessor for the name of a ComponentInterface...

... Translate it explicitly where needed.
This commit is contained in:
Paul Licameli 2019-12-19 11:44:00 -05:00
parent 16e66a1e7e
commit 092033b284
5 changed files with 21 additions and 29 deletions

View File

@ -137,10 +137,7 @@ public:
virtual TranslatableString GetDescription() = 0;
// non-virtual convenience function
const wxString GetTranslatedName();
// non-virtual convenience function
const TranslatableString GetUntranslatedName();
TranslatableString GetName();
// Parameters, if defined. false means no defined parameters.
virtual bool DefineParams( ShuttleParams & WXUNUSED(S) ){ return false;};

View File

@ -3212,14 +3212,9 @@ int PluginManager::b64decode(const wxString &in, void *out)
return p - (unsigned char *) out;
}
// These are defined out-of-line here, to keep ComponentInterface free of other
// This is defined out-of-line here, to keep ComponentInterface free of other
// #include directives.
const wxString ComponentInterface::GetTranslatedName()
{
return GetSymbol().Translation();
}
const TranslatableString ComponentInterface::GetUntranslatedName()
TranslatableString ComponentInterface::GetName()
{
return GetSymbol().Msgid();
}

View File

@ -126,7 +126,7 @@ bool AudacityCommand::ShowInterface(wxWindow *parent, bool WXUNUSED(forceModal))
wxDialog *AudacityCommand::CreateUI(wxWindow *parent, AudacityCommand * WXUNUSED(client))
{
Destroy_ptr<AudacityCommandDialog> dlg { safenew AudacityCommandDialog{
parent, GetUntranslatedName(), this}};
parent, GetName(), this}};
if (dlg->Init())
{
@ -170,7 +170,7 @@ bool AudacityCommand::SetAutomationParameters(const wxString & parms)
AudacityCommand::MessageBox(
wxString::Format(
_("%s: Could not load settings below. Default settings will be used.\n\n%s"),
GetTranslatedName(),
GetName().Translation(),
preset
)
);
@ -208,7 +208,7 @@ bool AudacityCommand::DoAudacityCommand(wxWindow *parent,
bool skipFlag = CheckWhetherSkipAudacityCommand();
if (skipFlag == false)
{
auto name = GetUntranslatedName();
auto name = GetName();
ProgressDialog progress{
name,
XO("Applying %s...").Format( name ),
@ -245,9 +245,9 @@ int AudacityCommand::MessageBox(const wxString& message, long style, const wxStr
{
wxString title;
if (titleStr.empty())
title = GetTranslatedName();
title = GetName().Translation();
else
title = wxString::Format(_("%s: %s"), GetTranslatedName(), titleStr);
title = wxString::Format(_("%s: %s"), GetName().Translation(), titleStr);
return AudacityMessageBox(message, title, style, mUIParent);
}

View File

@ -1083,7 +1083,7 @@ bool Effect::SetAutomationParameters(const wxString & parms)
Effect::MessageBox(
wxString::Format(
_("%s: Could not load settings below. Default settings will be used.\n\n%s"),
GetTranslatedName(),
GetName().Translation(),
preset
)
);
@ -1267,7 +1267,7 @@ bool Effect::DoEffect(wxWindow *parent,
bool skipFlag = CheckWhetherSkipEffect();
if (skipFlag == false)
{
auto name = GetUntranslatedName();
auto name = GetName();
ProgressDialog progress{
name,
XO("Applying %s...").Format( name ),
@ -2398,7 +2398,7 @@ void Effect::Preview(bool dryOnly)
// Apply effect
if (!dryOnly) {
ProgressDialog progress{
GetUntranslatedName(),
GetName(),
XO("Preparing preview"),
pdlgHideCancelButton
}; // Have only "Stop" button.
@ -2429,7 +2429,7 @@ void Effect::Preview(bool dryOnly)
// The progress dialog blocks these events.
{
ProgressDialog progress
(GetUntranslatedName(), XO("Previewing"), pdlgHideCancelButton);
(GetName(), XO("Previewing"), pdlgHideCancelButton);
while (gAudioIO->IsStreamActive(token) && previewing == ProgressResult::Success) {
::wxMilliSleep(100);
@ -2456,9 +2456,9 @@ int Effect::MessageBox
{
wxString title;
if (titleStr.empty())
title = GetTranslatedName();
title = GetName().Translation();
else
title = wxString::Format(_("%s: %s"), GetTranslatedName(), titleStr);
title = wxString::Format(_("%s: %s"), GetName().Translation(), titleStr);
return AudacityMessageBox(message, title, style, mUIParent);
}
@ -2639,7 +2639,7 @@ END_EVENT_TABLE()
EffectUIHost::EffectUIHost(wxWindow *parent,
Effect *effect,
EffectUIClientInterface *client)
: wxDialogWrapper(parent, wxID_ANY, effect->GetUntranslatedName(),
: wxDialogWrapper(parent, wxID_ANY, effect->GetName(),
wxDefaultPosition, wxDefaultSize,
wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxMINIMIZE_BOX | wxMAXIMIZE_BOX)
{
@ -2648,7 +2648,7 @@ EffectUIHost::EffectUIHost(wxWindow *parent,
[ [((NSView *)GetHandle()) window] setLevel:NSFloatingWindowLevel];
#endif
SetName( effect->GetUntranslatedName() );
SetName( effect->GetName() );
SetExtraStyle(GetExtraStyle() | wxWS_EX_VALIDATE_RECURSIVELY);
mParent = parent;
@ -2672,7 +2672,7 @@ EffectUIHost::EffectUIHost(wxWindow *parent,
EffectUIHost::EffectUIHost(wxWindow *parent,
AudacityCommand *command,
EffectUIClientInterface *client)
: wxDialogWrapper(parent, wxID_ANY, XO("Some Command") /*command->GetUntranslatedName()*/,
: wxDialogWrapper(parent, wxID_ANY, XO("Some Command") /*command->GetName()*/,
wxDefaultPosition, wxDefaultSize,
wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxMINIMIZE_BOX | wxMAXIMIZE_BOX)
{
@ -2681,7 +2681,7 @@ EffectUIHost::EffectUIHost(wxWindow *parent,
[ [((NSView *)GetHandle()) window] setLevel:NSFloatingWindowLevel];
#endif
//SetName( command->GetTranslatedName() );
//SetName( command->GetName() );
SetExtraStyle(wxWS_EX_VALIDATE_RECURSIVELY);
mParent = parent;
@ -3069,7 +3069,7 @@ void EffectUIHost::OnApply(wxCommandEvent & evt)
auto flags = AlwaysEnabledFlag;
bool allowed =
MenuManager::Get(*mProject).ReportIfActionNotAllowed(
mEffect->GetUntranslatedName(),
mEffect->GetName(),
flags,
WaveTracksSelectedFlag | TimeSelectedFlag);
if (!allowed)
@ -3235,7 +3235,7 @@ void EffectUIHost::OnMenu(wxCommandEvent & WXUNUSED(evt))
sub->Append(kDummyID, wxString::Format(_("Type: %s"),
::wxGetTranslation( mEffect->GetFamily().Translation() )));
sub->Append(kDummyID, wxString::Format(_("Name: %s"), mEffect->GetTranslatedName()));
sub->Append(kDummyID, wxString::Format(_("Name: %s"), mEffect->GetName().Translation()));
sub->Append(kDummyID, wxString::Format(_("Version: %s"), mEffect->GetVersion()));
sub->Append(kDummyID, wxString::Format(_("Vendor: %s"), mEffect->GetVendor().Translation()));
sub->Append(kDummyID, wxString::Format(_("Description: %s"), mEffect->GetDescription().Translation()));

View File

@ -254,7 +254,7 @@ void EffectRack::Add(Effect *effect, bool active, bool favorite)
mMainSizer->Add(bb, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL);
wxStaticText *text = safenew wxStaticText(mPanel, ID_NAME + mNumEffects,
effect->GetTranslatedName() );
effect->GetName().Translation() );
text->SetToolTip(_("Name of the effect"));
mMainSizer->Add(text, 0, wxEXPAND | wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL, 5);