MCPcopy Create free account
hub / github.com/KDE/kwin / handlePreeditText

Method handlePreeditText

src/internalinputmethodcontext.cpp:134–164  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

132// From the InputMethod to our internal window
133
134void 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
166void InternalInputMethodContext::handleCommitString(const QString &text)
167{

Callers 2

commitStringMethod · 0.80
setPreeditStringMethod · 0.80

Calls 1

appendMethod · 0.80

Tested by

no test coverage detected