1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-10-21 22:12:58 +02:00

Move DoAudacityCommand out of PluginMenus

This commit is contained in:
Paul Licameli
2019-06-12 22:52:52 -04:00
parent 1c588fa014
commit 691eee681c
4 changed files with 50 additions and 47 deletions

View File

@@ -27,6 +27,7 @@ processing. See also MacrosWindow and ApplyMacroDialog.
#include "Project.h"
#include "ProjectHistory.h"
#include "ProjectSettings.h"
#include "ProjectWindow.h"
#include "commands/CommandManager.h"
#include "effects/EffectManager.h"
#include "FileNames.h"
@@ -702,6 +703,49 @@ bool MacroCommands::ApplySpecialCommand(
}
// end CLEANSPEECH remnant
/// DoAudacityCommand() takes a PluginID and executes the assocated command.
///
/// At the moment flags are used only to indicate whether to prompt for
/// parameters
bool MacroCommands::DoAudacityCommand(
const PluginID & ID, const CommandContext & context, unsigned flags )
{
auto &project = context.project;
auto &window = ProjectWindow::Get( project );
const PluginDescriptor *plug = PluginManager::Get().GetPlugin(ID);
if (!plug)
return false;
if (flags & EffectManager::kConfigured)
{
TransportActions::DoStop(project);
// SelectAllIfNone();
}
EffectManager & em = EffectManager::Get();
bool success = em.DoAudacityCommand(ID,
context,
&window,
(flags & EffectManager::kConfigured) == 0);
if (!success)
return false;
/*
if (em.GetSkipStateFlag())
flags = flags | OnEffectFlags::kSkipState;
if (!(flags & OnEffectFlags::kSkipState))
{
wxString shortDesc = em.GetCommandName(ID);
wxString longDesc = em.GetCommandDescription(ID);
PushState(longDesc, shortDesc);
}
*/
window.RedrawProject();
return true;
}
bool MacroCommands::ApplyEffectCommand(
const PluginID & ID, const wxString &friendlyCommand,
const CommandID & command, const wxString & params,
@@ -734,7 +778,7 @@ bool MacroCommands::ApplyEffectCommand(
{
if( plug->GetPluginType() == PluginTypeAudacityCommand )
// and apply the effect...
res = PluginActions::DoAudacityCommand(ID,
res = DoAudacityCommand(ID,
Context,
EffectManager::kConfigured |
EffectManager::kSkipState |

View File

@@ -54,6 +54,9 @@ private:
// Stores information for one macro
class MacroCommands final {
public:
static bool DoAudacityCommand(
const PluginID & ID, const CommandContext & context, unsigned flags );
// constructors and destructors
MacroCommands();
public:

View File

@@ -142,8 +142,6 @@ void DoRecord( AudacityProject & );
namespace PluginActions {
bool DoEffect(
const PluginID & ID, const CommandContext & context, unsigned flags );
bool DoAudacityCommand(
const PluginID & ID, const CommandContext & context, unsigned flags );
}
/// Namespace for functions for Help menu

View File

@@ -546,49 +546,6 @@ bool DoEffect(
return true;
}
/// DoAudacityCommand() takes a PluginID and executes the assocated command.
///
/// At the moment flags are used only to indicate whether to prompt for
/// parameters
bool DoAudacityCommand(
const PluginID & ID, const CommandContext & context, unsigned flags )
{
auto &project = context.project;
auto &window = ProjectWindow::Get( project );
const PluginDescriptor *plug = PluginManager::Get().GetPlugin(ID);
if (!plug)
return false;
if (flags & EffectManager::kConfigured)
{
TransportActions::DoStop(project);
// SelectAllIfNone();
}
EffectManager & em = EffectManager::Get();
bool success = em.DoAudacityCommand(ID,
context,
&window,
(flags & EffectManager::kConfigured) == 0);
if (!success)
return false;
/*
if (em.GetSkipStateFlag())
flags = flags | OnEffectFlags::kSkipState;
if (!(flags & OnEffectFlags::kSkipState))
{
wxString shortDesc = em.GetCommandName(ID);
wxString longDesc = em.GetCommandDescription(ID);
PushState(longDesc, shortDesc);
}
*/
window.RedrawProject();
return true;
}
// Menu handler functions
struct Handler : CommandHandlerObject {
@@ -742,7 +699,8 @@ void OnAudacityCommand(const CommandContext & ctx)
// using GET in a log message for devs' eyes only
wxLogDebug( "Command was: %s", ctx.parameter.GET());
// Not configured, so prompt user.
DoAudacityCommand(EffectManager::Get().GetEffectByIdentifier(ctx.parameter),
MacroCommands::DoAudacityCommand(
EffectManager::Get().GetEffectByIdentifier(ctx.parameter),
ctx, EffectManager::kNone);
}