From 941aaf5b65696a57cf44d19aaec4b083556ebe04 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger <bstoeger@mail.tuwien.ac.at> Date: Sat, 13 Aug 2022 19:20:35 +0200 Subject: [PATCH] desktop: let tag-widget completion popup accept composition events Attn: horrible hack! For some reason the completion-popup does not have the Qt::WA_InputMethodEnabled flag set. Thus, if the popup is open composition of characters breaks. Therefore, when starting completion, explicitly set the flag on the popup. This is 100% not how this was intended, but seems to work for now. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at> --- desktop-widgets/tagwidget.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/desktop-widgets/tagwidget.cpp b/desktop-widgets/tagwidget.cpp index 093317d3b..5e5e77e3c 100644 --- a/desktop-widgets/tagwidget.cpp +++ b/desktop-widgets/tagwidget.cpp @@ -96,6 +96,18 @@ void TagWidget::inputMethodEvent(QInputMethodEvent *e) reparse(); } +// Call complete on a QCompleter and set the WA_InputMethodEnabled on +// the popup if a popup is opened. We need that flag, otherwise composition +// events are not forwarded to the widget and the user cannot enter +// multi-key characters as long as the popup is active. +static void complete(QCompleter *completer) +{ + completer->complete(); + QWidget *popup = completer->popup(); + if (popup) + popup->setAttribute(Qt::WA_InputMethodEnabled); +} + void TagWidget::reparse() { highlight(); @@ -112,10 +124,10 @@ void TagWidget::reparse() if (popup) popup->hide(); } else { - m_completer->complete(); + complete(m_completer); } } else { - m_completer->complete(); + complete(m_completer); } } }