7#include "kmodifierkeyinfoprovider_p.h"
9KModifierKeyInfoProvider::KModifierKeyInfoProvider()
14KModifierKeyInfoProvider::~KModifierKeyInfoProvider()
18bool KModifierKeyInfoProvider::setKeyLatched(
Qt::Key key,
bool latched)
25bool KModifierKeyInfoProvider::setKeyLocked(
Qt::Key key,
bool locked)
32bool KModifierKeyInfoProvider::isKeyPressed(
Qt::Key key)
const
34 auto it = m_modifierStates.constFind(key);
35 if (it != m_modifierStates.constEnd()) {
41bool KModifierKeyInfoProvider::isKeyLatched(
Qt::Key key)
const
43 auto it = m_modifierStates.constFind(key);
44 if (it != m_modifierStates.constEnd()) {
50bool KModifierKeyInfoProvider::isKeyLocked(
Qt::Key key)
const
52 auto it = m_modifierStates.constFind(key);
53 if (it != m_modifierStates.constEnd()) {
59bool KModifierKeyInfoProvider::isButtonPressed(
Qt::MouseButton button)
const
61 if (m_buttonStates.contains(button)) {
62 return m_buttonStates[button];
67bool KModifierKeyInfoProvider::knowsKey(
Qt::Key key)
const
69 return m_modifierStates.contains(key);
74 return m_modifierStates.keys();
77void KModifierKeyInfoProvider::stateUpdated(
Qt::Key key, KModifierKeyInfoProvider::ModifierStates newState)
79 auto &state = m_modifierStates[key];
80 if (newState != state) {
81 const auto difference = (newState ^ state);
83 if (difference & Pressed) {
84 Q_EMIT keyPressed(key, newState & Pressed);
86 if (difference & Latched) {
87 Q_EMIT keyLatched(key, newState & Latched);
89 if (difference & Locked) {
90 Q_EMIT keyLocked(key, newState & Locked);
95#include "moc_kmodifierkeyinfoprovider_p.cpp"