File indexing completed on 2024-04-28 15:27:42

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 
0014 /**
0015  * This exposes information about the current used input method.
0016  */
0017 class InputMethod : public QObject
0018 {
0019     Q_OBJECT
0020 
0021 public:
0022     InputMethod(QObject *parent = nullptr);
0023     ~InputMethod() override;
0024 
0025     /**
0026      * @brief This property specifies whether an input method is available.
0027      *
0028      * This will be @c true if there is an input method available. When it is
0029      * @c false it means there's no special input method configured and input
0030      * happens directly through keyboard events.
0031      */
0032     Q_PROPERTY(bool available READ available NOTIFY availableChanged)
0033     bool available() const;
0034     Q_SIGNAL void availableChanged();
0035 
0036     /**
0037      * @brief This property sets whether the current input method is enabled.
0038      *
0039      * If this is false, that means the input method is available but not in use.
0040      */
0041     Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged)
0042     bool enabled() const;
0043     void setEnabled(bool newEnabled);
0044     Q_SIGNAL void enabledChanged();
0045 
0046     /**
0047      * @brief This property sets whether the current method is active.
0048      *
0049      * What active means depends on the type of input method. In case of a
0050      * virtual keyboard for example, it would mean the virtual keyboard is
0051      * visible.
0052      */
0053     Q_PROPERTY(bool active READ active WRITE setActive NOTIFY activeChanged)
0054     bool active() const;
0055     void setActive(bool newActive);
0056     Q_SIGNAL void activeChanged();
0057 
0058     /**
0059      * @brief This property specifies whether the current input method is visible.
0060      * Is the current input method visible?
0061      *
0062      * For some input methods this will match ::active, for others this may differ.
0063      */
0064     Q_PROPERTY(bool visible READ visible NOTIFY visibleChanged)
0065     bool visible() const;
0066     Q_SIGNAL void visibleChanged();
0067 
0068     /**
0069      * @brief This property sets whether the input method will be shown
0070      * when a text input field gains focus.
0071      *
0072      * This is intended to be used to decide whether to give an input field
0073      * default focus. For certain input methods, like virtual keyboards, it may
0074      * not be desirable to show it by default. For example, having a search
0075      * field focused on application startup may cause the virtual keyboard to
0076      * show, greatly reducing the available application space.
0077      */
0078     Q_PROPERTY(bool willShowOnActive READ willShowOnActive NOTIFY willShowOnActiveChanged)
0079     bool willShowOnActive() const;
0080     Q_SIGNAL void willShowOnActiveChanged();
0081 
0082 private:
0083     class Private;
0084     const std::unique_ptr<Private> d;
0085 };
0086 
0087 #endif // INPUTMETHOD_H