代码拉取完成,页面将自动刷新
同步操作将从 joyni/VirtualKeyboard 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#include <QInputMethodEvent>
#include <QCoreApplication>
#include <QKeyEvent>
#include "keyeventdispatcher.h"
KeyEventDispatcher::KeyEventDispatcher(QObject *parent) :
QObject(parent),m_focusItem(0)
{
}
void KeyEventDispatcher::setFocusItem(QObject *focusItem)
{
m_focusItem = focusItem;
}
void KeyEventDispatcher::sendKeyToFocusItem(const QString &keyText)
{
if (!m_focusItem) {
return;
}
if (keyText == QString("\x7F"))
{
QCoreApplication::sendEvent(m_focusItem, new QKeyEvent(QEvent::KeyPress, Qt::Key_Backspace, Qt::NoModifier));
QCoreApplication::sendEvent(m_focusItem, new QKeyEvent(QEvent::KeyRelease, Qt::Key_Backspace, Qt::NoModifier));
}
else if (keyText == QString("\n"))
{
QCoreApplication::sendEvent(m_focusItem, new QKeyEvent(QEvent::KeyPress, Qt::Key_Return, Qt::NoModifier));
QCoreApplication::sendEvent(m_focusItem, new QKeyEvent(QEvent::KeyRelease, Qt::Key_Return, Qt::NoModifier));
}
else if (keyText == QString("&&"))
{
QCoreApplication::sendEvent(m_focusItem, new QKeyEvent(QEvent::KeyPress, 0, Qt::NoModifier, "&"));
QCoreApplication::sendEvent(m_focusItem, new QKeyEvent(QEvent::KeyRelease, 0, Qt::NoModifier, "&"));
}
else if (keyText == QString("&CtrlC&"))
{
QCoreApplication::sendEvent(m_focusItem, new QKeyEvent(QEvent::KeyPress, Qt::Key_C, Qt::ControlModifier));
QCoreApplication::sendEvent(m_focusItem, new QKeyEvent(QEvent::KeyRelease, Qt::Key_C, Qt::ControlModifier));
}
else if (keyText == QString("&CtrlV&"))
{
QCoreApplication::sendEvent(m_focusItem, new QKeyEvent(QEvent::KeyPress, Qt::Key_V, Qt::ControlModifier));
QCoreApplication::sendEvent(m_focusItem, new QKeyEvent(QEvent::KeyRelease, Qt::Key_V, Qt::ControlModifier));
}
else if (keyText == QString("&Left&"))
{
QCoreApplication::sendEvent(m_focusItem, new QKeyEvent(QEvent::KeyPress, Qt::Key_Left, Qt::NoModifier));
QCoreApplication::sendEvent(m_focusItem, new QKeyEvent(QEvent::KeyRelease, Qt::Key_Left, Qt::NoModifier));
}
else if (keyText == QString("&CtrlA&"))
{
QCoreApplication::sendEvent(m_focusItem, new QKeyEvent(QEvent::KeyPress, Qt::Key_A, Qt::ControlModifier));
QCoreApplication::sendEvent(m_focusItem, new QKeyEvent(QEvent::KeyRelease, Qt::Key_A, Qt::ControlModifier));
}
else
{
QCoreApplication::sendEvent(m_focusItem, new QKeyEvent(QEvent::KeyPress, 0, Qt::NoModifier, keyText));
QCoreApplication::sendEvent(m_focusItem, new QKeyEvent(QEvent::KeyRelease, 0, Qt::NoModifier, keyText));
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。