support different keyboard layout

This commit is contained in:
thez3ro 2017-03-27 18:11:34 +02:00 committed by Weslly
parent 6c1f023768
commit a6e142dd02

View File

@ -473,8 +473,12 @@ KeySym AutoTypePlatformX11::keyToKeySym(Qt::Key key)
return XK_Print;
case Qt::Key_ScrollLock:
return XK_Scroll_Lock;
case Qt::Key_Shift:
return XK_Shift_L;
case Qt::Key_Control:
return XK_Control_L;
case Qt::Key_Alt:
return XK_Alt_L;
default:
if (key >= Qt::Key_F1 && key <= Qt::Key_F16) {
return XK_F1 + (key - Qt::Key_F1);
@ -855,14 +859,23 @@ void AutoTypeExecutorX11::execClearField(AutoTypeClearField* action = nullptr)
{
Q_UNUSED(action);
m_platform->SendKey(m_platform->keyToKeySym(Qt::Key_Control), true);
m_platform->SendKeyPressedEvent(m_platform->charToKeySym('a'));
m_platform->SendKey(m_platform->keyToKeySym(Qt::Key_Control), false);
m_platform->SendKeyPressedEvent(m_platform->keyToKeySym(Qt::Key_Delete));
timespec ts;
ts.tv_sec = 0;
ts.tv_nsec = 25 * 1000 * 1000;
m_platform->SendKey(m_platform->keyToKeySym(Qt::Key_Control), true);
m_platform->SendKeyPressedEvent(m_platform->keyToKeySym(Qt::Key_Home));
m_platform->SendKey(m_platform->keyToKeySym(Qt::Key_Control), false);
nanosleep(&ts, nullptr);
m_platform->SendKey(m_platform->keyToKeySym(Qt::Key_Control), true);
m_platform->SendKey(m_platform->keyToKeySym(Qt::Key_Shift), true);
m_platform->SendKeyPressedEvent(m_platform->keyToKeySym(Qt::Key_End));
m_platform->SendKey(m_platform->keyToKeySym(Qt::Key_Shift), false);
m_platform->SendKey(m_platform->keyToKeySym(Qt::Key_Control), false);
nanosleep(&ts, nullptr);
m_platform->SendKeyPressedEvent(m_platform->keyToKeySym(Qt::Key_Backspace));
nanosleep(&ts, nullptr);
}