Extract toQtModifiers to place where it belongs
`QEvdevKeyboardHandler` contains static method `toQtModifiers` which is not operating on any of its internal fields or types. This indicates that this method doesn't belong to this class, and in fact it should be moved to `QEvdevKeyboardMap` where types used in it are declared. Move this static method to `QEvdevKeyboardMap` namespace. This is a preparatory change to extract `QEvdevKeyboardMap` to separate header. Task-number: QTBUG-115777 Change-Id: Ibe88b40a56fb96772d903498611777b3ec19dded Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
This commit is contained in:
parent
bd475ddf47
commit
1d0ec32f71
@ -202,7 +202,7 @@ void QEvdevKeyboardHandler::processKeyEvent(int nativecode, int unicode, int qtc
|
||||
Qt::KeyboardModifiers modifiers, bool isPress, bool autoRepeat)
|
||||
{
|
||||
if (!autoRepeat)
|
||||
QGuiApplicationPrivate::inputDeviceManager()->setKeyboardModifiers(QEvdevKeyboardHandler::toQtModifiers(m_modifiers));
|
||||
QGuiApplicationPrivate::inputDeviceManager()->setKeyboardModifiers(QEvdevKeyboardMap::toQtModifiers(m_modifiers));
|
||||
|
||||
QWindow *window = nullptr;
|
||||
#ifdef Q_OS_WEBOS
|
||||
@ -336,7 +336,7 @@ QEvdevKeyboardHandler::KeycodeAction QEvdevKeyboardHandler::processKeycode(quint
|
||||
// so just report the plain mapping with additional modifiers.
|
||||
if ((it == map_plain && it != map_withmod) ||
|
||||
(map_withmod && !(map_withmod->qtcode & modmask))) {
|
||||
qtcode |= QEvdevKeyboardHandler::toQtModifiers(modifiers);
|
||||
qtcode |= QEvdevKeyboardMap::toQtModifiers(modifiers);
|
||||
}
|
||||
|
||||
if (m_composing == 2 && first_press && !(it->flags & QEvdevKeyboardMap::IsModifier)) {
|
||||
|
@ -78,6 +78,21 @@ namespace QEvdevKeyboardMap {
|
||||
ModCtrlR = 0x80
|
||||
// ModCapsShift = 0x100, // not supported!
|
||||
};
|
||||
|
||||
inline Qt::KeyboardModifiers toQtModifiers(quint8 mod)
|
||||
{
|
||||
Qt::KeyboardModifiers qtmod = Qt::NoModifier;
|
||||
|
||||
if (mod & (ModShift | ModShiftL | ModShiftR))
|
||||
qtmod |= Qt::ShiftModifier;
|
||||
if (mod & (ModControl | ModCtrlL | ModCtrlR))
|
||||
qtmod |= Qt::ControlModifier;
|
||||
if (mod & ModAlt)
|
||||
qtmod |= Qt::AltModifier;
|
||||
|
||||
return qtmod;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
inline QDataStream &operator>>(QDataStream &ds, QEvdevKeyboardMap::Mapping &m)
|
||||
@ -129,20 +144,6 @@ public:
|
||||
const QString &specification,
|
||||
const QString &defaultKeymapFile = QString());
|
||||
|
||||
static Qt::KeyboardModifiers toQtModifiers(quint8 mod)
|
||||
{
|
||||
Qt::KeyboardModifiers qtmod = Qt::NoModifier;
|
||||
|
||||
if (mod & (QEvdevKeyboardMap::ModShift | QEvdevKeyboardMap::ModShiftL | QEvdevKeyboardMap::ModShiftR))
|
||||
qtmod |= Qt::ShiftModifier;
|
||||
if (mod & (QEvdevKeyboardMap::ModControl | QEvdevKeyboardMap::ModCtrlL | QEvdevKeyboardMap::ModCtrlR))
|
||||
qtmod |= Qt::ControlModifier;
|
||||
if (mod & QEvdevKeyboardMap::ModAlt)
|
||||
qtmod |= Qt::AltModifier;
|
||||
|
||||
return qtmod;
|
||||
}
|
||||
|
||||
bool loadKeymap(const QString &file);
|
||||
void unloadKeymap();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user