KGuiAddons

kmodifierkeyinfo.cpp
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#include "kmodifierkeyinfo.h"
8#include "kmodifierkeyinfoprovider_p.h"
9#include <kguiaddons_debug.h>
10
11#include <QGuiApplication>
12
13#include "config.h"
14
15#if WITH_WAYLAND
16#include "kmodifierkeyinfoprovider_wayland.h"
17#endif
18
19#if WITH_X11
20#include "kmodifierkeyinfoprovider_xcb.h"
21#endif
22
23KModifierKeyInfoProvider *createProvider()
24{
25#if WITH_WAYLAND
26 if (qGuiApp->platformName() == QLatin1String("wayland")) {
27 return new KModifierKeyInfoProviderWayland;
28 }
29#endif
30
31#if WITH_X11
32 if (qGuiApp->platformName() == QLatin1String("xcb")) {
33 return new KModifierKeyInfoProviderXcb;
34 }
35#endif
36
37 qCWarning(KGUIADDONS_LOG) << "No modifierkeyinfo backend for platform" << qGuiApp->platformName();
38 return new KModifierKeyInfoProvider;
39}
40
42 : QObject(parent)
43 , p(createProvider())
44{
45 connect(p.data(), &KModifierKeyInfoProvider::keyPressed, this, &KModifierKeyInfo::keyPressed);
46 connect(p.data(), &KModifierKeyInfoProvider::keyLatched, this, &KModifierKeyInfo::keyLatched);
47 connect(p.data(), &KModifierKeyInfoProvider::keyLocked, this, &KModifierKeyInfo::keyLocked);
48 connect(p.data(), &KModifierKeyInfoProvider::buttonPressed, this, &KModifierKeyInfo::buttonPressed);
49 connect(p.data(), &KModifierKeyInfoProvider::keyAdded, this, &KModifierKeyInfo::keyAdded);
50 connect(p.data(), &KModifierKeyInfoProvider::keyRemoved, this, &KModifierKeyInfo::keyRemoved);
51}
52
56
58{
59 return p->knowsKey(key);
60}
61
63{
64 return p->knownKeys();
65}
66
68{
69 return p->isKeyPressed(key);
70}
71
73{
74 return p->isKeyLatched(key);
75}
76
78{
79 return p->setKeyLatched(key, latched);
80}
81
83{
84 return p->isKeyLocked(key);
85}
86
88{
89 return p->setKeyLocked(key, locked);
90}
91
93{
94 return p->isButtonPressed(button);
95}
96
97#include "moc_kmodifierkeyinfo.cpp"
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...
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
MouseButton
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Jul 19 2024 11:59:55 by doxygen 1.11.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.