Monitor the keyboard state and emit signals, if the keyboard becomes active or inactive. More...
#include <keyboardmonitor.h>
Public Types | |
| enum | IgnoreKeys { IgnoreNoKeys = 0x0, IgnoreModifierKeys = 0x1, IgnoreModifierCombos = 0x2 } |
Which keys to ignore when checking the keyboard state. More... | |
Public Slots | |
| void | start () |
| Start monitoring the keyboard state. | |
| void | stop () |
| Stop monitoring the keyboard state. | |
| IgnoreKeys | ignoreKeys () const |
| Which keys to ignore? | |
| void | setIgnoreKeys (IgnoreKeys keys) |
| Ignore the given keys. | |
| int | idleTime () const |
| Get the idle time. | |
| void | setIdleTime (int msec) |
| Set the idle time. | |
| int | pollDelay () const |
| Get the polling delay. | |
| void | setPollDelay (int msec) |
| Set the polling delay. | |
| bool | isKeyboardActive () const |
| Is the keyboard currently active? | |
Signals | |
| void | typingStarted () |
| Emitted, if the keyboard became active, e.g. the user started typing. | |
| void | typingStopped () |
| Emitted, if the keyboard became inactive, e.g. the user stopped typing. | |
Public Member Functions | |
| KeyboardMonitor (QObject *parent=0) | |
| Create a new instance. | |
| virtual | ~KeyboardMonitor () |
Properties | |
| IgnoreKeys | ignoreKeys |
| Which keys to ignore. | |
| int | idleTime |
| The time in ms between the end of the keyboard activity and emitting typingStopped(). | |
| int | pollDelay |
| The time in ms between to consecutive keyboard checks. | |
| bool | keyboardActive |
| Is the keyboard active? | |
Monitor the keyboard state and emit signals, if the keyboard becomes active or inactive.
This class polls the keyboard state periodically (see pollDelay). Whenever the keyboard state changes, the corresponding signals are emitted (see typingStarted() and typingStopped()). However, to minimize "false positives" (if the user is just making a short break during typing), this class waits a configurable amount of time (see idleTime), before emitting typingStopped().
Polling is neither nice nor elegant, however the required XRecord extension is unfortunately broken as of Xorg server 1.6.
Which keys to ignore when checking the keyboard state.
| KeyboardMonitor::KeyboardMonitor | ( | QObject * | parent = 0 |
) |
Create a new instance.
| parent | same as for QObject(QObject *) |
| KeyboardMonitor::~KeyboardMonitor | ( | ) | [virtual] |
Destroy this instance.
| int synaptiks::KeyboardMonitor::idleTime | ( | ) | const [slot] |
| IgnoreKeys synaptiks::KeyboardMonitor::ignoreKeys | ( | ) | const [slot] |
| bool KeyboardMonitor::isKeyboardActive | ( | ) | const [slot] |
Is the keyboard currently active?
true, if the keyboard is active right now, false otherwise. | int synaptiks::KeyboardMonitor::pollDelay | ( | ) | const [slot] |
| void KeyboardMonitor::setIdleTime | ( | int | msec | ) | [slot] |
| void KeyboardMonitor::setIgnoreKeys | ( | IgnoreKeys | keys | ) | [slot] |
| void KeyboardMonitor::setPollDelay | ( | int | msec | ) | [slot] |
| void synaptiks::KeyboardMonitor::typingStopped | ( | ) | [signal] |
Emitted, if the keyboard became inactive, e.g. the user stopped typing.
int KeyboardMonitor::idleTime [read, write] |
The time in ms between the end of the keyboard activity and emitting typingStopped().
typingStopped() is not immediately emitted, when the keyboard becomes inactive. The user could just be making a short break. Instead, the class waits for the given amount of milliseconds, before emitting typingStopped().
The default is 2000 ms, which is 2 s.
KeyboardMonitor::IgnoreKeys KeyboardMonitor::ignoreKeys [read, write] |
Which keys to ignore.
The default is to ignore no keys (IgnoreKeys::IgnoreNoKeys).
bool synaptiks::KeyboardMonitor::keyboardActive [read] |
Is the keyboard active?
int KeyboardMonitor::pollDelay [read, write] |
The time in ms between to consecutive keyboard checks.
The polling delay is the time span between two consecutive queries of the keyboard state. The default is 200 ms, which is 0.2 s. This means, the keyboard will be checked every 200 ms.
1.6.3