From 575070e9ae35013a5400c383df19b091a0c581a4 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Tue, 16 Jan 2018 00:39:47 -0500 Subject: [PATCH] Remove PluginDescriptor::GetTranslatedEffectFamily... ... and instead look it up by ID, and find the effect's family name Simplifying what was done at 4628d6afa7a553a242f00ee8c1be0e72c5692052 --- src/Menus.cpp | 14 ++++++++------ src/PluginManager.cpp | 34 ---------------------------------- src/PluginManager.h | 4 +++- src/effects/EffectManager.cpp | 8 ++++++++ src/effects/EffectManager.h | 1 + 5 files changed, 20 insertions(+), 41 deletions(-) diff --git a/src/Menus.cpp b/src/Menus.cpp index 8f3091391..703c7c7cd 100644 --- a/src/Menus.cpp +++ b/src/Menus.cpp @@ -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()) diff --git a/src/PluginManager.cpp b/src/PluginManager.cpp index 78feab786..1537b1622 100644 --- a/src/PluginManager.cpp +++ b/src/PluginManager.cpp @@ -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; diff --git a/src/PluginManager.h b/src/PluginManager.h index 388fc688c..276a81465 100644 --- a/src/PluginManager.h +++ b/src/PluginManager.h @@ -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; diff --git a/src/effects/EffectManager.cpp b/src/effects/EffectManager.cpp index 655850d6e..63f74fbc6 100644 --- a/src/effects/EffectManager.cpp +++ b/src/effects/EffectManager.cpp @@ -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)); diff --git a/src/effects/EffectManager.h b/src/effects/EffectManager.h index 37f558a83..d78055bb9 100644 --- a/src/effects/EffectManager.h +++ b/src/effects/EffectManager.h @@ -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);