mirror of
https://github.com/cookiengineer/audacity
synced 2025-07-03 14:13:11 +02:00
Don't duplicate registry path calculation in PluginManager.cpp
This commit is contained in:
parent
15983499c8
commit
82e3ec6818
@ -1396,6 +1396,31 @@ const PluginID &PluginManagerInterface::AudacityCommandRegistrationCallback(
|
|||||||
return empty;
|
return empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RegistryPath PluginManager::GetPluginEnabledSetting( const PluginID &ID )
|
||||||
|
{
|
||||||
|
auto pPlugin = GetPlugin( ID );
|
||||||
|
if ( pPlugin )
|
||||||
|
return GetPluginEnabledSetting( *pPlugin );
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
RegistryPath PluginManager::GetPluginEnabledSetting(
|
||||||
|
const PluginDescriptor &desc )
|
||||||
|
{
|
||||||
|
switch ( desc.GetPluginType() ) {
|
||||||
|
case PluginTypeEffect: {
|
||||||
|
// Retrieve optional family symbol that was recorded in
|
||||||
|
// RegisterPlugin() for the module
|
||||||
|
auto family = desc.GetEffectFamily();
|
||||||
|
if ( family.empty() )
|
||||||
|
return {};
|
||||||
|
else
|
||||||
|
return wxT('/') + family + wxT("/Enable");
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool PluginManager::IsPluginRegistered(const PluginPath &path)
|
bool PluginManager::IsPluginRegistered(const PluginPath &path)
|
||||||
{
|
{
|
||||||
@ -2509,9 +2534,13 @@ const PluginDescriptor *PluginManager::GetFirstPlugin(int type)
|
|||||||
if( plug.IsValid() && plug.IsEnabled() && ((plugType & type) != 0))
|
if( plug.IsValid() && plug.IsEnabled() && ((plugType & type) != 0))
|
||||||
{
|
{
|
||||||
bool familyEnabled = true;
|
bool familyEnabled = true;
|
||||||
if( (plugType & PluginTypeEffect) != 0)
|
if( (plugType & PluginTypeEffect) != 0) {
|
||||||
// This preference may be written by EffectsPrefs
|
// This preference may be written by EffectsPrefs
|
||||||
gPrefs->Read(plug.GetEffectFamily() + wxT("/Enable"), &familyEnabled, true);
|
auto setting = GetPluginEnabledSetting( plug );
|
||||||
|
familyEnabled = setting.empty()
|
||||||
|
? true
|
||||||
|
: gPrefs->Read( setting, true );
|
||||||
|
}
|
||||||
if (familyEnabled)
|
if (familyEnabled)
|
||||||
return &mPluginsIter->second;
|
return &mPluginsIter->second;
|
||||||
}
|
}
|
||||||
@ -2529,9 +2558,13 @@ const PluginDescriptor *PluginManager::GetNextPlugin(int type)
|
|||||||
if( plug.IsValid() && plug.IsEnabled() && ((plugType & type) != 0))
|
if( plug.IsValid() && plug.IsEnabled() && ((plugType & type) != 0))
|
||||||
{
|
{
|
||||||
bool familyEnabled = true;
|
bool familyEnabled = true;
|
||||||
if( (plugType & PluginTypeEffect) != 0)
|
if( (plugType & PluginTypeEffect) != 0) {
|
||||||
// This preference may be written by EffectsPrefs
|
// This preference may be written by EffectsPrefs
|
||||||
gPrefs->Read(plug.GetEffectFamily() + wxT("/Enable"), &familyEnabled, true);
|
auto setting = GetPluginEnabledSetting( plug );
|
||||||
|
familyEnabled = setting.empty()
|
||||||
|
? true
|
||||||
|
: gPrefs->Read( setting, true );
|
||||||
|
}
|
||||||
if (familyEnabled)
|
if (familyEnabled)
|
||||||
return &mPluginsIter->second;
|
return &mPluginsIter->second;
|
||||||
}
|
}
|
||||||
@ -2548,7 +2581,10 @@ const PluginDescriptor *PluginManager::GetFirstPluginForEffectType(EffectType ty
|
|||||||
|
|
||||||
bool familyEnabled;
|
bool familyEnabled;
|
||||||
// This preference may be written by EffectsPrefs
|
// This preference may be written by EffectsPrefs
|
||||||
gPrefs->Read(plug.GetEffectFamily() + wxT("/Enable"), &familyEnabled, true);
|
auto setting = GetPluginEnabledSetting( plug );
|
||||||
|
familyEnabled = setting.empty()
|
||||||
|
? true
|
||||||
|
: gPrefs->Read( setting, true );
|
||||||
if (plug.IsValid() && plug.IsEnabled() && plug.GetEffectType() == type && familyEnabled)
|
if (plug.IsValid() && plug.IsEnabled() && plug.GetEffectType() == type && familyEnabled)
|
||||||
{
|
{
|
||||||
return &plug;
|
return &plug;
|
||||||
@ -2565,7 +2601,10 @@ const PluginDescriptor *PluginManager::GetNextPluginForEffectType(EffectType typ
|
|||||||
PluginDescriptor & plug = mPluginsIter->second;
|
PluginDescriptor & plug = mPluginsIter->second;
|
||||||
bool familyEnabled;
|
bool familyEnabled;
|
||||||
// This preference may be written by EffectsPrefs
|
// This preference may be written by EffectsPrefs
|
||||||
gPrefs->Read(plug.GetEffectFamily() + wxT("/Enable"), &familyEnabled, true);
|
auto setting = GetPluginEnabledSetting( plug );
|
||||||
|
familyEnabled = setting.empty()
|
||||||
|
? true
|
||||||
|
: gPrefs->Read( setting, true );
|
||||||
if (plug.IsValid() && plug.IsEnabled() && plug.GetEffectType() == type && familyEnabled)
|
if (plug.IsValid() && plug.IsEnabled() && plug.GetEffectType() == type && familyEnabled)
|
||||||
{
|
{
|
||||||
return &plug;
|
return &plug;
|
||||||
|
@ -173,6 +173,9 @@ class PluginManager final : public PluginManagerInterface
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
RegistryPath GetPluginEnabledSetting( const PluginID &ID );
|
||||||
|
RegistryPath GetPluginEnabledSetting( const PluginDescriptor &desc );
|
||||||
|
|
||||||
// PluginManagerInterface implementation
|
// PluginManagerInterface implementation
|
||||||
|
|
||||||
bool IsPluginRegistered(const PluginPath &path) override;
|
bool IsPluginRegistered(const PluginPath &path) override;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user