| 132 | // From the InputMethod to our internal window |
| 133 | |
| 134 | void InternalInputMethodContext::handlePreeditText(const QString &text, int cursorBegin, int cursorEnd) |
| 135 | { |
| 136 | QObject *focusObject = QGuiApplication::focusObject(); |
| 137 | if (!focusObject) { |
| 138 | return; |
| 139 | } |
| 140 | |
| 141 | QList<QInputMethodEvent::Attribute> attributes; |
| 142 | |
| 143 | if (cursorBegin != -1 || cursorEnd != -1) { |
| 144 | // Current supported cursor shape is just line. |
| 145 | // It means, cursorEnd and cursorBegin are the same. |
| 146 | QInputMethodEvent::Attribute attribute1(QInputMethodEvent::Cursor, |
| 147 | text.length(), |
| 148 | 1); |
| 149 | attributes.append(attribute1); |
| 150 | } |
| 151 | |
| 152 | // only use single underline style for now |
| 153 | QTextCharFormat format; |
| 154 | format.setFontUnderline(true); |
| 155 | format.setUnderlineStyle(QTextCharFormat::SingleUnderline); |
| 156 | QInputMethodEvent::Attribute attribute2(QInputMethodEvent::TextFormat, |
| 157 | 0, |
| 158 | text.length(), format); |
| 159 | attributes.append(attribute2); |
| 160 | |
| 161 | QInputMethodEvent event(text, attributes); |
| 162 | |
| 163 | QCoreApplication::sendEvent(focusObject, &event); |
| 164 | } |
| 165 | |
| 166 | void InternalInputMethodContext::handleCommitString(const QString &text) |
| 167 | { |
no test coverage detected