| 1 |
/* |
| 2 |
* Copyright (C) 2011~2017 by CSSlayer |
| 3 |
* [email protected] |
| 4 |
* |
| 5 |
* Redistribution and use in source and binary forms, with or without |
| 6 |
* modification, are permitted provided that the following conditions |
| 7 |
* are met: |
| 8 |
* |
| 9 |
* 1. Redistributions of source code must retain the above Copyright |
| 10 |
* notice, this list of conditions and the following disclaimer. |
| 11 |
* |
| 12 |
* 2. Redistributions in binary form must reproduce the above Copyright |
| 13 |
* notice, this list of conditions and the following disclaimer in the |
| 14 |
* documentation and/or other materials provided with the distribution. |
| 15 |
* |
| 16 |
* 3. Neither the name of the authors nor the names of its contributors |
| 17 |
* may be used to endorse or promote products derived from this |
| 18 |
* software without specific prior written permission. |
| 19 |
*/ |
| 20 |
|
| 21 |
#ifndef FCITXINPUTCONTEXTPROXY_H_ |
| 22 |
#define FCITXINPUTCONTEXTPROXY_H_ |
| 23 |
|
| 24 |
#include "inputcontext1proxy.h" |
| 25 |
#include "inputcontextproxy.h" |
| 26 |
#include "inputmethod1proxy.h" |
| 27 |
#include "inputmethodproxy.h" |
| 28 |
#include <QDBusConnection> |
| 29 |
#include <QDBusServiceWatcher> |
| 30 |
#include <QObject> |
| 31 |
|
| 32 |
class QDBusPendingCallWatcher; |
| 33 |
class FcitxWatcher; |
| 34 |
|
| 35 |
class FcitxInputContextProxy : public QObject { |
| 36 |
Q_OBJECT |
| 37 |
public: |
| 38 |
FcitxInputContextProxy(FcitxWatcher *watcher, QObject *parent); |
| 39 |
~FcitxInputContextProxy(); |
| 40 |
|
| 41 |
bool isValid() const; |
| 42 |
|
| 43 |
QDBusPendingReply<> focusIn(); |
| 44 |
QDBusPendingReply<> focusOut(); |
| 45 |
QDBusPendingCall processKeyEvent(uint keyval, uint keycode, uint state, |
| 46 |
bool type, uint time); |
| 47 |
bool processKeyEventResult(const QDBusPendingCall &call); |
| 48 |
QDBusPendingReply<> reset(); |
| 49 |
QDBusPendingReply<> setCapability(qulonglong caps); |
| 50 |
QDBusPendingReply<> setCursorRect(int x, int y, int w, int h); |
| 51 |
QDBusPendingReply<> setSurroundingText(const QString &text, uint cursor, |
| 52 |
uint anchor); |
| 53 |
QDBusPendingReply<> setSurroundingTextPosition(uint cursor, uint anchor); |
| 54 |
void setDisplay(const QString &display); |
| 55 |
|
| 56 |
Q_SIGNALS: |
| 57 |
void commitString(const QString &str); |
| 58 |
void currentIM(const QString &name, const QString &uniqueName, |
| 59 |
const QString &langCode); |
| 60 |
void deleteSurroundingText(int offset, uint nchar); |
| 61 |
void forwardKey(uint keyval, uint state, bool isRelease); |
| 62 |
void updateFormattedPreedit(const FcitxFormattedPreeditList &str, |
| 63 |
int cursorpos); |
| 64 |
void inputContextCreated(); |
| 65 |
|
| 66 |
private Q_SLOTS: |
| 67 |
void availabilityChanged(); |
| 68 |
void createInputContext(); |
| 69 |
void createInputContextFinished(); |
| 70 |
void serviceUnregistered(); |
| 71 |
void recheck(); |
| 72 |
void forwardKeyWrapper(uint keyval, uint state, int type); |
| 73 |
void updateFormattedPreeditWrapper(const FcitxFormattedPreeditList &str, |
| 74 |
int cursorpos); |
| 75 |
|
| 76 |
private: |
| 77 |
void cleanUp(); |
| 78 |
|
| 79 |
QDBusServiceWatcher m_watcher; |
| 80 |
FcitxWatcher *m_fcitxWatcher; |
| 81 |
org::fcitx::Fcitx::InputMethod *m_improxy = nullptr; |
| 82 |
org::fcitx::Fcitx::InputMethod1 *m_im1proxy = nullptr; |
| 83 |
org::fcitx::Fcitx::InputContext *m_icproxy = nullptr; |
| 84 |
org::fcitx::Fcitx::InputContext1 *m_ic1proxy = nullptr; |
| 85 |
QDBusPendingCallWatcher *m_createInputContextWatcher = nullptr; |
| 86 |
QString m_display; |
| 87 |
bool m_portal; |
| 88 |
}; |
| 89 |
|
| 90 |
#endif // FCITXINPUTCONTEXTPROXY_H_ |