Break dependency cycle of Effect and EffectManager
This commit is contained in:
parent
0572c0a0d4
commit
37d730edfe
|
@ -17,7 +17,6 @@
|
|||
|
||||
#include "../Audacity.h"
|
||||
#include "Effect.h"
|
||||
#include "EffectManager.h"
|
||||
|
||||
#include "../Experimental.h"
|
||||
|
||||
|
@ -25,6 +24,7 @@
|
|||
|
||||
#include <wx/defs.h>
|
||||
#include <wx/sizer.h>
|
||||
#include <wx/tokenzr.h>
|
||||
|
||||
#include "../AudioIO.h"
|
||||
#include "../LabelTrack.h"
|
||||
|
@ -667,8 +667,7 @@ void Effect::ExportPresets()
|
|||
{
|
||||
wxString params;
|
||||
GetAutomationParameters(params);
|
||||
EffectManager & em = EffectManager::Get();
|
||||
wxString commandId = em.GetSquashedName(GetSymbol().Internal()).GET();
|
||||
wxString commandId = GetSquashedName(GetSymbol().Internal()).GET();
|
||||
params = commandId + ":" + params;
|
||||
|
||||
auto path = FileNames::DefaultToDocumentsFolder(wxT("Presets/Path"));
|
||||
|
@ -745,8 +744,7 @@ void Effect::ImportPresets()
|
|||
wxString ident = params.BeforeFirst(':');
|
||||
params = params.AfterFirst(':');
|
||||
|
||||
EffectManager & em = EffectManager::Get();
|
||||
wxString commandId = em.GetSquashedName(GetSymbol().Internal()).GET();
|
||||
wxString commandId = GetSquashedName(GetSymbol().Internal()).GET();
|
||||
|
||||
if (ident != commandId) {
|
||||
// effect identifiers are a sensible length!
|
||||
|
@ -775,6 +773,30 @@ void Effect::ImportPresets()
|
|||
|
||||
}
|
||||
|
||||
CommandID Effect::GetSquashedName(wxString name)
|
||||
{
|
||||
// Get rid of leading and trailing white space
|
||||
name.Trim(true).Trim(false);
|
||||
|
||||
if (name.empty())
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
wxStringTokenizer st(name, wxT(" "));
|
||||
wxString id;
|
||||
|
||||
// CamelCase the name
|
||||
while (st.HasMoreTokens())
|
||||
{
|
||||
wxString tok = st.GetNextToken();
|
||||
|
||||
id += tok.Left(1).MakeUpper() + tok.Mid(1).MakeLower();
|
||||
}
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
bool Effect::HasOptions()
|
||||
{
|
||||
return false;
|
||||
|
|
|
@ -168,6 +168,8 @@ class AUDACITY_DLL_API Effect /* not final */ : public wxEvtHandler,
|
|||
void ExportPresets() override;
|
||||
void ImportPresets() override;
|
||||
|
||||
static CommandID GetSquashedName(wxString name);
|
||||
|
||||
bool HasOptions() override;
|
||||
void ShowOptions() override;
|
||||
|
||||
|
|
|
@ -122,31 +122,7 @@ TranslatableString EffectManager::GetVendorName(const PluginID & ID)
|
|||
CommandID EffectManager::GetCommandIdentifier(const PluginID & ID)
|
||||
{
|
||||
wxString name = PluginManager::Get().GetSymbol(ID).Internal();
|
||||
return GetSquashedName(name);
|
||||
}
|
||||
|
||||
CommandID EffectManager::GetSquashedName(wxString name)
|
||||
{
|
||||
// Get rid of leading and trailing white space
|
||||
name.Trim(true).Trim(false);
|
||||
|
||||
if (name.empty())
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
wxStringTokenizer st(name, wxT(" "));
|
||||
wxString id;
|
||||
|
||||
// CamelCase the name
|
||||
while (st.HasMoreTokens())
|
||||
{
|
||||
wxString tok = st.GetNextToken();
|
||||
|
||||
id += tok.Left(1).MakeUpper() + tok.Mid(1).MakeLower();
|
||||
}
|
||||
|
||||
return id;
|
||||
return Effect::GetSquashedName(name);
|
||||
}
|
||||
|
||||
TranslatableString EffectManager::GetCommandDescription(const PluginID & ID)
|
||||
|
|
|
@ -94,7 +94,6 @@ public:
|
|||
ComponentInterfaceSymbol GetCommandSymbol(const PluginID & ID);
|
||||
TranslatableString GetCommandName(const PluginID & ID);
|
||||
CommandID GetCommandIdentifier(const PluginID & ID);
|
||||
CommandID GetSquashedName(wxString name);
|
||||
TranslatableString GetCommandDescription(const PluginID & ID);
|
||||
wxString GetCommandUrl(const PluginID & ID);
|
||||
wxString GetCommandTip(const PluginID & ID);
|
||||
|
|
Loading…
Reference in New Issue