Kirigami2

inputmethod.cpp
1/*
2 * SPDX-FileCopyrightText: 2021 Arjen Hiemstra <ahiemstra@heimr.nl>
3 *
4 * SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6
7#include "inputmethod.h"
8
9#include "virtualkeyboardwatcher.h"
10
11namespace Kirigami
12{
13namespace Platform
14{
15
16class KIRIGAMIPLATFORM_NO_EXPORT InputMethod::Private
17{
18public:
19 bool available = false;
20 bool enabled = false;
21 bool active = false;
22 bool visible = false;
23};
24
25InputMethod::InputMethod(QObject *parent)
26 : QObject(parent)
27 , d(std::make_unique<Private>())
28{
29 auto watcher = VirtualKeyboardWatcher::self();
30
31 connect(watcher, &VirtualKeyboardWatcher::availableChanged, this, [this]() {
32 d->available = VirtualKeyboardWatcher::self()->available();
33 Q_EMIT availableChanged();
34 });
35
36 connect(watcher, &VirtualKeyboardWatcher::enabledChanged, this, [this]() {
37 d->enabled = VirtualKeyboardWatcher::self()->enabled();
38 Q_EMIT enabledChanged();
39 });
40
41 connect(watcher, &VirtualKeyboardWatcher::activeChanged, this, [this]() {
42 d->active = VirtualKeyboardWatcher::self()->active();
43 Q_EMIT activeChanged();
44 });
45
46 connect(watcher, &VirtualKeyboardWatcher::visibleChanged, this, [this]() {
47 d->visible = VirtualKeyboardWatcher::self()->visible();
48 Q_EMIT visibleChanged();
49 });
50
51 connect(watcher, &VirtualKeyboardWatcher::willShowOnActiveChanged, this, [this]() {
52 Q_EMIT willShowOnActiveChanged();
53 });
54
55 d->available = watcher->available();
56 d->enabled = watcher->enabled();
57 d->active = watcher->active();
58 d->visible = watcher->visible();
59}
60
61InputMethod::~InputMethod() = default;
62
63bool InputMethod::available() const
64{
65 return d->available;
66}
67
68bool InputMethod::enabled() const
69{
70 return d->enabled;
71}
72
73bool InputMethod::active() const
74{
75 return d->active;
76}
77
78bool InputMethod::visible() const
79{
80 return d->visible;
81}
82
83bool InputMethod::willShowOnActive() const
84{
85 return VirtualKeyboardWatcher::self()->willShowOnActive();
86}
87
88}
89}
90
91#include "moc_inputmethod.cpp"
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri May 24 2024 11:50:33 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.