Added: Duplicating macro or macro commands

--HG--
branch : develop
This commit is contained in:
Nimetu 2018-05-11 14:42:49 +03:00
parent b5a0fbe266
commit 5823e98356
2 changed files with 46 additions and 0 deletions

View file

@ -234,6 +234,8 @@
<group type="menu" id="options_macro" exit_click_b="true" extends="base_menu" > <group type="menu" id="options_macro" exit_click_b="true" extends="base_menu" >
<action name="uimMacroExec" handler="macros_exec" /> <action name="uimMacroExec" handler="macros_exec" />
<action name="uimMacroEdit" handler="macros_edit" /> <action name="uimMacroEdit" handler="macros_edit" />
<action name="uimMacroCopy" handler="macros_copy" />
<separator/>
<action name="uimMacroDel" handler="macros_del" /> <action name="uimMacroDel" handler="macros_del" />
</group> </group>
@ -324,6 +326,8 @@
<action name="uimMCMoveUp" handler="new_macro_cmd_move_up" /> <action name="uimMCMoveUp" handler="new_macro_cmd_move_up" />
<action name="uimMCMoveDown" handler="new_macro_cmd_move_down" /> <action name="uimMCMoveDown" handler="new_macro_cmd_move_down" />
<action name="uimMCEdit" handler="new_macro_cmd_edit" /> <action name="uimMCEdit" handler="new_macro_cmd_edit" />
<action name="uimMCCopy" handler="new_macro_cmd_copy" />
<separator/>
<action name="uimMCDel" handler="new_macro_cmd_delete" /> <action name="uimMCDel" handler="new_macro_cmd_delete" />
</group> </group>

View file

@ -777,6 +777,25 @@ public:
}; };
REGISTER_ACTION_HANDLER( CHandlerNewMacroCmdEdit, "new_macro_cmd_edit"); REGISTER_ACTION_HANDLER( CHandlerNewMacroCmdEdit, "new_macro_cmd_edit");
// ***************************************************************************
// Called from context menu when we right click on a command of the new_macro container
class CHandlerNewMacroCmdCopy: public IActionHandler
{
public:
virtual void execute(CCtrlBase *pCaller, const string &/* Params */)
{
CMacroCmdManager *pMCM = CMacroCmdManager::getInstance();
sint nCmdNb = getCmdNbFromId(pCaller->getId());
pMCM->CurrentEditMacro.addCommand(pMCM->CurrentEditMacro.Commands[nCmdNb].Name,
pMCM->CurrentEditMacro.Commands[nCmdNb].Params,
nCmdNb);
CInterfaceManager *pIM = CInterfaceManager::getInstance();
CMacroCmdManager::getInstance()->EditCmd->deactivate();
CAHManager::getInstance()->runActionHandler("new_macro_open",NULL);
}
};
REGISTER_ACTION_HANDLER( CHandlerNewMacroCmdCopy, "new_macro_cmd_copy");
// *************************************************************************** // ***************************************************************************
// Called from context menu when we right click on a command of the new_macro container // Called from context menu when we right click on a command of the new_macro container
class CHandlerNewMacroCmdDelete: public IActionHandler class CHandlerNewMacroCmdDelete: public IActionHandler
@ -1087,6 +1106,29 @@ public:
}; };
REGISTER_ACTION_HANDLER( CHandlerMacrosEdit, "macros_edit"); REGISTER_ACTION_HANDLER( CHandlerMacrosEdit, "macros_edit");
// ***************************************************************************
// Called from context menu on a macro
class CHandlerMacrosCopy : public IActionHandler
{
public:
virtual void execute(CCtrlBase *pCaller, const string &/* Params */)
{
sint nMacNb = getMacroFromId(pCaller->getId());
CInterfaceManager *pIM = CInterfaceManager::getInstance();
CMacroCmdManager *pMCM = CMacroCmdManager::getInstance();
// duplicate selected macro
CMacroCmd m = pMCM->getMacros()[nMacNb];
m.ID = -1;
m.Combo.Key = KeyCount;
m.Combo.KeyButtons = noKeyButton;
pMCM->addMacro(m, nMacNb+1);
CAHManager::getInstance()->runActionHandler("macros_open",NULL);
}
};
REGISTER_ACTION_HANDLER( CHandlerMacrosCopy, "macros_copy");
// *************************************************************************** // ***************************************************************************
// Called from context menu on a macro // Called from context menu on a macro
class CHandlerMacrosDel : public IActionHandler class CHandlerMacrosDel : public IActionHandler