File indexing completed on 2024-05-05 03:56:26
0001 /* 0002 * SPDX-FileCopyrightText: 2021 Arjen Hiemstra <ahiemstra@heimr.nl> 0003 * 0004 * SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #ifndef INPUTMETHOD_H 0008 #define INPUTMETHOD_H 0009 0010 #include <memory> 0011 0012 #include <QObject> 0013 #include <qqmlregistration.h> 0014 0015 #include "kirigamiplatform_export.h" 0016 0017 namespace Kirigami 0018 { 0019 namespace Platform 0020 { 0021 0022 /** 0023 * This exposes information about the current used input method. 0024 */ 0025 class KIRIGAMIPLATFORM_EXPORT InputMethod : public QObject 0026 { 0027 Q_OBJECT 0028 QML_ELEMENT 0029 QML_SINGLETON 0030 0031 public: 0032 InputMethod(QObject *parent = nullptr); 0033 ~InputMethod() override; 0034 0035 /** 0036 * Is an input method available? 0037 * 0038 * This will be true if there is an input method available. When it is 0039 * false it means there's no special input method configured and input 0040 * happens directly through keyboard events. 0041 */ 0042 Q_PROPERTY(bool available READ available NOTIFY availableChanged FINAL) 0043 bool available() const; 0044 Q_SIGNAL void availableChanged(); 0045 0046 /** 0047 * Is the current input method enabled? 0048 * 0049 * If this is false, that means the input method is available but not in use. 0050 */ 0051 Q_PROPERTY(bool enabled READ enabled NOTIFY enabledChanged FINAL) 0052 bool enabled() const; 0053 Q_SIGNAL void enabledChanged(); 0054 0055 /** 0056 * Is the current input method active? 0057 * 0058 * What active means depends on the type of input method. In case of a 0059 * virtual keyboard for example, it would mean the virtual keyboard is 0060 * visible. 0061 */ 0062 Q_PROPERTY(bool active READ active NOTIFY activeChanged FINAL) 0063 bool active() const; 0064 Q_SIGNAL void activeChanged(); 0065 0066 /** 0067 * Is the current input method visible? 0068 * 0069 * For some input methods this will match \ref active however for others this 0070 * may differ. 0071 */ 0072 Q_PROPERTY(bool visible READ visible NOTIFY visibleChanged FINAL) 0073 bool visible() const; 0074 Q_SIGNAL void visibleChanged(); 0075 0076 /** 0077 * Will the input method be shown when a text input field gains focus? 0078 * 0079 * This is intended to be used to decide whether to give an input field 0080 * default focus. For certain input methods, like virtual keyboards, it may 0081 * not be desirable to show it by default. For example, having a search 0082 * field focused on application startup may cause the virtual keyboard to 0083 * show, greatly reducing the available application space. 0084 */ 0085 Q_PROPERTY(bool willShowOnActive READ willShowOnActive NOTIFY willShowOnActiveChanged FINAL) 0086 bool willShowOnActive() const; 0087 Q_SIGNAL void willShowOnActiveChanged(); 0088 0089 private: 0090 class Private; 0091 const std::unique_ptr<Private> d; 0092 }; 0093 0094 } 0095 } 0096 0097 #endif // INPUTMETHOD_H