void MInputContext::updatePreedit(const QString &string, const QList<Maliit::PreeditTextFormat> &preeditFormats, int replacementStart, int replacementLength, int cursorPos) { if (debug) { qDebug() << InputContextName << "in" << __PRETTY_FUNCTION__ << "preedit:" << string << ", replacementStart:" << replacementStart << ", replacementLength:" << replacementLength << ", cursorPos:" << cursorPos; } if (imServer->pendingResets()) { return; } updatePreeditInternally(string, preeditFormats, replacementStart, replacementLength, cursorPos); }
bool MInputContext::event(QEvent *event) { #ifdef HAVE_MEEGOTOUCH if (event->type() == MPreeditInjectionEvent::eventNumber()) { if (correctionEnabled) { MPreeditInjectionEvent *injectionEvent = dynamic_cast<MPreeditInjectionEvent *>(event); if (injectionEvent == 0) { return false; } qDebug() << "MInputContext" << __PRETTY_FUNCTION__ << "MInputContext got preedit injection:" << injectionEvent->preedit() << ", event cursor pos:" << injectionEvent->eventCursorPosition(); // send the injected preedit to input method server and back to the widget with proper // styling // Note: plugin could change the preedit style in imServer->setPreedit(). // The cursor is hidden for preedit by default. The input method server can decide // whether it needs the cursor. QList<MInputMethod::PreeditTextFormat> preeditFormats; MInputMethod::PreeditTextFormat preeditFormat(0, injectionEvent->preedit().length(), MInputMethod::PreeditDefault); preeditFormats << preeditFormat; updatePreeditInternally(injectionEvent->preedit(), preeditFormats); imServer->setPreedit(injectionEvent->preedit(), injectionEvent->eventCursorPosition()); event->accept(); return true; } else { qDebug() << "MInputContext" << __PRETTY_FUNCTION__ << "MInputContext ignored preedit injection because correction is disabled"; return false; } } #endif return QInputContext::event(event); }