Debian Codegraph @

qt6/platforminputcontext/hybridinputcontext.h

raw
1 /*
2 * SPDX-FileCopyrightText: 2023~2023 CSSlayer <[email protected]>
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 *
6 */
7
8 #ifndef HYBRIDINPUTCONTEXT_H
9 #define HYBRIDINPUTCONTEXT_H
10
11 #include "fcitx4inputcontextproxy.h"
12 #include "fcitx4watcher.h"
13 #include "fcitxqtdbustypes.h"
14 #include "fcitxqtinputcontextproxy.h"
15 #include "fcitxqtwatcher.h"
16 #include <QDBusPendingReply>
17 #include <QObject>
18 #include <QString>
19 #include <QTimer>
20
21 namespace fcitx {
22
23 class HybridInputContext : public QObject {
24 Q_OBJECT
25 public:
26 HybridInputContext(FcitxQtWatcher *watcher, Fcitx4Watcher *fcitx4Watcher,
27 QObject *parent);
28
29 void focusIn();
30 void focusOut();
31 void setSurroundingText(const QString &text, unsigned int cursor,
32 unsigned int anchor);
33 void setSurroundingTextPosition(unsigned int cursor, unsigned int anchor);
34
35 void prevPage();
36 void nextPage();
37 void reset();
38 void selectCandidate(int index);
39
40 bool supportInvokeAction() const;
41 void invokeAction(unsigned int action, int cursor);
42
43 bool isValid() const;
44
45 void showVirtualKeyboard();
46 void hideVirtualKeyboard();
47 bool isVirtualKeyboardVisible() const;
48
49 void setDisplay(const QString &display);
50
51 void setCapability(quint64 capability);
52 void setCursorRect(int x, int y, int w, int h);
53 void setCursorRectV2(int x, int y, int w, int h, double scale);
54 void setSupportedCapability(quint64 supported);
55 QDBusPendingCall processKeyEvent(unsigned int keyval, unsigned int keycode,
56 unsigned int state, bool type,
57 unsigned int time);
58 static bool processKeyEventResult(const QDBusPendingCall &call);
59
60 Q_SIGNALS:
61 void commitString(const QString &str);
62 void currentIM(const QString &name, const QString &uniqueName,
63 const QString &langCode);
64 void deleteSurroundingText(int offset, unsigned int nchar);
65 void forwardKey(unsigned int keyval, unsigned int state, bool isRelease);
66 void updateFormattedPreedit(const FcitxQtFormattedPreeditList &str,
67 int cursorpos);
68 void updateClientSideUI(const FcitxQtFormattedPreeditList &preedit,
69 int cursorpos,
70 const FcitxQtFormattedPreeditList &auxUp,
71 const FcitxQtFormattedPreeditList &auxDown,
72 const FcitxQtStringKeyValueList &candidates,
73 int candidateIndex, int layoutHint, bool hasPrev,
74 bool hasNext);
75 void inputContextCreated(const QByteArray &uuid);
76 void notifyFocusOut();
77 void virtualKeyboardVisibilityChanged(bool visible);
78
79 private Q_SLOTS:
80 void recheck();
81 void doRecheck(bool skipFcitx5);
82 void inputContextCreationFailed();
83
84 private:
85 QTimer timer_;
86 FcitxQtWatcher *watcher_;
87 Fcitx4Watcher *fcitx4Watcher_;
88 FcitxQtInputContextProxy *proxy_ = nullptr;
89 Fcitx4InputContextProxy *proxy4_ = nullptr;
90 QString display_;
91 };
92
93 } // namespace fcitx
94
95 #endif