diff --git a/qt5/dbusaddons/fcitxqtinputcontextproxy.cpp b/qt5/dbusaddons/fcitxqtinputcontextproxy.cpp index 75717c7..7d75a50 100644 --- a/qt5/dbusaddons/fcitxqtinputcontextproxy.cpp +++ b/qt5/dbusaddons/fcitxqtinputcontextproxy.cpp @@ -47,6 +47,11 @@ QDBusPendingReply<> FcitxQtInputContextProxy::focusOut() { return d->icproxy_->FocusOut(); } +QDBusPendingReply<> FcitxQtInputContextProxy::hideVirtualKeyboard() { + Q_D(FcitxQtInputContextProxy); + return d->icproxy_->HideVirtualKeyboard(); +} + QDBusPendingReply FcitxQtInputContextProxy::processKeyEvent( unsigned int keyval, unsigned int keycode, unsigned int state, bool type, unsigned int time) { @@ -90,6 +95,11 @@ FcitxQtInputContextProxy::setSurroundingTextPosition(unsigned int cursor, return d->icproxy_->SetSurroundingTextPosition(cursor, anchor); } +QDBusPendingReply<> FcitxQtInputContextProxy::showVirtualKeyboard() { + Q_D(FcitxQtInputContextProxy); + return d->icproxy_->ShowVirtualKeyboard(); +} + QDBusPendingReply<> FcitxQtInputContextProxy::prevPage() { Q_D(FcitxQtInputContextProxy); return d->icproxy_->PrevPage(); @@ -111,6 +121,11 @@ QDBusPendingReply<> FcitxQtInputContextProxy::invokeAction(unsigned int action, return d->icproxy_->InvokeAction(action, cursor); } +QDBusPendingReply FcitxQtInputContextProxy::isVirtualKeyboardVisible() { + Q_D(FcitxQtInputContextProxy); + return d->icproxy_->IsVirtualKeyboardVisible(); +} + bool FcitxQtInputContextProxy::supportInvokeAction() const { Q_D(const FcitxQtInputContextProxy); return d->supportInvokeAction_; diff --git a/qt5/dbusaddons/fcitxqtinputcontextproxy.h b/qt5/dbusaddons/fcitxqtinputcontextproxy.h index e313e1e..4bd12e9 100644 --- a/qt5/dbusaddons/fcitxqtinputcontextproxy.h +++ b/qt5/dbusaddons/fcitxqtinputcontextproxy.h @@ -35,6 +35,7 @@ public: public Q_SLOTS: QDBusPendingReply<> focusIn(); QDBusPendingReply<> focusOut(); + QDBusPendingReply<> hideVirtualKeyboard(); QDBusPendingReply processKeyEvent(unsigned int keyval, unsigned int keycode, unsigned int state, bool type, @@ -49,10 +50,12 @@ public Q_SLOTS: unsigned int anchor); QDBusPendingReply<> setSurroundingTextPosition(unsigned int cursor, unsigned int anchor); + QDBusPendingReply<> showVirtualKeyboard(); QDBusPendingReply<> prevPage(); QDBusPendingReply<> nextPage(); QDBusPendingReply<> selectCandidate(int i); QDBusPendingReply<> invokeAction(unsigned int action, int cursor); + QDBusPendingReply isVirtualKeyboardVisible(); bool supportInvokeAction() const; diff --git a/qt5/dbusaddons/fcitxqtinputcontextproxyimpl.h b/qt5/dbusaddons/fcitxqtinputcontextproxyimpl.h index 1830673..5e788b8 100644 --- a/qt5/dbusaddons/fcitxqtinputcontextproxyimpl.h +++ b/qt5/dbusaddons/fcitxqtinputcontextproxyimpl.h @@ -58,6 +58,12 @@ public Q_SLOTS: // METHODS return asyncCallWithArgumentList(QStringLiteral("FocusOut"), argumentList); } + inline QDBusPendingReply<> HideVirtualKeyboard() + { + QList argumentList; + return asyncCallWithArgumentList(QStringLiteral("HideVirtualKeyboard"), argumentList); + } + inline QDBusPendingReply<> InvokeAction(unsigned int action, int cursor) { QList argumentList; argumentList << QVariant::fromValue(action) @@ -66,6 +72,12 @@ public Q_SLOTS: // METHODS argumentList); } + inline QDBusPendingReply IsVirtualKeyboardVisible() + { + QList argumentList; + return asyncCallWithArgumentList(QStringLiteral("IsVirtualKeyboardVisible"), argumentList); + } + inline QDBusPendingReply<> NextPage() { QList argumentList; @@ -135,6 +147,12 @@ public Q_SLOTS: // METHODS return asyncCallWithArgumentList(QStringLiteral("SetSurroundingTextPosition"), argumentList); } + inline QDBusPendingReply<> ShowVirtualKeyboard() + { + QList argumentList; + return asyncCallWithArgumentList(QStringLiteral("ShowVirtualKeyboard"), argumentList); + } + Q_SIGNALS: // SIGNALS void CommitString(const QString &str); void CurrentIM(const QString &name, const QString &uniqueName, const QString &langCode); diff --git a/qt5/dbusaddons/interfaces/org.fcitx.Fcitx.InputContext1.xml b/qt5/dbusaddons/interfaces/org.fcitx.Fcitx.InputContext1.xml index 99d112a..ee0dec1 100644 --- a/qt5/dbusaddons/interfaces/org.fcitx.Fcitx.InputContext1.xml +++ b/qt5/dbusaddons/interfaces/org.fcitx.Fcitx.InputContext1.xml @@ -54,6 +54,13 @@ + + + + + + + diff --git a/qt5/platforminputcontext/qfcitxplatforminputcontext.cpp b/qt5/platforminputcontext/qfcitxplatforminputcontext.cpp index e323fe8..7e464b8 100644 --- a/qt5/platforminputcontext/qfcitxplatforminputcontext.cpp +++ b/qt5/platforminputcontext/qfcitxplatforminputcontext.cpp @@ -688,6 +688,32 @@ bool QFcitxPlatformInputContext::hasCapability(Capability) const { return true; } +void QFcitxPlatformInputContext::showInputPanel() { + auto *proxy = validIC(); + if (proxy == nullptr) { + return; + } + proxy->showVirtualKeyboard(); +} + +void QFcitxPlatformInputContext::hideInputPanel() { + auto *proxy = validIC(); + if (proxy == nullptr) { + return; + } + proxy->hideVirtualKeyboard(); +} + +bool QFcitxPlatformInputContext::isInputPanelVisible() const { + auto *proxy = const_cast(this)->validIC(); + if (proxy == nullptr) { + return false; + } + auto reply = proxy->isVirtualKeyboardVisible(); + reply.waitForFinished(); + return reply.value(); +} + void QFcitxPlatformInputContext::createICData(QWindow *w) { auto iter = icMap_.find(w); if (iter == icMap_.end()) { diff --git a/qt5/platforminputcontext/qfcitxplatforminputcontext.h b/qt5/platforminputcontext/qfcitxplatforminputcontext.h index 110370a..0c389c0 100644 --- a/qt5/platforminputcontext/qfcitxplatforminputcontext.h +++ b/qt5/platforminputcontext/qfcitxplatforminputcontext.h @@ -155,6 +155,9 @@ public: bool filterEvent(const QEvent *event) override; QLocale locale() const override; bool hasCapability(Capability capability) const override; + virtual void showInputPanel() override; + virtual void hideInputPanel() override; + virtual bool isInputPanelVisible() const override; public Q_SLOTS: void cursorRectChanged();