From 2b94c752df072f53ea8cffd5c84c291f5e804429 Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Wed, 18 Oct 2023 17:07:16 +0800 Subject: [PATCH] disalbe code suggestion while using ibus as the input method --- RedPandaIDE/editor.cpp | 18 +++++++++++++++++- RedPandaIDE/editor.h | 3 +++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/RedPandaIDE/editor.cpp b/RedPandaIDE/editor.cpp index 7ddaa3cb..71787806 100644 --- a/RedPandaIDE/editor.cpp +++ b/RedPandaIDE/editor.cpp @@ -57,6 +57,8 @@ QHash> Editor::mSharedParsers; +int Editor::mShouldDisableSuggestionInInputMethodEvent = -1; + Editor::Editor(QWidget *parent): Editor(parent,"untitled",ENCODING_AUTO_DETECT,nullptr,true,nullptr) { @@ -1338,7 +1340,21 @@ void Editor::mouseReleaseEvent(QMouseEvent *event) void Editor::inputMethodEvent(QInputMethodEvent *event) { - QSynedit::QSynEdit::inputMethodEvent(event); + QSynedit::QSynEdit::inputMethodEvent(event); +#ifdef Q_OS_UNIX + if (mShouldDisableSuggestionInInputMethodEvent == -1) { + //not inited + QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); + //input method is ibus, disable suggestion + mShouldDisableSuggestionInInputMethodEvent = + (env.value("QT_IM_MODULE")=="ibus" )? 1 : 0; + } + if (mShouldDisableSuggestionInInputMethodEvent == 1) { + if (pMainWindow->completionPopup()->isVisible()) + pMainWindow->completionPopup()->close(); + return; + } +#endif QString s = event->commitString(); if (s.isEmpty()) return; diff --git a/RedPandaIDE/editor.h b/RedPandaIDE/editor.h index e98a9534..2e4508e4 100644 --- a/RedPandaIDE/editor.h +++ b/RedPandaIDE/editor.h @@ -355,6 +355,9 @@ private: QMap mIdentCache; static QHash> mSharedParsers; +#ifdef Q_OS_UNIX + static int mShouldDisableSuggestionInInputMethodEvent; +#endif // QWidget interface protected: