File indexing completed on 2025-01-26 05:09:00
0001 /* 0002 SPDX-FileCopyrightText: 2009 Aaron Seigo <aseigo@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #pragma once 0008 0009 #include <Plasma5Support/DataEngine> 0010 0011 #include <KLazyLocalizedString> 0012 #include <kmodifierkeyinfo.h> 0013 0014 /** 0015 * This engine provides the current state of the keyboard modifiers 0016 * and mouse buttons, primarily useful for accessibility feature support. 0017 */ 0018 class KeyStatesEngine : public Plasma5Support::DataEngine 0019 { 0020 Q_OBJECT 0021 0022 public: 0023 KeyStatesEngine(QObject *parent); 0024 ~KeyStatesEngine() override; 0025 0026 void init(); 0027 Plasma5Support::Service *serviceForSource(const QString &source) override; 0028 0029 protected: 0030 // bool sourceRequestEvent(const QString &name); 0031 // bool updateSourceEvent(const QString &source); 0032 0033 protected Q_SLOTS: 0034 void keyPressed(Qt::Key key, bool state); 0035 void keyLatched(Qt::Key key, bool state); 0036 void keyLocked(Qt::Key key, bool state); 0037 void mouseButtonPressed(Qt::MouseButton button, bool state); 0038 void keyAdded(Qt::Key key); 0039 void keyRemoved(Qt::Key key); 0040 0041 private: 0042 KModifierKeyInfo m_keyInfo; 0043 QMap<Qt::Key, KLazyLocalizedString> m_mods; 0044 QMap<Qt::MouseButton, KLazyLocalizedString> m_buttons; 0045 };