Remove PluginDescriptor::GetTranslatedEffectFamily...

... and instead look it up by ID, and find the effect's family name

Simplifying what was done at 4628d6afa7
This commit is contained in:
Paul Licameli 2018-01-16 00:39:47 -05:00
parent 79a9f3f599
commit 575070e9ae
5 changed files with 20 additions and 41 deletions

View File

@ -227,8 +227,9 @@ static bool SortEffectsByPublisherAndName(const PluginDescriptor *a, const Plugi
static bool SortEffectsByTypeAndName(const PluginDescriptor *a, const PluginDescriptor *b)
{
wxString akey = a->GetTranslatedEffectFamily();
wxString bkey = b->GetTranslatedEffectFamily();
auto &em = EffectManager::Get();
auto akey = em.GetEffectFamilyName(a->GetID());
auto bkey = em.GetEffectFamilyName(b->GetID());
if (akey.IsEmpty())
{
@ -259,8 +260,9 @@ static bool SortEffectsByTypeAndName(const PluginDescriptor *a, const PluginDesc
static bool SortEffectsByType(const PluginDescriptor *a, const PluginDescriptor *b)
{
wxString akey = a->GetTranslatedEffectFamily();
wxString bkey = b->GetTranslatedEffectFamily();
auto &em = EffectManager::Get();
auto akey = em.GetEffectFamilyName(a->GetID());
auto bkey = em.GetEffectFamilyName(b->GetID());
if (akey.IsEmpty())
{
@ -1730,7 +1732,7 @@ void AudacityProject::AddEffectMenuItems(CommandManager *c,
}
else if (groupBy == wxT("groupby:type"))
{
current = plug->GetTranslatedEffectFamily();
current = EffectManager::Get().GetEffectFamilyName(plug->GetID());
if (current.IsEmpty())
{
current = _("Unknown");
@ -1791,7 +1793,7 @@ void AudacityProject::AddEffectMenuItems(CommandManager *c,
}
else if (groupBy == wxT("sortby:type:name"))
{
group = plug->GetTranslatedEffectFamily();
group = EffectManager::Get().GetEffectFamilyName(plug->GetID());
}
if (plug->IsEffectDefault())

View File

@ -1226,40 +1226,6 @@ wxString PluginDescriptor::GetEffectFamilyId() const
return mEffectFamily;
}
wxString PluginDescriptor::GetTranslatedEffectFamily() const
{
#if 0
return wxGetTranslation(mEffectFamily);
#else
// PRL: 2.2.2 hack to change the visible name without breaking
// compatibility of pluginsettings.cfg; redo this better
// Remap "Audacity" to "Built-in" (suitably translated)
// "Audacity" was the only possibility for mEffectFamily that was in the
// message catalog.
// The other possibilites are "VST", "LADSPA", "AudioUnit", "Nyquist",
// "LV2", "Vamp"
// None of these strings (yet) occur anywhere in the program in _() or XO()
// And we will leave them verbatim in other locales, as proper names
// See also EffectUIHost::OnMenu
// See also commits cafbff9ff82520ff7d4344570385752869c6d230 and
// c6bbe4c3dae8a52bb4b7a3c720af97bc3bd69769 for more about the complications
// involving this function
auto result = mEffectFamily;
if (result == wxT("Audacity"))
// Use XO so that this string does localize
result = XO("Built-in");
return wxGetTranslation( result );
#endif
}
EffectType PluginDescriptor::GetEffectType() const
{
return mEffectType;

View File

@ -89,8 +89,10 @@ public:
// Effect plugins only
// Internal string only, no translated counterpart!
// (Use Effect::GetFamilyName instead)
wxString GetEffectFamilyId() const;
wxString GetTranslatedEffectFamily() const;
EffectType GetEffectType() const;
bool IsEffectDefault() const;
bool IsEffectInteractive() const;

View File

@ -117,6 +117,14 @@ wxString EffectManager::GetEffectName(const PluginID & ID)
return PluginManager::Get().GetName(ID);
}
wxString EffectManager::GetEffectFamilyName(const PluginID & ID)
{
auto effect = GetEffect(ID);
if (effect)
return effect->GetFamilyName();
return {};
}
wxString EffectManager::GetEffectIdentifier(const PluginID & ID)
{
wxString name = (PluginManager::Get().GetSymbol(ID));

View File

@ -83,6 +83,7 @@ public:
bool shouldPrompt = true);
wxString GetEffectName(const PluginID & ID);
wxString GetEffectFamilyName(const PluginID & ID);
wxString GetEffectIdentifier(const PluginID & ID);
wxString GetEffectDescription(const PluginID & ID);
bool IsHidden(const PluginID & ID);