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 | |
11 | namespace Kirigami |
12 | { |
13 | namespace Platform |
14 | { |
15 | |
16 | class KIRIGAMIPLATFORM_NO_EXPORT InputMethod::Private |
17 | { |
18 | public: |
19 | bool available = false; |
20 | bool enabled = false; |
21 | bool active = false; |
22 | bool visible = false; |
23 | }; |
24 | |
25 | InputMethod::InputMethod(QObject *parent) |
26 | : QObject(parent) |
27 | , d(std::make_unique<Private>()) |
28 | { |
29 | auto watcher = VirtualKeyboardWatcher::self(); |
30 | |
31 | connect(sender: watcher, signal: &VirtualKeyboardWatcher::availableChanged, context: this, slot: [this]() { |
32 | d->available = VirtualKeyboardWatcher::self()->available(); |
33 | Q_EMIT availableChanged(); |
34 | }); |
35 | |
36 | connect(sender: watcher, signal: &VirtualKeyboardWatcher::enabledChanged, context: this, slot: [this]() { |
37 | d->enabled = VirtualKeyboardWatcher::self()->enabled(); |
38 | Q_EMIT enabledChanged(); |
39 | }); |
40 | |
41 | connect(sender: watcher, signal: &VirtualKeyboardWatcher::activeChanged, context: this, slot: [this]() { |
42 | d->active = VirtualKeyboardWatcher::self()->active(); |
43 | Q_EMIT activeChanged(); |
44 | }); |
45 | |
46 | connect(sender: watcher, signal: &VirtualKeyboardWatcher::visibleChanged, context: this, slot: [this]() { |
47 | d->visible = VirtualKeyboardWatcher::self()->visible(); |
48 | Q_EMIT visibleChanged(); |
49 | }); |
50 | |
51 | connect(sender: watcher, signal: &VirtualKeyboardWatcher::willShowOnActiveChanged, context: this, slot: [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 | |
61 | InputMethod::~InputMethod() = default; |
62 | |
63 | bool InputMethod::available() const |
64 | { |
65 | return d->available; |
66 | } |
67 | |
68 | bool InputMethod::enabled() const |
69 | { |
70 | return d->enabled; |
71 | } |
72 | |
73 | bool InputMethod::active() const |
74 | { |
75 | return d->active; |
76 | } |
77 | |
78 | bool InputMethod::visible() const |
79 | { |
80 | return d->visible; |
81 | } |
82 | |
83 | bool InputMethod::willShowOnActive() const |
84 | { |
85 | return VirtualKeyboardWatcher::self()->willShowOnActive(); |
86 | } |
87 | |
88 | } |
89 | } |
90 | |
91 | #include "moc_inputmethod.cpp" |
92 | |