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
41KModifierKeyInfo::KModifierKeyInfo(QObject *parent)
42 : QObject(parent)
43 , p(createProvider())
44{
45 connect(sender: p.data(), signal: &KModifierKeyInfoProvider::keyPressed, context: this, slot: &KModifierKeyInfo::keyPressed);
46 connect(sender: p.data(), signal: &KModifierKeyInfoProvider::keyLatched, context: this, slot: &KModifierKeyInfo::keyLatched);
47 connect(sender: p.data(), signal: &KModifierKeyInfoProvider::keyLocked, context: this, slot: &KModifierKeyInfo::keyLocked);
48 connect(sender: p.data(), signal: &KModifierKeyInfoProvider::buttonPressed, context: this, slot: &KModifierKeyInfo::buttonPressed);
49 connect(sender: p.data(), signal: &KModifierKeyInfoProvider::keyAdded, context: this, slot: &KModifierKeyInfo::keyAdded);
50 connect(sender: p.data(), signal: &KModifierKeyInfoProvider::keyRemoved, context: this, slot: &KModifierKeyInfo::keyRemoved);
51}
52
53KModifierKeyInfo::~KModifierKeyInfo()
54{
55}
56
57bool KModifierKeyInfo::knowsKey(Qt::Key key) const
58{
59 return p->knowsKey(key);
60}
61
62const QList<Qt::Key> KModifierKeyInfo::knownKeys() const
63{
64 return p->knownKeys();
65}
66
67bool KModifierKeyInfo::isKeyPressed(Qt::Key key) const
68{
69 return p->isKeyPressed(key);
70}
71
72bool KModifierKeyInfo::isKeyLatched(Qt::Key key) const
73{
74 return p->isKeyLatched(key);
75}
76
77bool KModifierKeyInfo::setKeyLatched(Qt::Key key, bool latched)
78{
79 return p->setKeyLatched(key, latched);
80}
81
82bool KModifierKeyInfo::isKeyLocked(Qt::Key key) const
83{
84 return p->isKeyLocked(key);
85}
86
87bool KModifierKeyInfo::setKeyLocked(Qt::Key key, bool locked)
88{
89 return p->setKeyLocked(key, locked);
90}
91
92bool KModifierKeyInfo::isButtonPressed(Qt::MouseButton button) const
93{
94 return p->isButtonPressed(button);
95}
96
97#include "moc_kmodifierkeyinfo.cpp"
98

source code of kguiaddons/src/util/kmodifierkeyinfo.cpp