Commit bdd38bdd authored by Clinton Stimpson's avatar Clinton Stimpson
Browse files

ENH: Implement global key event recording and playback

      (not just for specific widget types).
parent b7950310
......@@ -66,6 +66,18 @@ bool pqBasicWidgetEventPlayer::playEvent(QObject* Object,
QCoreApplication::sendEvent(widget, &ku);
return true;
}
else if(Command == "keyEvent")
{
QStringList data = Arguments.split(':');
QKeyEvent ke(static_cast<QEvent::Type>(data[0].toInt()),
data[1].toInt(),
static_cast<Qt::KeyboardModifiers>(data[2].toInt()),
data[3],
!!data[4].toInt(),
data[5].toInt());
QCoreApplication::sendEvent(widget, &ke);
return true;
}
else
{
return false;
......
......@@ -33,6 +33,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "pqBasicWidgetEventTranslator.h"
#include <QEvent>
#include <QKeyEvent>
#include <QWidget>
pqBasicWidgetEventTranslator::pqBasicWidgetEventTranslator(QObject* p)
......@@ -59,6 +60,20 @@ bool pqBasicWidgetEventTranslator::translateEvent(QObject* Object,
emit recordEvent(Object, "contextMenu", "");
}
break;
case QEvent::KeyPress:
case QEvent::KeyRelease:
{
QKeyEvent* ke = static_cast<QKeyEvent*>(Event);
QString data =QString("%1:%2:%3:%4:%5:%6")
.arg(ke->type())
.arg(ke->key())
.arg(static_cast<int>(ke->modifiers()))
.arg(ke->text())
.arg(ke->isAutoRepeat())
.arg(ke->count());
emit recordEvent(Object, "keyEvent", data);
}
break;
default:
break;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment