1 | /* |
2 | * SPDX-FileCopyrightText: 2021 Arjen Hiemstra <ahiemstra@heimr.nl> |
3 | * |
4 | * SPDX-License-Identifier: LGPL-2.0-or-later |
5 | */ |
6 | |
7 | #ifndef INPUTMETHOD_H |
8 | #define INPUTMETHOD_H |
9 | |
10 | #include <memory> |
11 | |
12 | #include <QObject> |
13 | #include <qqmlregistration.h> |
14 | |
15 | #include "kirigamiplatform_export.h" |
16 | |
17 | namespace Kirigami |
18 | { |
19 | namespace Platform |
20 | { |
21 | |
22 | /*! |
23 | * \qmltype InputMethod |
24 | * \inqmlmodule org.kde.kirigami.platform |
25 | * |
26 | * \brief This exposes information about the current used input method. |
27 | */ |
28 | class KIRIGAMIPLATFORM_EXPORT InputMethod : public QObject |
29 | { |
30 | Q_OBJECT |
31 | QML_ELEMENT |
32 | QML_SINGLETON |
33 | |
34 | public: |
35 | InputMethod(QObject *parent = nullptr); |
36 | ~InputMethod() override; |
37 | |
38 | /*! |
39 | * \qmlproperty bool InputMethod::available |
40 | * |
41 | * \readonly |
42 | * |
43 | * Is an input method available? |
44 | * |
45 | * This will be true if there is an input method available. When it is |
46 | * false it means there's no special input method configured and input |
47 | * happens directly through keyboard events. |
48 | */ |
49 | Q_PROPERTY(bool available READ available NOTIFY availableChanged FINAL) |
50 | bool available() const; |
51 | Q_SIGNAL void availableChanged(); |
52 | |
53 | /*! |
54 | * \qmlproperty bool InputMethod::enabled |
55 | * |
56 | * \readonly |
57 | * |
58 | * Is the current input method enabled? |
59 | * |
60 | * If this is false, that means the input method is available but not in use. |
61 | */ |
62 | Q_PROPERTY(bool enabled READ enabled NOTIFY enabledChanged FINAL) |
63 | bool enabled() const; |
64 | Q_SIGNAL void enabledChanged(); |
65 | |
66 | /*! |
67 | * \qmlproperty bool InputMethod::active |
68 | * |
69 | * \readonly |
70 | * |
71 | * Is the current input method active? |
72 | * |
73 | * What active means depends on the type of input method. In case of a |
74 | * virtual keyboard for example, it would mean the virtual keyboard is |
75 | * visible. |
76 | */ |
77 | Q_PROPERTY(bool active READ active NOTIFY activeChanged FINAL) |
78 | bool active() const; |
79 | Q_SIGNAL void activeChanged(); |
80 | |
81 | /*! |
82 | * \qmlproperty bool InputMethod::visible |
83 | * |
84 | * \readonly |
85 | * |
86 | * Is the current input method visible? |
87 | * |
88 | * For some input methods this will match active however for others this |
89 | * may differ. |
90 | */ |
91 | Q_PROPERTY(bool visible READ visible NOTIFY visibleChanged FINAL) |
92 | bool visible() const; |
93 | Q_SIGNAL void visibleChanged(); |
94 | |
95 | /*! |
96 | * \qmlproperty bool InputMethod::willShowOnActive |
97 | * |
98 | * \readonly |
99 | * |
100 | * Will the input method be shown when a text input field gains focus? |
101 | * |
102 | * This is intended to be used to decide whether to give an input field |
103 | * default focus. For certain input methods, like virtual keyboards, it may |
104 | * not be desirable to show it by default. For example, having a search |
105 | * field focused on application startup may cause the virtual keyboard to |
106 | * show, greatly reducing the available application space. |
107 | */ |
108 | Q_PROPERTY(bool willShowOnActive READ willShowOnActive NOTIFY willShowOnActiveChanged FINAL) |
109 | bool willShowOnActive() const; |
110 | Q_SIGNAL void willShowOnActiveChanged(); |
111 | |
112 | private: |
113 | class Private; |
114 | const std::unique_ptr<Private> d; |
115 | }; |
116 | |
117 | } |
118 | } |
119 | |
120 | #endif // INPUTMETHOD_H |
121 | |