KGuiAddons 5.109.0
kmodifierkeyinfo.h
1/*
2 SPDX-FileCopyrightText: 2009 Michael Leupold <lemma@confuego.org>
3
4 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
5*/
6
7#ifndef KMODIFIERKEYINFO_H
8#define KMODIFIERKEYINFO_H
9
10#include <kguiaddons_export.h>
11
12#include <QExplicitlySharedDataPointer>
13#include <QObject>
14
15class KModifierKeyInfoProvider;
16
35class KGUIADDONS_EXPORT KModifierKeyInfo : public QObject
36{
37 Q_OBJECT
38
39public:
43 explicit KModifierKeyInfo(QObject *parent = nullptr);
44
49
56 bool knowsKey(Qt::Key key) const;
57
63 const QList<Qt::Key> knownKeys() const;
64
72 bool isKeyPressed(Qt::Key key) const;
73
81 bool isKeyLatched(Qt::Key key) const;
82
91 bool setKeyLatched(Qt::Key key, bool latched);
92
100 bool isKeyLocked(Qt::Key key) const;
101
110 bool setKeyLocked(Qt::Key key, bool locked);
111
119 bool isButtonPressed(Qt::MouseButton button) const;
120
121Q_SIGNALS:
129 void keyPressed(Qt::Key key, bool pressed);
130
137 void keyLatched(Qt::Key key, bool latched);
138
145 void keyLocked(Qt::Key key, bool locked);
146
155 void buttonPressed(Qt::MouseButton button, bool pressed);
156
163 void keyAdded(Qt::Key key);
164
171 void keyRemoved(Qt::Key key);
172
173private:
174 Q_DISABLE_COPY(KModifierKeyInfo)
175 QExplicitlySharedDataPointer<KModifierKeyInfoProvider> const p; // krazy:exclude=dpointer
176};
177
178#endif
Get information about the state of the keyboard's modifier keys.
Definition kmodifierkeyinfo.h:36
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 keyAdded(Qt::Key key)
This signal is emitted whenever a new modifier is found due to the keyboard mapping changing.
const QList< Qt::Key > knownKeys() const
Get a list of known keys.
void keyRemoved(Qt::Key key)
This signal is emitted whenever a previously known modifier no longer exists due to the keyboard mapp...
bool setKeyLocked(Qt::Key key, bool locked)
Set the locked state of a key.
KModifierKeyInfo(QObject *parent=nullptr)
Default constructor.
void keyLocked(Qt::Key key, bool locked)
This signal is emitted whenever the locked state of a key changes.
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.
~KModifierKeyInfo() override
Destructor.
void keyLatched(Qt::Key key, bool latched)
This signal is emitted whenever the latched state of a key changes.
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 isKeyPressed(Qt::Key key) const
Synchronously check if a key is pressed.
bool isKeyLocked(Qt::Key key) const
Synchronously check if a key is locked.
void buttonPressed(Qt::MouseButton button, bool pressed)
This signal is emitted whenever the pressed state of a mouse button changes (mouse button press or re...