1 | // Copyright (C) 2021 The Qt Company Ltd. |
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
3 | |
4 | #ifndef SHIFTHANDLER_P_H |
5 | #define SHIFTHANDLER_P_H |
6 | |
7 | // |
8 | // W A R N I N G |
9 | // ------------- |
10 | // |
11 | // This file is not part of the Qt API. It exists purely as an |
12 | // implementation detail. This header file may change from version to |
13 | // version without notice, or even be removed. |
14 | // |
15 | // We mean it. |
16 | // |
17 | |
18 | #include <QObject> |
19 | #include <QtQml/qqml.h> |
20 | #include <QtVirtualKeyboard/qvirtualkeyboard_global.h> |
21 | #include <QtCore/private/qglobal_p.h> |
22 | |
23 | QT_BEGIN_NAMESPACE |
24 | |
25 | class QVirtualKeyboardInputContext; |
26 | class QVirtualKeyboardInputContextPrivate; |
27 | |
28 | namespace QtVirtualKeyboard { |
29 | |
30 | class ShiftHandlerPrivate; |
31 | |
32 | class Q_VIRTUALKEYBOARD_EXPORT ShiftHandler : public QObject |
33 | { |
34 | Q_OBJECT |
35 | Q_DISABLE_COPY(ShiftHandler) |
36 | Q_DECLARE_PRIVATE(ShiftHandler) |
37 | Q_PROPERTY(QString sentenceEndingCharacters READ sentenceEndingCharacters WRITE setSentenceEndingCharacters NOTIFY sentenceEndingCharactersChanged) |
38 | Q_PROPERTY(bool autoCapitalizationEnabled READ isAutoCapitalizationEnabled NOTIFY autoCapitalizationEnabledChanged) |
39 | Q_PROPERTY(bool toggleShiftEnabled READ isToggleShiftEnabled NOTIFY toggleShiftEnabledChanged) |
40 | Q_PROPERTY(bool shiftActive READ isShiftActive WRITE setShiftActive NOTIFY shiftActiveChanged) |
41 | Q_PROPERTY(bool capsLockActive READ isCapsLockActive WRITE setCapsLockActive NOTIFY capsLockActiveChanged) |
42 | Q_PROPERTY(bool uppercase READ isUppercase NOTIFY uppercaseChanged) |
43 | QML_NAMED_ELEMENT(ShiftHandler) |
44 | QML_UNCREATABLE("ShiftHandler is only available via InputContextPrivate.shiftHandler" ) |
45 | QML_ADDED_IN_VERSION(1, 0) |
46 | QML_EXTRA_VERSION(2, 0) |
47 | |
48 | explicit ShiftHandler(QVirtualKeyboardInputContext *parent = nullptr); |
49 | void init(); |
50 | |
51 | public: |
52 | ~ShiftHandler(); |
53 | |
54 | QString sentenceEndingCharacters() const; |
55 | void setSentenceEndingCharacters(const QString &value); |
56 | bool isAutoCapitalizationEnabled() const; |
57 | bool isToggleShiftEnabled() const; |
58 | bool isShiftActive() const; |
59 | void setShiftActive(bool active); |
60 | bool isCapsLockActive() const; |
61 | void setCapsLockActive(bool active); |
62 | bool isUppercase() const; |
63 | |
64 | Q_INVOKABLE void toggleShift(); |
65 | Q_INVOKABLE void clearToggleShiftTimer(); |
66 | |
67 | signals: |
68 | void sentenceEndingCharactersChanged(); |
69 | void toggleShiftEnabledChanged(); |
70 | void autoCapitalizationEnabledChanged(); |
71 | void shiftActiveChanged(); |
72 | void capsLockActiveChanged(); |
73 | void uppercaseChanged(); |
74 | |
75 | private slots: |
76 | void reset(); |
77 | void autoCapitalize(); |
78 | void restart(); |
79 | void localeChanged(); |
80 | void inputMethodVisibleChanged(); |
81 | |
82 | private: |
83 | void setAutoCapitalizationEnabled(bool enabled); |
84 | void setToggleShiftEnabled(bool enabled); |
85 | |
86 | private: |
87 | friend class ::QVirtualKeyboardInputContext; |
88 | friend class ::QVirtualKeyboardInputContextPrivate; |
89 | }; |
90 | |
91 | } // namespace QtVirtualKeyboard |
92 | QT_END_NAMESPACE |
93 | |
94 | #endif // SHIFTHANDLER_P_H |
95 | |