2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2016 Nicolas Arnaud-Cormos
|
2022-12-21 10:12:09 +01:00
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
2010-12-20 10:35:30 +01:00
|
|
|
|
|
|
|
|
#include "imacrohandler.h"
|
|
|
|
|
|
|
|
|
|
#include "macro.h"
|
|
|
|
|
|
2013-08-23 14:33:43 +02:00
|
|
|
using namespace Macros::Internal;
|
2010-12-20 10:35:30 +01:00
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
\class Macro::IEventHandler
|
2013-06-05 14:29:24 +02:00
|
|
|
\brief The IEventHandler class is a base class for all macro event handlers.
|
2010-12-20 10:35:30 +01:00
|
|
|
|
|
|
|
|
An event handler is used to handle a specific type of macro events.
|
2013-09-06 17:23:10 +02:00
|
|
|
They are used to create and replay macro events. Use
|
|
|
|
|
MacroManager::registerEventHandler
|
2010-12-20 10:35:30 +01:00
|
|
|
to add a new event handler.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
\fn void IEventHandler::startRecording(Macro* macro)
|
|
|
|
|
|
2013-09-06 17:23:10 +02:00
|
|
|
Initializes some data when starting to record a macro.
|
2010-12-20 10:35:30 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
\fn void IEventHandler::endRecordingMacro(Macro* macro)
|
|
|
|
|
|
2013-09-06 17:23:10 +02:00
|
|
|
Cleans up after recording a macro.
|
2010-12-20 10:35:30 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
\fn bool IEventHandler::canExecuteEvent(const MacroEvent ¯oEvent)
|
|
|
|
|
|
2013-09-06 17:23:10 +02:00
|
|
|
When replaying a macro, the manager iterates through all macro events
|
|
|
|
|
specified in \a macroEvent
|
2013-10-07 13:34:40 +02:00
|
|
|
in the macro and calls this function to determine which handler to use.
|
|
|
|
|
If the function returns \c true, \c executeEvent is called.
|
2010-12-20 10:35:30 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
\fn bool IEventHandler::executeEvent(const MacroEvent ¯oEvent)
|
|
|
|
|
|
2013-09-06 17:23:10 +02:00
|
|
|
Executes the specified \a macroEvent, using the values stored in
|
2010-12-20 10:35:30 +01:00
|
|
|
the macro event.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
// ---------- IMacroHandler ------------
|
|
|
|
|
|
|
|
|
|
void IMacroHandler::startRecording(Macro* macro)
|
|
|
|
|
{
|
2017-02-27 15:47:47 +01:00
|
|
|
m_currentMacro = macro;
|
2010-12-20 10:35:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void IMacroHandler::endRecordingMacro(Macro* macro)
|
|
|
|
|
{
|
|
|
|
|
Q_UNUSED(macro)
|
2017-02-27 15:47:47 +01:00
|
|
|
m_currentMacro = nullptr;
|
2010-12-20 10:35:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void IMacroHandler::addMacroEvent(const MacroEvent& event)
|
|
|
|
|
{
|
2017-02-27 15:47:47 +01:00
|
|
|
if (m_currentMacro)
|
|
|
|
|
m_currentMacro->append(event);
|
2010-12-20 10:35:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void IMacroHandler::setCurrentMacro(Macro *macro)
|
|
|
|
|
{
|
2017-02-27 15:47:47 +01:00
|
|
|
m_currentMacro = macro;
|
2010-12-20 10:35:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool IMacroHandler::isRecording() const
|
|
|
|
|
{
|
2017-02-27 15:47:47 +01:00
|
|
|
return m_currentMacro != nullptr;
|
2010-12-20 10:35:30 +01:00
|
|
|
}
|