KGuiAddons 5.109.0
Signals | Public Member Functions | List of all members
KModifierKeyInfo

Get information about the state of the keyboard's modifier keys. More...

#include <KModifierKeyInfo>

Signals

void buttonPressed (Qt::MouseButton button, bool pressed)
 This signal is emitted whenever the pressed state of a mouse button changes (mouse button press or release).
 
void keyAdded (Qt::Key key)
 This signal is emitted whenever a new modifier is found due to the keyboard mapping changing.
 
void keyLatched (Qt::Key key, bool latched)
 This signal is emitted whenever the latched state of a key changes.
 
void keyLocked (Qt::Key key, bool locked)
 This signal is emitted whenever the locked state of a key changes.
 
void keyPressed (Qt::Key key, bool pressed)
 This signal is emitted whenever the pressed state of a key changes (key press or key release).
 
void keyRemoved (Qt::Key key)
 This signal is emitted whenever a previously known modifier no longer exists due to the keyboard mapping changing.
 

Public Member Functions

 KModifierKeyInfo (QObject *parent=nullptr)
 Default constructor.
 
 ~KModifierKeyInfo () override
 Destructor.
 
bool isButtonPressed (Qt::MouseButton button) const
 Synchronously check if a mouse button is pressed.
 
bool isKeyLatched (Qt::Key key) const
 Synchronously check if a key is latched.
 
bool isKeyLocked (Qt::Key key) const
 Synchronously check if a key is locked.
 
bool isKeyPressed (Qt::Key key) const
 Synchronously check if a key is pressed.
 
const QList< Qt::Key > knownKeys () const
 Get a list of known keys.
 
bool knowsKey (Qt::Key key) const
 Check if a key is known by the underlying window system and can be queried.
 
bool setKeyLatched (Qt::Key key, bool latched)
 Set the latched state of a key.
 
bool setKeyLocked (Qt::Key key, bool locked)
 Set the locked state of a key.
 

Detailed Description

Get information about the state of the keyboard's modifier keys.

This class provides cross-platform information about the state of the keyboard's modifier keys and the mouse buttons and allows to change the state as well.

It recognizes two states a key can be in:

An application can either query the states synchronously (isKeyLatched(), isKeyLocked()) or connect to KModifierKeyInfo's signals to be notified about changes (keyLatched(), keyLocked()).

Constructor & Destructor Documentation

◆ KModifierKeyInfo()

KModifierKeyInfo::KModifierKeyInfo ( QObject *  parent = nullptr)
explicit

Default constructor.

◆ ~KModifierKeyInfo()

KModifierKeyInfo::~KModifierKeyInfo ( )
override

Destructor.

Member Function Documentation

◆ buttonPressed

void KModifierKeyInfo::buttonPressed ( Qt::MouseButton  button,
bool  pressed 
)
signal

This signal is emitted whenever the pressed state of a mouse button changes (mouse button press or release).

Parameters
buttonThe mouse button that changed state
pressedtrue if the mouse button is now pressed, false if is released.

◆ isButtonPressed()

bool KModifierKeyInfo::isButtonPressed ( Qt::MouseButton  button) const

Synchronously check if a mouse button is pressed.

Parameters
buttonThe mouse button to check
Returns
true if the mouse button is pressed, false if the mouse button is not pressed or its state is unknown.

◆ isKeyLatched()

bool KModifierKeyInfo::isKeyLatched ( Qt::Key  key) const

Synchronously check if a key is latched.

Parameters
keyThe key to check
Returns
true if the key is latched, false if the key is not latched or unknown.
See also
isKeyPressed,
isKeyLocked,
keyLatched

◆ isKeyLocked()

bool KModifierKeyInfo::isKeyLocked ( Qt::Key  key) const

Synchronously check if a key is locked.

Parameters
keyThe key to check
Returns
true if the key is locked, false if the key is not locked or unknown.
See also
isKeyPressed,
isKeyLatched,
keyLocked

◆ isKeyPressed()

bool KModifierKeyInfo::isKeyPressed ( Qt::Key  key) const

Synchronously check if a key is pressed.

Parameters
keyThe key to check
Returns
true if the key is pressed, false if the key is not pressed or unknown.
See also
isKeyLatched,
isKeyLocked,
keyPressed

◆ keyAdded

void KModifierKeyInfo::keyAdded ( Qt::Key  key)
signal

This signal is emitted whenever a new modifier is found due to the keyboard mapping changing.

Parameters
keyThe key that was discovered

◆ keyLatched

void KModifierKeyInfo::keyLatched ( Qt::Key  key,
bool  latched 
)
signal

This signal is emitted whenever the latched state of a key changes.

Parameters
keyThe key that changed state
latchedtrue if the key is now latched, false if it isn't

◆ keyLocked

void KModifierKeyInfo::keyLocked ( Qt::Key  key,
bool  locked 
)
signal

This signal is emitted whenever the locked state of a key changes.

Parameters
keyThe key that changed state
lockedtrue if the key is now locked, false if it isn't

◆ keyPressed

void KModifierKeyInfo::keyPressed ( Qt::Key  key,
bool  pressed 
)
signal

This signal is emitted whenever the pressed state of a key changes (key press or key release).

Parameters
keyThe key that changed state
pressedtrue if the key is now pressed, false if is released.

◆ keyRemoved

void KModifierKeyInfo::keyRemoved ( Qt::Key  key)
signal

This signal is emitted whenever a previously known modifier no longer exists due to the keyboard mapping changing.

Parameters
keyThe key that vanished

◆ knownKeys()

const QList< Qt::Key > KModifierKeyInfo::knownKeys ( ) const

Get a list of known keys.

Returns
A list of known keys of which states will be reported.

◆ knowsKey()

bool KModifierKeyInfo::knowsKey ( Qt::Key  key) const

Check if a key is known by the underlying window system and can be queried.

Parameters
keyThe key to check
Returns
true if the key is available, false if it is unknown

◆ setKeyLatched()

bool KModifierKeyInfo::setKeyLatched ( Qt::Key  key,
bool  latched 
)

Set the latched state of a key.

Parameters
keyThe key to latch
latchedtrue to latch the key, false to unlatch it.
Returns
false if the key is unknown. true doesn't guarantee you the operation worked.

◆ setKeyLocked()

bool KModifierKeyInfo::setKeyLocked ( Qt::Key  key,
bool  locked 
)

Set the locked state of a key.

Parameters
keyThe key to lock
latchedtrue to lock the key, false to unlock it.
Returns
false if the key is unknown. true doesn't guarantee you the operation worked.